Commit graph

14562 commits

Author SHA1 Message Date
jenkins-bot
e532630b11 Merge "mediawiki.util: Update addPortletLink to support 'text-wrapper' option" 2021-09-23 22:47:39 +00: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
bwang
d4d7635979 mediawiki.util: Update addPortletLink to support 'text-wrapper' option
- Add Skin::getOptions and Skin::getPortletLinkOptions, which are used
  to provide skin options to mw.util.
- Add SkinFactory::getSkinOptions, which is used by
  Skin::getPortletLinkOptions.

Depends-On: Ib23360e3439abc828404c1de8e0906915ee7d8b6
Bug: T289163
Change-Id: I801e7d583cb0b0c7da51f4da503268be736bb60c
2021-09-23 19:03:36 +01: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
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
jenkins-bot
47e10b87b1 Merge "mediawiki.Title: Support Unicode characters out of BMP" 2021-09-19 20:49:06 +00: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
Fomafix
7ca4c6365e mediawiki.Title: Support Unicode characters out of BMP
Unicode characters out of the BMP (starting at U+10000) have in a
JavaScript string two UTF-16 surrogates.

On uppercase of the first character of a title this must be supported.

This change also adds test cases to verify this.

Bug: T291321
Change-Id: I88c4ddbd39000aa09455f67ca8435ce704b98bf8
2021-09-18 11:46:18 +00: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
jenkins-bot
250f905650 Merge "stats: Simplify normalizeMetricKey() and fix bad output for edge cases" 2021-09-16 21:02:01 +00:00
jenkins-bot
6b887d5e49 Merge "Deprecate WikiPage methods replaced by DeletePage" 2021-09-16 21:01:54 +00:00
jenkins-bot
b6b903b8cd Merge "stats: Defer BufferingStatsdDataFactory::normalizeMetricKey to send phase" 2021-09-16 21:00:52 +00:00
jenkins-bot
5ebdc642fc Merge "Make EditPage use PageUpdater" 2021-09-16 20:55:33 +00:00
jenkins-bot
683495458e Merge "MediaWikiIntegrationTestCase::getExistingTestPage: Don't assume NS0 is wikitext" 2021-09-16 20:34:55 +00:00
Daimona Eaytoy
a8200aa5a8 Deprecate WikiPage methods replaced by DeletePage
Also remove the "@unstable" annotation from DeletePage.

Methods without known usages were hard-deprecated, the others
soft-deprecated.

Bug: T288758
Bug: T288759
Change-Id: I30c62572fd533526779a8ade3ab178f35bebb522
2021-09-16 20:17:45 +00:00
daniel
6ce0d2c825 Make EditPage use PageUpdater
This ensures that a DerivedPageDataUpdater is initialized earlier during
the edit process, so it can be used by hooks to access the state of the
ongoing edit.

This patch also cleans up PageUpdater a bit to make the internal information
flow more consistent with the idea that PageUpdater is acting as a
builder for a new revision.

Change-Id: I99abb7bdffb2b5ff5979ba5b1e56d39dba4cd3dc
2021-09-16 13:11:15 -07:00
Petr Pchelko
2c2ffb0bef Move revert detection code from WikiPage to EditResultBuilder
WikiPage is not the right spot to compute all the revert
related stuff - we already figure out manual reverts when
building the EditResult, lets figure out rollbacks and undos
in there as well.

Change-Id: I9fdc5f24c1db1eb0452b90bf4af1ef5ffbce6cb8
2021-09-16 12:24:34 -07:00
Daimona Eaytoy
377342de86 Deprecate and replace legacy hooks in DeletePage
In both cases the typehints were changed to the new interfaces. For the
ArticleDelete hook, the replacement has no $error param and requires the
caller to set a fatal status if it wants to abort.

Bug: T288758
Change-Id: I9540f6ab2075bcf56bd4fdc79c611c883246cdce
2021-09-16 19:13:35 +02:00
jenkins-bot
76ba780e41 Merge "WikiExporter: inject services" 2021-09-16 17:04:04 +00:00
jenkins-bot
5af89e32c7 Merge "Emit deprecation warnings reading from $wgUser" 2021-09-16 15:27:44 +00:00
DannyS712
a2b20b63d7 Emit deprecation warnings reading from $wgUser
With this patch deprecation warnings will be emitted
if $wgUser is accessed or written into. The only pattern
of usage still allowed is

$oldUser = $wgUser;
$wgUser = $newUser;
// Do something
$wgUser = $oldUser;

Once there is no deprecation warnings, we know that nothing
legitimately depends on $wgUser being set, so we can safely
remove the code that's still allowed as well.

Bug: T267861
Change-Id: Ia1c42b3a32acd0e2bb9b0e93f1dc3c82640dcb22
2021-09-15 20:17:04 -07:00
jenkins-bot
28961d052a Merge "Remove FileBackendGroup::singleton() and ::destroySingletons()" 2021-09-16 02:52:38 +00:00
Timo Tijhof
c77f9a8c60 profiler: Fixup broken logic for the new 'running' option
Follows-up I8808cad03418 which added this option, but I neglected to
actually test it. When trying it out with a patched wmf-config on
a mwdebug server, the following issue surfaced:

> Fatal TypeError: Argument 1 passed to XhprofData::__construct() must
> be of type array, null given, called in ProfilerXhprof.php:90

This is because ProfilerXhprof::disable() actually has its own state
tracking which refuses to even try calling tideways_xhprof_disable()
unless its state says it was in control of enabling it.

Remove this check and reduce the class to just abstracting the calls
to the PHP extension.

Also, remove the useless null return which is incompatible with the
callers to this function as evidenced by above Fatal TypeError.
The PHP extensions already default to an empty array, which is now
documented.

Test Plan:
* Local wiki with php-tideways installed, on this pach applied.
  Note that MediaWiki-Docker now has php-tideways pre-installed!
* In LocalSettings, configure profiling as per
  <https://www.mediawiki.org/wiki/MediaWiki-Docker/Recipes/Profiling>
  $wgProfiler = [
    'class'  => ProfilerXhprof::class,
    'output' => 'text',
  ];
* At load.php?forceprofile=1, there are valid percentages (100% "main").
* Add `tideways_xhprof_enable();` and `$wgProfiler['running'] = true;`
  to LocalSettings.
  The percentages are still valid, and the profile is now longer
  with additional coverage of early code such as MediaWikiServices.
* Switching to master, there is a fatal error with these settings.

Bug: T247332
Change-Id: Iaad88a0c46d39aee1374e5b02a77251bfa4c6f09
2021-09-16 03:26:23 +01:00
jenkins-bot
adfa9a9503 Merge "resourceloader: Fix debug mode for RL-to-RL cross-wiki module loads" 2021-09-16 01:40:13 +00:00
Timo Tijhof
008b6528b6 resourceloader: Skip version hash calculation in debug mode
=== Why

* More speed

  In debug mode, the server should regenerate the startup manifest
  on each page view to ensure immediate effect of changes. But,
  this also means more version recomputation work on the server.

  For most modules, this was already quite fast on repeat views
  because of OS-level file caches, and our file-hash caches and
  LESS compile caches in php-apcu from ResourceLoader.
  But, this makes it even faster.

* Better integration with browser devtools.

  Breakpoints stay more consistently across browsers when the
  URL stays the same even after you have changed the file and
  reloaded the page. For static files, I believe most browsers ignore
  query parameters. But for package files that come from load.php,
  this was harder for browsers to guess correctly which old script URL
  is logically replaced by a different one on the next page view.

=== How

Change Module::getVersionHash to return empty strings in debug mode.

I considered approaching this from StartupModule::getModuleRegistrations
instead to make the change apply only to the client-side manifest.

I decided against this because we have other calls to getVersionHash
on the server-side (such as for E-Tag calculation, and formatting
cross-wiki URLs) which would then not match the version queries that
mw.loader formats in debug mode.

Also, those calls would still be incurring some the avoidable costs.

=== Notes

* The two test cases for verifying the graceful fallback in production
  if version hash computations throw an exception, were moved to a
  non-debug test case as no longer happen now during the debug
  (unminified) test cases.

* Avoid "PHP Notice: Undefined offset 0" in testMakeModuleResponseStartupError
  by adding a fallback to empty string so that if the test fails,
  it fails in a more useful way instead of aborting with this error
  before the assertion happens. (Since PHPUnit generally stops on the
  first error.)

* In practice, there are still "version" query parameters and E-Tag
  headers in debug mode. These are not module versions, but URL
  "combined versions" crafted by getCombinedVersion() in JS and PHP.
  These return the constant "ztntf" in debug mode, which is the hash
  of an empty string. We could alter these methods to special-case
  when all inputs are and join to a still-empty string, or maybe we
  just leave them be. I've done the latter for now.

Bug: T235672
Bug: T85805
Change-Id: I0e63eef4f85b13089a0aa3806a5b6f821d527a92
2021-09-15 18:13:09 -07:00
Timo Tijhof
7c6713b4d9 resourceloader: Make getVersionHash() final
This is in preparation for making all version hashes the empty string
in debug mode, which will make things faster to work with, but also
helps solve T235672 in an easy way client-side without having to
add additional complexity to the mw.loader client that is specific
to debug mode.

Bug: T235672
Change-Id: I43204f22dfbcf5d236b35adc5b35df3da8021bad
2021-09-15 18:10:49 -07:00
jenkins-bot
987e8b8324 Merge "objectcache: improve the WANObjectCache "lag mitigation" TTL logic" 2021-09-15 22:55:08 +00:00
Alexander Vorwerk
da26927c73 Remove FileBackendGroup::singleton() and ::destroySingletons()
both deprecated since 1.35, hard deprecated since 1.37 and unused.

Bug: T249025
Change-Id: Ie4759fa3fa25202d623317acb444079f10e33817
2021-09-15 19:21:30 +02:00
jenkins-bot
ca252b6ee9 Merge "Make UserDefTest a unit test" 2021-09-15 14:36:53 +00:00
jdlrobson
f9be83e310 Deprecate Skin::getCopyrightIcon. Skin::getPoweredBy, SkinGetPoweredBy hook
The skin methods serve BaseTemplate so are moved there. The associated
hook is seldom used so deprecated.

Bug: T290583
Change-Id: I166241fc88b98603f8d5489643eda984f49bad66
2021-09-14 20:53:46 -07:00