Commit graph

1563 commits

Author SHA1 Message Date
jenkins-bot
cd5a34611a Merge "Title: Use directly Language::factory instead of wfGetLangObj" 2018-06-18 01:12:07 +00:00
jenkins-bot
84fa176c9c Merge "Avoid deprecated LinkCache::singleton()" 2018-06-14 23:48:54 +00:00
Brian Wolff
d561f646b9 Make $wgEmailConfirmToEdit only affect edit actions.
Previously it would affect all actions that use Title::userCan.
This used to be less noticable, but recently was expanded to include
the 'read' action. This only affected the case where both
$wgBlockDisablesLogin and $wgEmailConfirmedToEdit were enabled.

I don't think anyone was relying on the old behaviour as it was
undocumented, and only affected obscure permissions (checked with
Title::userCan and not depending on "edit" rights)

Follow-up b675be2083

Bug: T143790
Change-Id: I4ad93ed78de4f1ed444f73df6dc26d405a67e553
2018-06-12 00:13:18 +00:00
Kunal Mehta
c4e5a9dd97 Avoid deprecated LinkCache::singleton()
Change-Id: Ie0e5c4ef0fe6ec896378bb2433af0898655dd907
2018-06-10 23:55:11 -07:00
Fomafix
b89445db35 Title: Use directly Language::factory instead of wfGetLangObj
$this->mPageLanguage[0] get serialized with ->getCode() so it can
deserialized with Language::factory( $this->mPageLanguage[0] ).

Change-Id: I3e2bf51eb088d064d809549cfb8d15cfb464b1a9
2018-06-10 16:22:21 +02:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Bartosz Dziewoński
b191e5e860 Use PHP 7 '<=>' operator in 'sort()' callbacks
`$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser,
and `0` if they are equal, which are exactly the values 'sort()'
callbacks are supposed to return.

It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]`
to sort arrays of objects first by 'x', and by 'y' if they are equal.

* Replace a common pattern like `return $a < $b ? -1 : 1` with the
  new operator (and similar patterns with the variables, the numbers
  or the comparison inverted). Some of the uses were previously not
  correctly handling the variables being equal; this is now
  automatically fixed.
* Also replace `return $a - $b`, which is equivalent to `return
  $a <=> $b` if both variables are integers but less intuitive.
* (Do not replace `return strcmp( $a, $b )`. It is also equivalent
  when both variables are strings, but if any of the variables is not,
  'strcmp()' converts it to a string before comparison, which could
  give different results than '<=>', so changing this would require
  careful review and isn't worth it.)
* Also replace `return $a > $b`, which presumably sort of works most
  of the time (returns `1` if `$b` is lesser, and `0` if they are
  equal or `$a` is lesser) but is erroneous.

Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
2018-05-30 18:05:20 -07:00
Kunal Mehta
230958d97c Autofix MediaWiki.Commenting.FunctionComment.SpacingDoc* errors
Change-Id: I63761ebce04c03b9b13237919c27cc10180f198f
2018-05-19 14:07:03 -07:00
Aaron Schulz
6b174467a9 Add missing __METHOD__ to onTransactionPreCommitOrIdle() caller
Change-Id: I3722411dc63ff69253096f9c05e4fd1f130931ae
2018-05-15 14:50:24 -07:00
Timo Tijhof
045e6b8738 Title: Simplify use of MWNamespace::getCanonicalName()
The exists() check performs most of what getCanonicalName() will
do a second time. Make the code more simple, DRY, and performant,
by aiming for EAFP instead of LBYL.

Also fixes a potential bug where it was using current namespace
from $this for exists(), but subject namespace (stored as $namespace)
for getCanonicalName().

Change-Id: I11539bde00bf3df3270869f40fbd62083588b50c
2018-04-10 18:11:03 +01:00
James D. Forrester
2ae7d6b580 Add protection for User: JSON pages in the same manner as JS & CSS ones
Also recognise MediaWiki: JSON pages (with the existing protection of
the editinterface right).

Bug: T76554
Change-Id: Idba166d82ee6dd507d7345c9bdbefc8ca78ed7b4
2018-03-29 14:33:46 +00:00
James D. Forrester
35ba7839be Drop Title::getTitleInvalidRegex(), deprecated in 1.25
Change-Id: I8b8dd744c4c2ca5a13c89701b44013ddda785f3b
2018-03-26 10:55:41 -07:00
James D. Forrester
f4ec592330 Follow-up 6d4e1547: Hard-deprecate these functions
Only use in Wikimedia production is in GlobalCssJs, below.

Depends-On: I7543fe9ea393901379c16c4f0b1e96fa20955b6f
Change-Id: I66292b179d948e46dba3513f50c3d36012765a9d
2018-03-02 00:48:26 +00:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
James D. Forrester
6d4e15476c Title: Refactor JS/CSS page handling to be more sane
Change-Id: Ia7837dc614dcc8896a7d4b6d663dc45b6bd4f7ee
2018-02-16 17:35:12 +00:00
jenkins-bot
bbedc24556 Merge "Pass $key into CommentStore methods and use MediawikiServices" 2018-02-06 15:31:59 +00:00
Fomafix
73a514b574 Remove superfluous spaces and semicolons in comments
Change-Id: Ib4b452f1843ec250c8c1fcc2a738d80726b6135d
2018-02-05 19:05:57 +00:00
addshore
e5879da149 Pass $key into CommentStore methods and use MediawikiServices
This allows CommentStore to be added to MediaWikiServices
without the need of an aditional Factory.

This change includes a compatability layer to allow the behaviour
from 1.30 to continue to be used while deprecated.

CommentStore::newKey has been deprecated.
Keys are now passed into the public methods of CommentStore
where needed.
The following CommentStore methods have had their signatures changed
to introduced a $key parameter, but when used in conjunction with
CommentStore::newKey behaviour will remain unchanged:
  * CommentStore::getFields
  * CommentStore::getJoin
  * CommentStore::getComment
  * CommentStore::getCommentLegacy
  * CommentStore::insert
  * CommentStore::insertWithTemplate

Change-Id: I3abb62a5cfb0dcd456da9f4eb35583476ae41cfb
2018-02-05 15:34:12 +00:00
Max Semenik
36e6ab15da Fix called function case in a bunch of places
Change-Id: If1e392290a5bab3bce389f7da692e53a748b8aff
2018-01-22 09:10:09 -08:00
Stanislav Malyshev
7efe60da09 Fix phpdoc since $proto can be int
In fact, some of the PROTO_* constants are ints,
some strings and one is null (PROTO_CURRENT).

Change-Id: I69c45ab87360ed1ab54b53b7e9e959ea566b4cba
2018-01-18 13:17:12 -08:00
Thiemo Mättig
fa15c98787 Improve (weak and strict) type hints invarious places
Change-Id: I3a42ec1547fae971d7b495c99dd144739d8521ab
2017-12-28 16:31:56 +01:00
addshore
8b89b5ed2f Improve phpdoc of 'OldRestrictions' in Title
The previous version of the phpdoc simply says
that the field contains a comma seperated list of
page restrictions, which is wrong.
The field is actually a colon seperated list of comma
seperated lists.

The new phpdoc and example have been pulled from mw.org
and checked against what actually exists in a real db.

Change-Id: I6bfdfd87120150e4b53e1b4c49e95041f55d8c97
2017-12-05 11:29:16 -08:00
Max Semenik
4d8b064fae Title: Use a more proper way of detecting whether interwikis are local
Bug: T181575
Change-Id: Ifcfe609ce01b174120b81b8c0bf82c4ed6077641
2017-11-30 23:32:50 +00:00
jenkins-bot
b5370206ff Merge "Add action/user tracking to html cache purge jobs" 2017-11-09 22:33:48 +00:00
Brad Jorsch
3488f49532 Replace selectFields() methods with getQueryInfo()
Several classes have a "selectFields()" static method to tell callers
which fields to select from the database. With the recent comment table
change and the upcoming actor table change, this pattern has become too
simplistic as a SELECT will need to join several tables to be able to
retrieve all the needed fields.

Thus, we deprecate the selectFields() methods in favor of getQueryInfo()
methods that return tables and join conditions in addition to the
fields.

Change-Id: Idcfd15568489d9f03a7ba4460e96610d33bc4089
2017-10-30 22:57:33 +00:00
Aaron Schulz
3247bae0e7 Add action/user tracking to html cache purge jobs
Change-Id: Ic7155a7303debfaf26b13cb836497ccbc89ea238
2017-10-30 10:47:30 -07:00
Max Semenik
40a8d35444 Hard deprecate Title::escapeFragmentForURL()
No usages in core and only one outside of core, being
fixed in If1191817ee2db84d8fd3b91aa13e6257faf10a41.

Change-Id: I91ca289e989a4dc32de083b9cc002c9c9d75a3e1
2017-10-17 23:29:15 -07:00
Umherirrender
f739a8f368 Improve some parameter docs
Add missing @return and @param to function docs and fixed some @param

Change-Id: I810727961057cfdcc274428b239af5975c57468d
2017-09-10 20:32:31 +02:00
daniel
fdf83070cd Add Title::isValid method
Make the notion of Title objects representing invalid titles explicit.

Bug: T165149
Change-Id: I89aaabdff9614fe63bd1244784a1d677dbc26f9e
2017-09-08 22:56:42 +00:00
jenkins-bot
ca01c9ff7f Merge "Title: Make getOtherPage() check canHaveTalkPage()" 2017-09-07 09:38:24 +00:00
Kunal Mehta
1f53b6ee6a Title: Make getOtherPage() check canHaveTalkPage()
Practically this doesn't make any difference, but once it's possible for
namespaces to not have talk pages, this function would have returned an
invalid Title.

Bug: T165149
Change-Id: I940433c22193d406d8b4a6cab0e6ad37e88e62c6
2017-09-06 19:52:34 -07:00
Brad Jorsch
11cf01dd9a Add comment table and code to start using it
A subsequent patch will remove the old columns.

Bug: T166732
Change-Id: Ic3a434c061ed6e443ea072bc62dda09acbeeed7f
2017-08-30 15:05:00 +10:00
jenkins-bot
c742fb4bd7 Merge "Add @since tag to Title::canHaveTalkPage()" 2017-08-29 20:14:03 +00:00
Kunal Mehta
844d724621 Avoid using deprecated Title::canTalk()
Change-Id: Ibd224f9de595435524e683262882c9ebf2761abf
2017-08-29 12:36:33 -07:00
Kunal Mehta
dceb5a9836 Add @since tag to Title::canHaveTalkPage()
It was added in f8ac44cca5.

Change-Id: Iee3e074f5108a905b66c52305978c99b2604f2cd
2017-08-29 12:30:13 -07:00
Umherirrender
718e63694d Add missing @param and @return documentation
Change-Id: I1d1098eec3933df6561cceef646576013ddc08c8
2017-08-11 22:17:01 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
addshore
cf91b0a50e Add @since tag for Title::getTalkPageIfDefined
Folow up to: I6d2613d8f7105048022f8093186dc57f1f8173ab

Change-Id: Ie9c478532b40f067f1cc6d6a6c2a3c328984473f
2017-08-04 15:40:24 +01:00
Max Semenik
fd6e9ef2d4 Human-readable section ID support
It adds the ability to replace the current section ID escaping
schema (.C0.DE) with a HTML5-compliant escaping schema that is
displayed as Unicode in many modern browsers.

See the linked bug for discussion of various options that were
considered before the implementation. A few remarks:
* Because Sanitizer::escapeId() is used in a bunch of places without
  escaping, I'm deprecating it without altering its behavior.
* The bug described in comments for Parser::guessLegacySectionNameFromWikiText()
  is still there in some Edge versions that display mojibake.

Bug: T152540
Change-Id: Id304010a0342efbb7ef2d56c5b8b244f2e4fb2c5
2017-08-01 20:32:20 -07:00
daniel
f284dffc21 Introduce Title::getTalkPageIfDefined.
This is part of the effort to remove the assumption that every page
can have a talk page. Before we can merge Icee208dc4 which makes
Title::getTalkPage() throw an exception of no corresponding talk
namespace is defined, all extensions that call getTalkPage() must
be changed to either check canHaveTalkPage() first, or to use
the conveniance function getTalkPageIfDefined() instead.

Bug: T165149
Bug: T172146
Change-Id: I6d2613d8f7105048022f8093186dc57f1f8173ab
2017-08-01 19:09:13 +02:00
jenkins-bot
a840e83089 Merge "Title: Don't create mSubpages member variable" 2017-07-25 15:03:41 +00:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
Kunal Mehta
61d9828a88 Title: Don't create mSubpages member variable
This variable is set and then immediately returned. It's never read
from, so it doesn't make sense as a member variable.

Change-Id: I507895c32b754b8606fb162db321294d31ab6d4e
2017-07-19 18:56:19 -07:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
daniel
f8ac44cca5 Rename canTalk methods
This renames Title::canTalk to Title::canHaveTalkPage
and MWNamespace::canTalk to MWNamespace::hasTalkNamespace.

Bug: T165149
Change-Id: I342a273a497b31282388b13bf76dadfb1122dcbb
2017-06-25 10:15:30 +00:00
daniel
fbc1449653 Make Titles with an unknown namespace ID refer to Special:Badtitle.
Without this patch, Title::getPrefixedText() would return ":Foo"
if the namespace was unknown, potentially creating a misleading
link to the main namespace. With this change, getPrefixedText()
will return something like "Special:Badtitle/NS12345:Foo".

Note that round trip behavior is broken either way.

Bug: T165149
Change-Id: I0d491a2b58ff45f207f83ee62ca6e7e6ffbf790a
2017-06-14 04:31:07 +00:00
Brad Jorsch
6d52171806 Have Title::get(Next|Previous)RevisionID sort by timestamp
Revision IDs are usually increasing as timestamp increases, but not
always. Callers almost certainly want next/previous timestamp when the
two differ.

This also takes care of a minor bug in the nearby getFirstRevision()
where it'll choose an arbitrary tied revision ID if there were multiple
revisions made in the same second.

Bug: T4930
Bug: T163532
Bug: T159319
Change-Id: Iab2060a0ad5e45edbaa0ff36e863cb014b8e876f
2017-05-08 05:33:07 +00:00
Fomafix
5c41b29993 Use isSpecialPage() where possible
Change-Id: Ie4d0838acf96a7ed4a1fe4cfdc901c77d3312174
2017-04-29 22:31:42 +02:00
jenkins-bot
0697e41485 Merge "Move Database and subclasses to Rdbms namespace" 2017-04-12 18:07:43 +00:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00