CommentParser:
* Move comment formatting backend from Linker to a CommentParser service.
Allow link existence and file existence to be batched.
* Rename $local to $samePage since I think that is clearer.
* Rename $title to $selfLinkTarget since it was unclear what the title
was used for.
* Rename the "autocomment" concept to "section link" in public
interfaces, although the old term remains in CSS classes.
* Keep unsafe HTML pass-through in separate "unsafe" methods, for easier
static analysis and code review.
CommentFormatter:
* Add CommentFormatter and RowCommentFormatter services as a usable
frontend for comment batches, and to replace the Linker static methods.
* Provide fluent and parametric interfaces.
Linker:
* Remove Linker::makeCommentLink() without deprecation -- nothing calls
it and it is obviously an internal helper.
* Soft-deprecate Linker methods formatComment(), formatLinksInComment(),
commentBlock() and revComment().
Caller migration:
* CommentFormatter single: Linker, RollbackAction, ApiComparePages,
ApiParse
* CommentFormatter parametric batch: ImageHistoryPseudoPager
* CommentFormatter fluent batch: ApiQueryFilearchive
* RowCommentFormatter sequential: History feed, BlocklistPager,
ProtectedPagesPager, ApiQueryProtectedTitles
* RowCommentFormatter with index: ChangesFeed, ChangesList,
ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryRecentChanges
* RevisionCommentBatch: HistoryPager, ContribsPager
Bug: T285917
Change-Id: Ia3fd50a4a13138ba5003d884962da24746d562d0
Follows-up Ieaf04e0c289646dd5 which changed internal references to
bool(true) for 'debug' to the integer DEBUG_ constants, and introduced
a new debug=2 parameter.
In the refactor, I missed the setDebug() calls for
DerivativeResourceLoaderContext, which were still passing a boolean,
but more importantly were effectively passing debug=1 even if the
pageview carried debug=2. This isn't a problem yet in production since
debug=2 is currently identical in behaviour to debug=1.
The impact of this issue is mainly noticed through secondary CSS
requests. The URLs for primary stylesheets, and JS modules was already
forwarding the current "debug" version.
Test Plan:
* Open Main_Page?action=edit&debug=2
* Before this patch, e.g. on mediawiki.org today, secondary
stylesheet requests (part of a JS module) have debug=1.
For example "modules=jquery.makeCollapsible.styles&only=styles".
* After this, everything has debug=2 when the page view has debug=2.
Bug: T85805
Change-Id: Ia8fba4e30397bc5890033f13417b6739b0f83c38
PHPUnit 8.5.21 no longer converts deprecations to exceptions by default.
However, we rely on such conversions in our tests, otherwise there are
failures:
Failed asserting that exception of type "PHPUnit\Framework\Error\Deprecated" is thrown.
The upstream change is:
fac02620f6
Bug: T291731
Co-Authored-byː Antoine Musso <hashar@free.fr>
Change-Id: Ifacf26905a7fa24ea3aafad79e012ddfb0a797bb
$wgShellLocale was a flawed solution to the problem of locale
dependence. MediaWiki has its own concept of locale (the Language
hierarchy) and any kind of dependence on the server's libc locale is
incorrect and harmful, leading to bugs. Developers have an expectation
that functions like strtolower() will work in a certain way, and
respecting the locale set in the environment at install time violates
this expectation.
The problems with using C as a locale, which led to $wgShellLocale, are:
* escapeshellarg() will strip non-ASCII characters. This can be worked
around by not using it. The security vulnerability it was trying to
fix can be prevented in another way.
* Shell commands like rsvg will fail to correctly interpret UTF-8
arguments. This is the reason for the putenv(). On Linux, this can
be fixed by using C.UTF-8, which we didn't know at the time. On
Windows, the problem is not relevant (there are unrelated issues
with UTF-8 arguments).
Bug: T291234
Change-Id: Ib5ac0e7bc720dcc094303a358ee1c7bbdcfc6447
New option 'absoluteURLs' was added to getText method
of the ParserOutput object that replaces all links
in the page HTML with absolute URLs.
Removing the action=render special case from Title
seems safe cause we will end up replacing the result
with absolute URL if we're in a render action no matter
where Title::getLocalUrl was called from.
This change is safely revertable from the perspective
of ParserCache.
Bug: T263581
Change-Id: Id660e1026192f40181587199d3418568f0fdb6d3
Some methods in the PageUpdater's class implements the fluent interface
design pattern. Use the fluent interface where need be.
Change-Id: If76a4b8c5070c20ed40038a4ee78e2d677de5180
For both LinkTarget and PageReference, just extract
namespace and dbkey and pass those in the array
of parameters to Job::__construct().
Allows a bunch of simplification to WatchedItemStore.
Bug: T291531
Change-Id: Id150d0c62af38d4b3d17e5698866127c6e04717e
This is just moving code verbatim, removing now-unneeded stuff, and
duplicating tests as well.
Bug: T290021
Change-Id: I540ddaaa11dfabcf0b87b608b151b5e34d199fd8
On mobile and possibly desktop via (`$wgFooterIcons`), trying to acccess
the copyright icon returns an array instead of a string. An exception is thrown
since the indexing is done on a string.
Throwing an error: TypeError: Return value of BaseTemplate::getCopyrightIconHTML()
must be of the type string, array returned.
The returned array looks like this (when I test):
["copyright"]=> array(1) {
["copyright"]=> array(3) {
["url"]=> string(47) "https://creativecommons.org/licenses/by-sa/4.0/"
["src"]=> string(44) "/core/resources/assets/licenses/cc-by-sa.png"
["alt"]=> string(39) "Creative Commons Attribution-ShareAlike"
}
}
So getting the icon, we need to index src, hence the patch. Let me know
if I'm wrong here. Also, have a look [[Manual:$wgFooterIcons]], you'll see that
default value is an empty array instead of a string:
$wgFooterIcons = [
"copyright" => [
"copyright" => [],
],
]
This made MF to not be able to load locally and the patch fixes it.
In addition, we can just pass `$config` as we have above rather than request
the for it again and again.
Bug: T291325
Change-Id: Icb42342e83f2bc61922ab991bcec66aa5e7b5646
ContentHandler::getContentText() is deprecated and should be
replaced with Content::getText() for TextContent instances.
Change-Id: I556d3d3f64fafd1d54c4a0c5021efaff2d9c3ce8
NOTE: some test cases where removed as they're exactly doing the
same thing as the ones above.
Bug: T291268
Change-Id: I8fa8bafc892dbc84f2aab2549d453d6f39835d33
In order for us to keep backward compatibility, cast the page identity
back to a Title in: `buildTextboxAttribs()` and use within the code.
Change-Id: Ia55251ee7f730636d6e85bf069734ff462119f0d
Since $wgSkipSkins is meant to only 'remove skin from preferences',
it should not affect parsing with them.
So these skins need to be allowed here.
To achive this, this patch adds getInstalledSkins() method to SkinFactory
to provide the complete. The method supersedes getSkinNames() which does
the same thing but with ambiguous name.
Description of getAllowedSkins() has been corrected as it was slightly incorrect.
Bug: T237856
Change-Id: I0889b823d27f1a2830cc0205f5a21ed4de744e08
This is done without a deprecation process since the function is
@internal and completely unused outside of core.
Bug: T291341
Change-Id: I4b074f83f9be67b5b5bc2d33b2a6a55bb109a2b3
This patch adds a service as a replacement for MWGrants. This is done
as it allows proper dependency injection of used services and
configuration settings.
This was previously committed as Iac52dba15f and reverted because it
introduced recursive service instantiation.
To avoid this recursive service instantiantion all UI related methods
get moved to a new GrantsLocalization service, instead of the GrantsInfo
service.
Bug: T253077
Change-Id: Ib900bc424fc272ec709d272dcaff71398fa856f8
Nothing in the code expects things to be on the left/right, it was just
a naming convention. However, it caused some issues because CSSJanus
flips the attributes in the stylesheet for RTL languages.
So just use more descriptive names that also avoid issues with RTL
languages.
Bug: T290731
Change-Id: I8a383cd1e3981dc8a826ff60eee523d9f71d1d3d
```
function check($txt) {
echo sprintf("er=%+5s, ini=%+5s # $txt\n",
error_reporting(), intval( ini_get( 'error_reporting' ) )
);
}
function turningItOffAndOnAgain() { // have you tried...
check('... enter');
$old = error_reporting(42);
check('... off');
error_reporting($old);
check('... on');
}
error_reporting(2);
check('start'); # er=2, ini=2
turningItOffAndOnAgain();
check('toggled'); # er=2, ini=2
@turningItOffAndOnAgain();
check('silence-toggled'); # er=2, ini=0
```
PHP correctly reflects the silenced state during the silenced state,
the same as our AtEase library.
PHP also correctly ignores changse to error_reporting while being
silenced. That is, it always restores it back to how it was regardless
of what a confused nested function may have done.
Where it fails is that it doesn't seem to sync the INI setting, which
caused this PHPUnit check to cause test failures.
While this an upstream bug, it was also a mistake on my part to
write the PHPUnit check based on the ini_get value. That's not the
idiomatic way to check the current state and apart from these two
lines of code, it seems nothing in any of our Codesearch-indexed
code bases, including third party, do this.
Bug: T291278
Change-Id: Ic3e66cb2e5b2b44b9997d323abbc87b7f8fe3c41