Commit graph

304 commits

Author SHA1 Message Date
jdlrobson
8a39fef52f Wrap the "bytes changed" indication on Special:Contributions with CSS
Rather than use actual text, move the parentheses that serve as
presentation into the CSS.

Bug: T205581
Change-Id: I4ae645ca0edf0001a20c228f90f8d43a10cfff71
2018-11-16 00:30:44 +00:00
Fomafix
43244db9a2 Use PHP 7 '??' operator instead of if-then-else
Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
2018-10-21 21:46:46 +02:00
Brad Jorsch
993baa3493 ActorMigration: Remove possibility of read-both
When this was originally written, the plan was to read both the old and
new fields during the transition period, while stopping writes to them
midway through. It turns out that the WHERE conditions to do read-both
correctly are generally not handled well by the database and working
around that would require a lot of complicated code (see what's being
removed from ApiQueryUserContribs here, for example).

We can simplify things greatly by instead having it write both fields
during the transition period, reading from the old for the first part
and the new for the second part, as is being done for MCR.

Bug: T204669
Change-Id: I4764c1c7883dc1003cb12729455c8107319f70b1
Depends-On: I845f6ae462f2539ebd35cbb5f2ca8b5714e2c1fb
Depends-On: I88b31b977543fdbdf69f8c1158e77e448df94e11
2018-10-11 12:12:00 +11:00
Max Semenik
40e217a428 Don't use deprecated function wfArrayFilterByKey()
Change-Id: Ifdc67f8b9b8617e6398aa0d2b6ff4bec1e7507ce
2018-09-28 17:24:13 -07:00
James D. Forrester
b5ce7632c7 hooks: Drop Special{Watchlist|RecentChanges}Filters, deprecated in 1.23
Neither SpecialWatchlistFilters nor SpecialRecentChangesFilters are used in any
code known to Wikimedia code search. The related code to use these hooks was
only ever used within the MediaWiki repo.

Change-Id: Ib631d49d7b5835c665171dbad3e8a646b80827ef
2018-09-12 12:43:01 -07:00
Aryeh Gregor
e68fdb4065 Mass conversion to SpecialPageFactory service
Change-Id: Ia6e1e819ec6cbe8bf75b820109f51d47863e31fc
2018-08-17 12:03:12 -07:00
jenkins-bot
7cd7c534f7 Merge "ChangesList: HTML escape the timestamp" 2018-08-02 10:22:22 +00:00
Brian Wolff
01748b1cc1 ChangesList: HTML escape the timestamp
Bug: T197002
Change-Id: Ib695674b9dc28a2f864f330e578cee6a1a7a4219
2018-08-02 09:47:49 +00:00
Max Semenik
9b0c621d7f Deprecate wfArrayFilter() and wfArrayFilterByKey()
Now that all our supported PHP versions have array_filter()
with a third parameter, these functions aren't needed anymore.

Depends-On: I3b097a1a048baabcaca15dc214a3a1bb06e746cc
Depends-On: I0187e27ac47cbab099249572201d1a649226a734
Change-Id: I7cabd0252691a083cb749cf9d3a7a23f1d076c39
2018-07-19 08:40:46 +02:00
Aaron Schulz
6986130f33 Convert ChangesList to using MapCacheLRU
Change-Id: I1cafb601dc644ca6d58ec0430e9608cfb497bcd8
2018-07-14 01:34:58 +00:00
Brian Wolff
89b21847e1 Start working on phan-taint-check warnings. Fix minor escaping issues.
This fixes 26 of the phan-taint-check warnings on MW core. Some
are outright fixed, others are false positives that were suppressed.

This really only covers some of the easy ones. There are still
314 warnings to go.

Change-Id: I30463bc3a09fd4324d190de8533f51784764dd3a
2018-07-12 03:26:59 +00:00
Timo Tijhof
645207653b Replace redundant Assert calls with native typehint
* PageUpdater: Plain class type hints never needed Assert,
  not sure why that was here.

* CategoryMembershipChange: The 'callable' typehint was introduced
  in PHP 5.4.

Change-Id: I958bd63a7f9edec3a297f34fe43339fac5f43006
2018-07-10 19:31:13 +00:00
jenkins-bot
55aab97bb4 Merge "Ensure whether user can rollback page in ChangesList" 2018-07-09 22:34:40 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Roan Kattouw
39163edd17 RCFilters: Move aggregation of highlight classes to the backend
Construction of the highlight containers was moved to the backend, but
setupHighlightContainers() also aggregates the CSS classes used for
highlights for grouped entries in enhanced mode.

Move that to the backend too, and get rid of setupHighlightContainers().

Also move the namespace classes to getHTMLClassesForFilters() so that
they get picked up too, and pick up classes for tags separately because
the way they're handled is weird.

Bug: T197168
Change-Id: I4c374f82e7d128025f4e2b2f39b0adba14b76ef3
2018-06-26 17:55:50 -07:00
Moriel Schottlender
b44400dad8 Move construction of highlight divs to backend
Create the highlight container div in the backend for
both regular and enhanced result view, so we spare
the load in the frontend.

Bug: T197168
Change-Id: I36bd7b7c4c124d305ac7b07e824dc2a58e152be4
2018-06-26 17:19:47 -07:00
Fomafix
125cbd8c01 Use \u{00A0} instead of   or  
Directly use the UTF-8 encoding of the 'NO-BREAK SPACE' (U+00A0) instead of
the HTML/XML entities   or   or  .

With the UTF-8 character the generated HTML is shorter and better to read.

Also change the special value for the label in HTMLForm from   to
U+00A0 but also support   for backward compability.

Bug: T154300
Change-Id: I882599ac1120789bb4e524c4394870680caca4f4
2018-06-24 01:20:13 +00:00
daniel
e8632ab0f6 [MCR] Factor PageUpdater out of WikiPage
This introduces PageUpdater to replace WikiPage::doEditContent,
and DerivedPageDataUpdater, to replace WikiPage::doEditUpdates
and WikiPage::prepareContentForEdit.

See docs/pageupdater.txt for a description of their
functionality.

MCR migration notes:

* The interface of PageUpdater is expected to
remain mostly stable after this patch. Code that has been using
WikiPage::doEditContent can be confidently migrated to using the
new mechanism for revision creation.

* This patch keeps the code inside PageUpdater largely aligned
with the old code in WikiPage, to make review easier to to avoid
mistakes. It is intended to be refactored further, moving
application logic into stateless services.

* DerivedPageDataUpdate is intended as a stepping stone for further
refactoring. Its behavior is designed to be compatible with
callback code that currently relies on
WikiPage::prepareContentForEdit. Much of the code that currently
lives in DerivedPageDataUpdate should be factored out into
services, all behavior relevant to calling code should be exposed
via narrow interfaces.

Bug: T174038
Bug: T196653
Change-Id: If610c68f4912e89af616cdcac1d35a1be3946afa
2018-06-14 13:22:13 +00:00
Fomafix
0f1858321c Use PHP 7 '??' operator instead of if-then-else
Change-Id: I790b86e2e9e3e41386144637659516a4bfca1cfe
2018-06-12 23:14:18 +02:00
Max Semenik
8085c58a4b Replace call_user_func_array(), part 1
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

Change-Id: Idcec077ef3fdf029b632cceafd0150851ad723e3
2018-06-04 23:39:04 -07: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
Amir Sarabadani
ac5166d343 Make RCCacheEntry use the local part of the user name for linking
Bug: T190530
Change-Id: Ib9e555c65fbe9befdb8413e6fbc3b3a53614bad8
2018-05-22 22:27:18 +00:00
Aaron Schulz
b6cd5421b9 rdbms: rename onTransactionIdle() to onTransactionCommitOrIdle()
This is clearer and is consistent with onTransactionPreCommitOrIdle()

Change-Id: I3a34a0e9adea69ec55ed6ddfef47703e31e7c3b5
2018-05-09 21:07:06 +00:00
jenkins-bot
c2f9376c19 Merge "RecentChange: Use constants for the $noudp parameter of save()" 2018-04-30 19:47:24 +00:00
Timo Tijhof
eca112b4e0 RecentChange: Use constants for the $noudp parameter of save()
It is a boolean parameter that is confusing for three reasons:

* It's a boolean parameter, given parameters are unnamed in PHP,
  these are always poor UX for call sites.

* It's negated ("noudp"). save(true) means no feeds events,
  save(false) [default] means sending events to feeds.

* To overcome this problem, typical use was to pass a free-form
  string that self-documents the intended behaviour,
  e.g. `save('pleasenoudp')`, any string casts to true.

Fix this by moving the booleans to constants and use those
instead. For compatiblity, keep the negation internally,
although it's hidden from regular usage. Also document
the string hack, deprecate it, and update callers.

Change-Id: Ia57c86b38bf50cb4ec580f42a6b1ca798fcf781a
2018-04-27 22:23:52 +00:00
Roan Kattouw
f841e886b6 Use PRC_AUTOPATROLLED for log entries and category entries
These actions mark edits as patrolled automatically, so the
correct rc_patrolled value to use is PRC_AUTOPATROLLED rather than
PRC_PATROLLED. The code for log entries checks the autopatrol right, and
the code for category entries has a comment that says "just like log
entries".

Bug: T190408
Bug: T184791
Change-Id: Id994af8cd3833a862a09389431256aba35c2e6d9
2018-04-26 11:21:48 -07:00
Amir Sarabadani
922be51066 Remove the feature switch for disabling autopatrol logging
Per the RFC, it will now become the default and only behaviour
to not log autpatrol actions. The information is already
recorded via the rc_patrolled field.

Bug: T184485
Change-Id: I98ae895a2b4cde4bb945f1df23be4a070b0bf9c4
2018-04-13 20:52:53 +00:00
Amir Sarabadani
00a4f0939c Replace rc_patrolled values with contants, part I
This constants has been recently introduced and it's good to use them

Change-Id: I8ce56dc95de3e49610dca71c00965ca1ac74bcf0
2018-04-11 22:35:31 +02:00
Amir Sarabadani
728321e113 Make autopatrol third option in rc_patrolled and use it in API
Bug: T184791
Change-Id: If64ba8b845b122a87f20646dddf72ef257b793cb
2018-04-03 18:44:37 +02:00
Matěj Suchánek
85b8aed11b Ensure whether user can rollback page in ChangesList
This is already done in Special:Contributions.

Bug: T50731
Change-Id: I2a608f32c90ff0c06c92937b5edf0ee000ca8aba
2018-03-22 21:09:05 +01: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
jenkins-bot
6f7e982df6 Merge "Only try to show character difference if it isn't empty" 2018-02-14 17:31:33 +00:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +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
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Timo Tijhof
bee9f4db96 Remove various redundant '@license' tags in file headers
Redundant given this is the project-wide license already,
especially in file headers that already include the GPL license
header.

This and other minor fixups based on feedback from Ie0cea0ef5027c7e5.

* Add @file where missing.
* Move @ingroup and @deprecated from file to class doc where needed.

Change-Id: I7067abb7abee1f0c238cb2536e16192e946d8daa
2018-01-12 18:15:11 +00:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
mainframe98
70e92cdad5 Fix additional usage of incorrect case
Courtesy of the PhpStorm inspection Case mismatch in method call or
class usage.

Bug: T166759
Change-Id: I27c53658b99048fa0dd8f9d6ef1398620386e1cc
2017-12-15 11:58:11 +01:00
Aaron Schulz
c8d82c02c3 Use WANObjectCache::makeKey() in ChangesFeed
Change-Id: Ia029873e5d0883d177007555ad494cae9e00c407
2017-11-27 12:03:47 -08:00
Aaron Schulz
bb462e5193 Fix some broke cache key generations
Change-Id: Ib724fe0cfa866351caee89d3451b6c4b7b6a4578
2017-11-19 21:30:45 -08:00
Max Semenik
72b15b96e7 Fix function annotiation
Change-Id: I4dfc62c8ef2226b46aa1eed508816377f6599ab2
2017-11-04 00:35:39 -07:00
Brad Jorsch
c2f432625f Add deprecation notices for selectFields() methods deprecated in Idcfd1556
Now that WMF-deployed extensions have been updated to no longer call
them.

Change-Id: I04942ca1b95baa2126f2dcf4d0975536f4dd07c7
Depends-On: I300130c7b952a353ac28989d39d7f01366da2a37
Depends-On: Ia81bf6a655af800ce8ac19940d851e65746e1f77
Depends-On: I0d869aacaaad85cdd34361a611ac8348bdbb757d
Depends-On: I7b05a99e23da296a673eb0bd34f18344618c8be3
Depends-On: I42237e8e29497bbc56606f6ad01de3d525bf8b2a
Depends-On: If75d2e76c2f166bc40a544dd502da43171ce1e7b
Depends-On: I401809d2638b11e6c77a318fc8fbbc41fa639083
Depends-On: I5d62ad76fdb64a9c6efd228f27e9b5f512f17d5e
Depends-On: I488afaa991e3d26b638a4f588f70db455959eadf
Depends-On: Ibe82dadb0f2d1c5dbc38b96731c6e443c5469ff0
Depends-On: Id25b86dd415e2e3c6190a91faee2a3b815e50f61
2017-11-01 14:50:56 +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
Stephane Bisson
b31c87ab91 RCFilters: define consistent interface in ChangesListFilterGroup
Get rid of isPerGroupRequestParameter and define a consistent
interface that all filter groups can implement.

Change-Id: Ib904bcdc697c65722a0041ac611d1e00c577389f
2017-10-18 12:44:51 -07:00
Stephane Bisson
4b82dc1bee RCFilters: Don't let new params filter out old page
Bug: T177884
Change-Id: Id0ace30b837cf6c5fa7159aa40d80392187c4e16
2017-10-16 15:56:37 -04:00
jenkins-bot
7d8766e80e Merge "RCFilters: Allows specifying default highlights from the server" 2017-10-04 20:58:42 +00:00
Stephane Bisson
8937a72df7 RCFilters: Allows specifying default highlights from the server
Bug: T172757
Change-Id: I0545b4e0222e14be99d567e7890ccf33722a5d1e
2017-10-04 13:51:23 -07:00
Stephane Bisson
dbc83d9c43 RCFilters: Avoid adding raw filter and group objects to js vars
Bug: T176236
Change-Id: I0c68ea0e090cfb065d2e3e8acad7025c61c344ca
2017-10-04 11:08:51 -04:00
Moriel Schottlender
a8497a3dd0 RCFilters: Output namespace class on log actions as well
Bug: T174732
Change-Id: Icaf7117d9566bb2bb31c69cf86078491d6c217cc
2017-09-13 17:18:11 -07:00