We don't want to depend on the entire site configuration when we only
need a few specific settings.
This change additionally means that these services no longer see a live
version of the settings, but rather a copy. This means in tests you
really do have to call overrideMwServices() if you want services to pick
up your config changes.
ResourceLoader and SearchEngineConfig will need more work to port,
because they expose their member Config in a getter, and the getter is
actually used.
Parser and NamespaceInfo are also relatively complicated, so I split
them into separate patches.
Tested with 100% code coverage. \o/
Depends-On: If6534b18f6657ec1aba7327463f2661037f995b3
Change-Id: I1a3f358e8659b49de4502dc8216ecb6f35f4e02a
Specifically in registerFiltersFromDefinitions(), phan was unable to
tell that $groupDefinition['class'] was a string. I think it assumed it
was an integer because the earlier $groupDefinition['priority'] was an
integer.
Use phan's more advanced type documentation system to instruct it that
$className will be a string.
Change-Id: I09f41366b713d6159b57e798cfd1720f42ba30ef
* Title: phan false positive
* McrUndoAction: fixed improper use of @param
* UploadSourceAdapter: fixed wrong type
* XmlTypeCheck: Use null so phan doesn't think we're trying to call the
function ''
* Database: phan false positive
* SpecialBlock: Use phan's advanced type documentation so phan knows
specifically what's being returned
* ChangesListSpecialPage: phan false positive
* BatchRowUpdate: Have default callback take a parameter so phan doesn't
think too many arguments are being passed
* MimeAnalyzer: left FIXME for relying on PHP 7.1 unpack() signature
* LanguageConverter: Specify types for $mTables since phan couldn't
determine it automatically
* preprocessorFuzzTest: Implement User::load() method signature
Change-Id: I08080ab636c5fe67ea6a4e14b2212d7523606e21
The parameter passed to the execute() method of each special page can
be null, and usually is. In some of these files this fact was already
mentioned in the comment, but not listed as a type.
In this patch I also remove comments that do not explain much. Saying
that the execute() method of a special page "executes a special page" or
is the "main entry point to a special page" is not super helpful. That's
usually what the documentation in the parent class shoudl explain.
We can add @inheritDoc tags in all these cases if you prefer. Please
tell me.
Change-Id: I1d811ab0c6d5c956e36f6a74120a425abc4332e6
The styles that we are applying on changelist pages should also
apply on diff pages. This generalises the rules into a new
module.
To avoid problems with cached HTML mediawiki.special.changeslist
temporarily loads resources/src/mediawiki.interface.helpers.styles.
This will be removed after the change has been in production for a
week.
Bug: T212613
Change-Id: I6aad563e48f41c783df8b176a4f437e60a1255cc
This reverts commit bf4f9d0313.
Reason for revert: causes issues with OAuth extension
The OAuth extension uses a hook to override certain tag messages, and
that hook uses RequestContext::getMain()->msg(), which tries to load
the current user. That's not allowed in load.php requests, so we get a
"Sessions are disabled for this entry point" error.
Change-Id: If58b7edfca116cd7a11f38556f74bed82609d96a
Right now there are only a few settings that don't depend on the request
context, but we can at least export those. The tag data in
particular can get pretty big.
Downgrade the type hint for ChangeTags::tagDescription() and
tagLongDescriptionMessage() from IContextSource to MessageLocalizer, so
we can pass a ResourceLoaderContext to these functions. (Since
IContextSource extends MessageLocalizer, this won't break any callers.)
truncateTagDescription() can't be downgraded to MessageLocalizer because
it needs a Language object, so hack up a fake RequestContext when
calling it. It would be nice if this weren't necessary; perhaps we can
move getLanguage() from IContextSource up into MessageLocalizer?
Bug: T201574
Change-Id: I9b66e35de826a07aa9551ba285e64e4852293229
The maximum value for the rclimit and wllimit preferences is 1000, so
make the maximum value for the ?limit= query parameter also 1000.
Bug: T206233
Change-Id: I244ab2896875391f9676c8127033a0b76568157f
Should be "string" not "String" and "array" not "Array" in
@param, @return and @var use cases. Also, minor typo fixes.
Change-Id: I9d5ebc5b741c6560907b95f7c0c4039da2861f4a
This change ensures that the output is tidy, and is necessary to support
future parsers which will not be able to produce untidy output.
Bug: T198214
Change-Id: I743f4185a03403f8d9b9db010ff1ee4e9342e062
wgStructuredChangeFiltersShowPreference, wgStructuredChangeFiltersShowWatchlistPreference,
and wgStructuredChangeFiltersOnWatchlist were introduced for progressive rollout
of the RCFilters app on RC and WL.
These variables and their related conditional code is no longer needed.
Bug: T196033
Change-Id: Id3799fefd21cd9bea0e089a5e12576ee9ea1085e
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
We used to generate an inline script tag with an mw.messages.set(...)
call to export these i18n messages, but there are no guarantees that
this script tag will run before mw.rcfilters.init does and tries to
access these messages. This race condition doesn't seem to be happening
in practice right now, but dec800968e makes it more probable.
Instead, export the messages object as a config var in mw.config, and
import it into mw.messages at the start of mw.rcfilters.init. This just
moves the blob from one inline script tag to another, but mw.config is
guaranteed to be populated before any modules execute.
Longer term, we should move these messages, as well as the filter
definitions, to a ResourceLoader module rather than embedding them in
every page view. I filed T201574 for that.
Bug: T192623
Change-Id: I2d58f55701b28876a6491432cee0fc56f97ff00b
When collapsed, make sure we are adjusting the 'min-height' on the
'rcfilters-head' div so that it actually takes the space it should.
Make sure the preference of whether the area is collapsed or not is
preserved for the user, per RC or WL pages, and that it is loaded
properly with the correct minimum height dimensions depending on
which state is in the preferences, so to prevent "jump" of the
result list after load.
Bug: T177206
Change-Id: I82c3042cd1bb85dedcd6b5458b157fed94def808
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.
In one occurrence, a simple conditional instead of trickery was much more readable.
This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.
Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
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
`$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
The primary goal here is a defense in depth measure to
stop an attacker who found a bug in the parser allowing
them to insert malicious attributes.
This wouldn't stop someone who could insert a full
script tag (since at current it can't distinguish between
malicious and legit user js). It also would not prevent
DOM-based or reflected XSS for anons, as the nonce value
is guessable for anons when receiving a response cached
by varnish. However, the limited protection of just stopping
stored XSS where the attacker only has control of attributes,
is still a big win in my opinion. (But it wouldn't prevent
someone who has that type of xss from abusing things like
data-ooui attribute).
This will likely break many gadgets. Its expected that any
sort of rollout on Wikimedia will be done very slowly, with
lots of testing and the report-only option to begin with.
This is behind feature flags that are off by default, so
merging this patch should not cause any change in default
behaviour.
This may break some extensions (The most obvious one
is charinsert (See fe648d41005), but will probably need
some testing in report-only mode to see if anything else breaks)
This uses the unsafe-eval option of CSP, in order to
support RL's local storage thingy. For better security,
we may want to remove some of the sillier uses of eval
(e.g. jquery.ui.datepicker.js).
For more info, see spec: https://www.w3.org/TR/CSP2/
Additionally see:
https://www.mediawiki.org/wiki/Requests_for_comment/Content-Security-Policy
Bug: T135963
Change-Id: I80f6f469ba4c0b608385483457df96ccb7429ae5
Unpatrolled, manual and auto.
This moves the old hidepatrolled/hideunpatrolled filters to a legacy
group, and adds a new string options group with three options.
Also adds code mapping the old parameters to the new ones, and handling
for the hidepatrolled preference.
Bug: T190408
Change-Id: Ic1f181d3704c1d998696617a0d10270a87f22a62
Otherwise these tests break completely when you add conditions like
$conds['rc_patrolled'] = [ 1, 2 ];
That maps to 'rc_patrolled IN (1,2)', but the DIY code in
normalizeCondition() was too simplistic to generate that.
Change-Id: I449317185f98e20b3e17f1b13610d872ae828171
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
* always hide the big red .errorbox when rcfilters
is enabled
* always identify the changes-list section with
.mw-changeslist or .mw-changeslist-empty
* conditionally add .mw-changeslist-empty-<reason>
to the changeslist section when the reason for it
being empty is known
* handle RCL being empty because the specified title
is invalid or inter-wiki
Bug: T184952
Change-Id: I5dd974f5f769503e89301dd22bdfd3d49b0dd11f
Introduce truncateInternal() method in Language class, based on
existing truncate() method. New method abstracts string truncation,
allowing users to specify callable functions for text length measurement
and string truncation.
New method, truncateInternal(), is used to provide two options for
text truncation:
* For DB usage: truncateForDatabase() method is truncating text by
number of bytes.
* For UI usage: truncateForVisual() method is truncating text by number
of characters, using multibyte string PHP methods.
Old truncate() method is deprecated and just returns the results of
truncateForDatabase() method.
Newly introduced truncateForVisual() method is used for
truncation of long tag descriptions in RCFilters menu.
Bug: T179626
Change-Id: Ib01a8c303304064dde3ce983b817d93a88a5affd
Since Ifecaaff572, legend was using position: absolute when results are
grouped by page. Most users found such behavior annoying and unexpected,
so positioning is being reverted to previous state.
Only change besides reverting is preventing collapsed legend to push
away the surrounding results. Without that, we would have scenarios
where legend is expanded and collapsed, but results are pushed away as
if legend is still expanded.
Bug: T182156
Bug: T184165
Change-Id: I5adb7e1cb793ec30fba9d5d9674a7fa294d9a3a5
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
When the 'title' hidden field contains the subpage, the 'target'
input field is never taken into account since the subpage always
takes precedence in ChangesListSpecialPage->setup()
I75cfb2b56a4da6357e6117b3f34f3178bfb2c90c introduced
SpecialRecentChangesLinked->getPageTitle which overrides
SpecialPage->getPageTitle to include the subpage by default.
This helped with redirecting to the right page when parsing
a saved query on the server but changed the behavior everywhere
that function was used in the context of RCL. That includes
SpecialRecentChanges.php:545 where the option form is built.
Bug: T183437
Change-Id: Id39d1887719ecb6900b25fefbb133dff9c4d0456
If user enables "Live updates" on one tab/browser and logs out from
different tab/browser, reload the page.
Bug: T177717
Change-Id: Ifeeb7d50eaec8f733a94a36711f1c4541af1cef9
Side-effect of Ib933de3a3f9e876924386e80f315506f60f8af54
ChangesListSpecialPage#isStructuredFilterUiEnabled needs
to call static::checkStructuredFilterUiEnabled() to reach
the implementation from SpecialWatchlist.
Bug: T182318
Change-Id: I1e90d7e29f9e7fc5acece6466ed818210058dd2c
- When results are grouped by page, on pages where new RC filters
are enabled, apply position: absolute to legend, to avoid top
result entries being pushed too much.
Bug: T174728
Change-Id: Ifecaaff5727905b3c4e860555ba094f71aac6f80