Commit graph

11543 commits

Author SHA1 Message Date
Tim Starling
f7f84dddb3 Introduce CommentFormatter
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
2021-09-28 11:13:03 -07:00
jenkins-bot
3801581dae Merge "resourceloader: Preserve new 'debug' param in getScriptURLsForDebug()" 2021-09-28 15:27:27 +00:00
vladshapik
12b42e8023 Hard deprecate User::blockedby(), User::getblockid()
Bug: T290869
Change-Id: If2d96705223bd80ffd68526773a2c81aaeaa898d
2021-09-28 12:50:29 +00:00
jenkins-bot
39c546d706 Merge "Change 'fromdbmaster' to WikiPage::READ_LATEST" 2021-09-27 22:44:26 +00:00
jenkins-bot
7833853b49 Merge "Remove the deprecated IP class" 2021-09-27 22:37:13 +00:00
Samuel Guebo
a8db81dc71 Add script to delete a user email's address
Can be used for a variety of operations
including preservation of users privacy.

Bug: T290099
Change-Id: Iad75810310c95e96b5f8998b201ed04ace5af656
2021-09-27 18:02:11 +00:00
jenkins-bot
eaf10f600b Merge "Expand local URLs to absolute URLs in ParserOutput" 2021-09-27 14:48:02 +00:00
jenkins-bot
07f3f8053b Merge "UndeletePage cleanup, part 1" 2021-09-27 14:24:53 +00:00
jenkins-bot
5c570f46da Merge "Move code from PageArchive to a new UndeletePage command" 2021-09-27 14:22:05 +00:00
jenkins-bot
6b6042b0b8 Merge "Hard deprecate User::setOption()" 2021-09-26 21:56:54 +00:00
Umherirrender
0e4bb6d611 Change 'fromdbmaster' to WikiPage::READ_LATEST
Constants are harder to misspell

Change-Id: Ie1afcc8580cccf815df1cc97f05a5be81676d9f7
2021-09-26 19:27:33 +00:00
jenkins-bot
86fa9b40a5 Merge "Inject UserIdentityLookup into SpecialLog" 2021-09-26 19:22:47 +00:00
Alexander Vorwerk
04dfdc3653 Hard deprecate User::setOption()
deprecated since 1.35

Bug: T277818
Change-Id: Ic251d624e5d6fa857aa92f9c5dd3df44714ac610
2021-09-26 17:18:54 +02:00
Alexander Vorwerk
4cf2895914 Remove the deprecated IP class
Bug: T291008
Change-Id: I83a0ad6543384be71fa8d057932f8331cc0fdc4f
2021-09-26 13:58:28 +02:00
jenkins-bot
d18082bfd6 Merge "GlobalFunctions: Test clean up for wfExpandUrl()" 2021-09-25 20:54:03 +00:00
Timo Tijhof
3cfd632b9a GlobalFunctions: Test clean up for wfExpandUrl()
Prep for a larger change to keep review small and simple.

Change-Id: I31f1403ab40c79ab270c4170d2afd6e885a2caac
2021-09-25 20:06:57 +00:00
Timo Tijhof
6d14529c69 resourceloader: Preserve new 'debug' param in getScriptURLsForDebug()
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
2021-09-25 20:06:42 +00:00
Alexander Vorwerk
fd094c5bb7 Inject UserIdentityLookup into SpecialLog
Change-Id: Ifc17a7ef38da60ec1534b39df1657f2394cbcb59
2021-09-25 18:36:37 +02:00
DannyS712
b42e1abfb9 PHPUnit: enable convertDeprecationsToExceptions
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
2021-09-25 10:05:18 +00:00
jenkins-bot
ca9e9c0dc6 Merge "Remove $wgShellLocale, always use C" 2021-09-25 00:48:14 +00:00
Tim Starling
65b1b6b56a Remove $wgShellLocale, always use C
$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
2021-09-24 17:25:01 -07:00
Timo Tijhof
fc5403e6a8 resourceloader: Add test for getVersionHash() in debug mode
Folllows-up I0e63eef4f85b13.

Bug: T235672
Change-Id: I012ea8b1a40646ce7522c26d11139eddaa2067d1
2021-09-25 00:08:51 +01:00
jenkins-bot
62d9c60273 Merge "Detect and monitor against multiple Parser invocation during edit requests" 2021-09-23 22:01:43 +00:00
Cindy Cicalese
eed48e402b Detect and monitor against multiple Parser invocation during edit requests
Bug: T288707
Change-Id: I0cca8f9bcf1d6e964b8b06c0c4490e83f4fb1de5
2021-09-23 16:12:40 -05:00
Petr Pchelko
d334de960a Expand local URLs to absolute URLs in ParserOutput
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
2021-09-23 11:48:51 -07:00
Derick Alangi
2432cc2bb4 Use PageUpdater's fluent interface as in some parts of our codebase
Some methods in the PageUpdater's class implements the fluent interface
design pattern. Use the fluent interface where need be.

Change-Id: If76a4b8c5070c20ed40038a4ee78e2d677de5180
2021-09-23 00:31:33 +01:00
Martin Urbanec
408999928d
HTMLTitleTextField: Remove B&C code
Bug: T288181
Change-Id: Iec9225d0f0fe47dd972f6c302ca803e65b8232a7
2021-09-22 00:48:59 -07:00
DannyS712
db49026745 ActivityUpdateJob: accept PageReference
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
2021-09-21 23:30:51 +00:00
DannyS712
20aa78f213 Drop deprecated BeforeResetNotificationTimestamp hook
Deprecated in 1.37 and unused

Allows a bunch of cleanup for WatchedItemStore.

Bug: T271715
Change-Id: I328cf49c3e85da2069b620f8c63670d93608a784
2021-09-21 23:09:18 +00:00
Daimona Eaytoy
c0f64981bf UndeletePage cleanup, part 1
Bug: T290021
Change-Id: Idaf25a209a65b9a36a0a24473c76523ee3a17e8d
2021-09-21 18:13:57 +02:00
Daimona Eaytoy
beadd4454f Move code from PageArchive to a new UndeletePage command
This is just moving code verbatim, removing now-unneeded stuff, and
duplicating tests as well.

Bug: T290021
Change-Id: I540ddaaa11dfabcf0b87b608b151b5e34d199fd8
2021-09-21 16:11:29 +00:00
jenkins-bot
88427bedac Merge "profiler: Fixup broken logic for the new 'running' option" 2021-09-21 04:42:58 +00:00
Derick Alangi
caf0591902 skins: Correctly index the copyright icon, caused failure in MF
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
2021-09-20 23:19:23 +01:00
jenkins-bot
8ee86f1734 Merge "Avoid using ContentHandler::getContentText()" 2021-09-20 19:14:10 +00:00
jenkins-bot
b80e8a22b5 Merge "ApiParse: Support hidden skins" 2021-09-20 15:57:26 +00:00
Alexander Vorwerk
c4b2765ebd Avoid using ContentHandler::getContentText()
ContentHandler::getContentText() is deprecated and should be
replaced with Content::getText() for TextContent instances.

Change-Id: I556d3d3f64fafd1d54c4a0c5021efaff2d9c3ce8
2021-09-20 15:32:44 +02:00
jenkins-bot
998a8426aa Merge "tests: Avoid trying to access the DB in data providers" 2021-09-20 11:25:41 +00:00
Derick Alangi
c296685f4f tests: Avoid trying to access the DB in data providers
NOTE: some test cases where removed as they're exactly doing the
same thing as the ones above.

Bug: T291268
Change-Id: I8fa8bafc892dbc84f2aab2549d453d6f39835d33
2021-09-20 10:32:45 +01:00
Derick Alangi
b648efacc5 editpage: Replace usage of Title in TextboxBuilder::class
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
2021-09-20 10:24:00 +01:00
Ammarpad
1cf4eab3ab ApiParse: Support hidden skins
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
2021-09-20 09:29:24 +01:00
Alexander Vorwerk
1a22c1c1d7 Remove global function mimeTypeMatch()
This is done without a deprecation process since the function is
@internal and completely unused outside of core.

Bug: T291341
Change-Id: I4b074f83f9be67b5b5bc2d33b2a6a55bb109a2b3
2021-09-19 19:03:46 +00:00
Umherirrender
bcee220ad1 tests: Avoid non-namespaced aliases for Wikimedia\Rdbms namespace
Change-Id: I49cb151f64c578f41dc1236b2a8906694ca97b93
2021-09-18 20:24:08 +02:00
jenkins-bot
01dea43131 Merge "Reapply "GrantsInfo service to replace MWGrants"" 2021-09-18 10:04:34 +00:00
Alexander Vorwerk
ecbaedbad2 Reapply "GrantsInfo service to replace MWGrants"
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
2021-09-18 08:52:22 +00:00
jenkins-bot
55c8edcd23 Merge "Rename diff-related classes for LTR compatibility" 2021-09-17 23:40:28 +00:00
Daimona Eaytoy
25e10bb38a Rename diff-related classes for LTR compatibility
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
2021-09-17 22:58:44 +00:00
jenkins-bot
7789aa9781 Merge "Remove LockManagerGroup::singleton() and ::destroySingletons()" 2021-09-17 19:41:49 +00:00
jenkins-bot
5bdce46006 Merge "phpunit: Fix phpErrorFilter check in TestCaseTrait to avoid PHP bug" 2021-09-17 18:57:47 +00:00
Timo Tijhof
5abebcedf8 phpunit: Fix phpErrorFilter check in TestCaseTrait to avoid PHP bug
```
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
2021-09-17 17:35:50 +00:00
Alexander Vorwerk
3f421aba14 Remove LockManagerGroup::singleton() and ::destroySingletons()
both deprecated since 1.34.

Bug: T249030
Change-Id: Ide18730c12af503259c98a0380e34a075ecd7128
2021-09-17 00:25:44 +02:00