Commit graph

13340 commits

Author SHA1 Message Date
Aaron Schulz
f6fec396c5 objectcache: use WRITE_BACKGROUND in WANObjectCache where applicable
This avoids the latency of waiting for a response.

Change yieldStampedeLock() to use delete() instead of changeTTL() since
the PECL memcached client does not support WRITE_BACKGROUND with TOUCH.

Also, simply relayVolatilePurges() into relayVolatilePurge() and tweak
some related documentation for WANObjectCache

Bug: T302623
Change-Id: I16f011b730f34332aa54a48c579de3c6606dafda
2022-11-09 21:17:03 +00:00
jenkins-bot
1a508fdaf8 Merge "Improve LocalisationCache post-merge validation check" 2022-11-09 10:20:49 +00:00
Timo Tijhof
41333fa512 profiler: Inject $wgProfiler from Setup.php to Profiler
Follows-up I58ff3c193190d78a. Small step toward not run-time reading
the global (and using Config here is non-trivial/unsafe).

Change-Id: Ic527e493baabe700c50f75fadaa5b51615a5e597
2022-11-09 02:58:19 +00:00
Tim Starling
0b12f8b698 Improve LocalisationCache post-merge validation check
When I deleted MessagesEn.php, neither the exception on line 498 nor
the exception modified here was thrown. Extensions register namespaces,
hiding the lack of default namespaces. If namespaceNames was missing,
RHS line 1004 would raise a warning but would create the key.

Also, phan was complaining that the key might be absent.

So, use 'rtl' instead of 'namespaceNames' as our test for data validity,
since it's less likely to be overridden by extensions. Move the check up
above the normalization of individual keys. Use isset() to satisfy phan.

Bug: T322278
Change-Id: I44c7506205fbe9ba6ffbd1155a6cdcf3ff0960eb
2022-11-09 12:57:23 +11:00
Krinkle
08286fdf91 Setup: Promote clearActionName log message to runtime warning (2)
This reverts dc3bd3d721 (I385dca1d95) and re-applies d4ce0f3255 (Ib9fc34ca64).

The CI failures have been addressed.

Bug: T314008
Change-Id: I35a4f656c31b67ebb662bf6f6366f4ee846ecbda
2022-11-08 23:29:25 +00:00
jenkins-bot
39337f2c59 Merge "Remove WikiRevision::downloadSource" 2022-11-08 21:56:09 +00:00
jenkins-bot
49074e3479 Merge "Skins: Config flag controls contributions link" 2022-11-08 19:57:29 +00:00
daniel
8c1c1ae35a Enable pig-latin variant for testing
Having pig-latin enabled per default in dev environments is convenient
for manual testing. More importantly, it will allow us to write
end-to-end tests for variant conversion.

Depends-On: I9dc2f743ac487b0f7cfb667150c0f6950d5e7fce
Depends-On: I85b66c85be3959d48a048733af17197bc4cf70af
Change-Id: Ia80ad33cbf5e311fa8b84bd765a8df8d156f4c38
2022-11-08 17:45:51 +05:30
Máté Szabó
c04cb6f607 Include core PSR-4 classes in the generated classmap
It appears that autoloading classes via MediaWiki's PSR-4 autoloader has
a not insignificant performance penalty, especially when hundreds of
PSR-4 classes like HookRunner's hook interfaces are autoloaded. Using a
classmap autoloader, like we already do for PSR-4 classes from Composer
dependencies, is a potential way to reduce the performance impact
here.[1]

For core classes, this can be done by simply not excluding PSR-4 classes
in AutoloadGenerator, causing it to include appropriate mappings in the
generated autoload.php classmap. I had to exclude one class_alias()
declared in Result.php from the classmap with a NO_AUTOLOAD stanza,
because including it broke AutoLoaderStructureTest's assertion that all
aliases should be defined in the same file as the aliased class.
Assuming this is still an issue, this would already have been a problem
because the test was previously skipping every PSR-4 class. Excluding
this file via NO_AUTOLOAD just restores that status quo.
----
[1] https://phabricator.wikimedia.org/T274041#8358399

Bug: T274041
Change-Id: I0aa62c944d874bf7a9f3a240e72e58fe6a887b28
2022-11-08 12:13:32 +01:00
Amir Sarabadani
719ce204a0 Reorg: Move ForeignResourceManager to ResourceLoader directory
It literally has @ingroup ResourceLoader

Bug: T321882
Change-Id: Ia5c7c56c9235f98754f6d5e602da4626a76ff083
2022-11-08 10:54:17 +01:00
Amir Sarabadani
7690ab4e33 Reorg: Move HeaderCallback to Request directory
Cleaning root of includes/

Bug: T321882
Change-Id: I1844da95d4fd79824646fdf4b6063cb771ca3000
2022-11-08 10:53:27 +01:00
Moh'd Khier Abualruz
2dfe4a923b Skins: Config flag controls contributions link
This restores a rewritten version of
commit 78483caaaf.

- Special:Contribute the default entry point in the menu when enabled
- Otherwise it will link to Special:Contributions (default behaviour)

Depends-On: I65336cfd56e1f6b92c1b3bc83cb5d91bbca065bf
Bug: T319327
Change-Id: I67779b88c4904462f9d847b3edb08a65306b2bfb
2022-11-08 10:33:39 +01:00
thiemowmde
6208f68751 Relax ReleaseNotesTest to accept long URLs
Needed-For: I1f085532ab720265acb1213f33869f759a987d92
Change-Id: Icb09fed4cd6d0306ce081b0ea1ca63ef55c4ad25
2022-11-07 13:53:49 +01:00
jenkins-bot
60a0c634fe Merge "site: Annotate CachingSiteStore as @internal and perform minor cleanup" 2022-11-05 00:52:04 +00:00
Timo Tijhof
c8f1699d51 site: Annotate CachingSiteStore as @internal and perform minor cleanup
* Recognise CachingSiteStore as the internal class that it is.

* Clean up the file header and move ingroup annotation, similar to
  other commits under
  <https://gerrit.wikimedia.org/r/q/message:ingroup+owner:Krinkle>.

  The one here was particularly odd as it placed the license inside
  the class doc block rather than the file doc block.

* Remove unused $cacheKey and $cacheTimeout constructor args. They
  were also not covered by any unit tests.

* Avoid use of `empty()` as per
  <https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP>

* Use a more conventional cache key in CachingSiteStore, keeping
  the dynamic part for a later segment and keeping the first segment
  explicitly tied to a single concrete key group. This also improves
  ergonomics of cache statistics e.g. in Grafana and makes the cache
  key easier to locate in codesearch/grep, and more recognisable,
  e.g. starting with the code component ("site").

Change-Id: I541ad62551ab76127d70ef665272fd1d590ab556
2022-11-05 00:37:12 +00:00
Timo Tijhof
4d72e28e03 rdbms: Fix test to not rely on deprecated class aliases
Restore unrelated test fix from 46eabe275c, which got reverted
in 0b43c49465.

The DatabaseFactory::create() function takes $type which is either
a built-in type (mysql, sqlite, postgres) or theoretically the suffix
of a database extension class for a custom type.

"mysqli" is not a valid type, the type is "mysql". This was passing
because DatabaseMysqli still exists as a class alias for the namespaced
Rdbms class.

Bug: T309418
Change-Id: Ic05a4b3d4cfe539e11df3dc83dfe459c184d1332
2022-11-04 22:09:58 +00:00
daniel
6fd3a7b0b0 Stash original wikitext when rendering unsaved content.
When visual editor switches from source mode to visual mode, we need to
stash the wikitext. Otherwise, we later lack the proper context to
convert the modified HTML back to wikitext.

Bug: T321862
Change-Id: Id611e6e022bf8d9d774ca1a3a214220ada713285
2022-11-04 17:17:32 +01:00
jenkins-bot
fcf1254593 Merge "PHPUnit: introduce clearHooks() method." 2022-11-04 14:11:49 +00:00
Matěj Suchánek
884efbe0e3 Remove WikiRevision::downloadSource
It has been deprecated since 1.31 and it is unused.

Change-Id: I695e7f5d253076829ba9b58bccd7bfc77624c393
2022-11-04 09:24:15 -04:00
jenkins-bot
61b911455d Merge "ApiQueryRevisionsBase: Fix 'rvdiffto' parameter handling on PHP 8.0" 2022-11-04 10:52:02 +00:00
jenkins-bot
5f84c3eac4 Merge "Various doc fixes about false and null on method arguments/return types" 2022-11-04 10:35:19 +00:00
Derick Alangi
701cf7ab92 HtmlInputTransformHelper: Capture metrics for SelSer context
Bug: T318399
Change-Id: Iff2439cb281126ef41c445fb86433a561b3981e7
2022-11-04 14:06:36 +05:30
jenkins-bot
18f7181508 Merge "HtmlInputTransformHelper: setters for programmatic use" 2022-11-04 05:56:20 +00:00
jenkins-bot
eb19ae2294 Merge "Fix LanguageConverterTestTrait.php didn't normalize language codes" 2022-11-04 05:52:30 +00:00
jenkins-bot
59ab57573d Merge "objectcache: add "segmentable" option to WANObjectCache" 2022-11-04 00:32:21 +00:00
jenkins-bot
e1d7753b53 Merge "rdbms: simplify getLagFromPtHeartbeat() in DatabaseMysqlBase" 2022-11-04 00:27:17 +00:00
Aaron Schulz
b24871a15c objectcache: add "segmentable" option to WANObjectCache
This allows for large string value storage similar to that
of direct BagOStuff callers.

Bug: T309126
Change-Id: I22d2d8bb520ef2ea6ccd28016d34db36fe27c3df
2022-11-04 00:12:44 +00:00
jenkins-bot
1654a4bbe3 Merge "PagerNavigationBuilder: Document that nulls in setLinkQuery() etc. are allowed" 2022-11-03 20:27:24 +00:00
jenkins-bot
32aa00c175 Merge "pager: Remove unused PagerNavigationBuilder::setExtra()" 2022-11-03 20:26:08 +00:00
Umherirrender
1b342a8893 Various doc fixes about false and null on method arguments/return types
Doc-only changes

Change-Id: Ice974b3ba41708859dfe646e94b31c5ebbf26410
2022-11-03 18:55:47 +01:00
jenkins-bot
5b703126e5 Merge "Remove deprecated MWTimestamp::getHumanTimestamp" 2022-11-03 17:48:23 +00:00
Umherirrender
1d2d7ef85b Remove deprecated MWTimestamp::getHumanTimestamp
Change-Id: I2374b8e1f51edd83172707fdfd2ad27ca89ad4ef
2022-11-03 17:00:39 +00:00
daniel
0457d9fa5b HtmlInputTransformHelper: setters for programmatic use
This patch is intended to allow HtmlInputTransformHelper to be used
without constructing a fake request body. The idea is to make it easier
to use it in action API modules, such as ApiVisualEditorEdit.

Change-Id: I4002342820b19060da30b6fb8622c85c49eec6a0
2022-11-03 22:25:19 +05:30
jenkins-bot
81434f95f5 Merge "Produce HTML for invalid JSON" 2022-11-03 16:42:31 +00:00
daniel
f545d5efeb Rename HTMLTransform to HtmlToContentTransform
* We will have several kinds of HTML transformations.
Rename HTMLTransform to indicate that its for converting HTML to Content
objects.

* Using Naming Convention 'Html' instead of 'HTML'

Change-Id: I506f3303ae8f9e4db17299211366bef1558f142c
2022-11-03 16:47:36 +01:00
daniel
80d8af47f7 Produce HTML for invalid JSON
implementations of ContentHandler::fillParserOutput MUST set HTML if
$cpoParams->getGenerateHtml() returns true.

Bug: T321319
Change-Id: Ibd43f7420e949666649752dce7072dc35bc1f440
2022-11-03 16:44:47 +01:00
jenkins-bot
1e2112436b Merge "variant transform: allow input content-language to be a variant" 2022-11-03 15:27:59 +00:00
Máté Szabó
f15e0a62f9 ApiQueryRevisionsBase: Fix 'rvdiffto' parameter handling on PHP 8.0
The legacy 'rvdiffto' API parameter allows consumers to supply a
revision ID or the special strings 'cur', 'prev', 'next' to
revision-related API modules. This will then be resolved to a revision
and the diff of returned revisions against this revision will be
attached to the response.

On PHP 8.0, this parameter is broken as 'cur', 'prev', 'next' no longer
get resolved to the appropriate revision ID but rather are treated as
invalid literal revision IDs. This is because given an associative array
`$params = [ 'diffto' => 'prev' ];`, the expression `$params['diffto']
!= 0` is false on PHP < 8.0 but true on PHP >= 8.0.[1]

Fix it by also checking whether the parameter value is numeric before
treating it as a revision ID, and add a test case for this logic. To
facilitate testing, convert the counter used by ApiQueryRevisionsBase to
count the number of uncached diffs served in the current response to an
instance variable; it is currently a static variable which persists
across test boundaries.

Change-Id: Ifbe14cd2880c98dddc5577d226bef5878bdd657f

---
[1] https://onlinephp.io/c/81e7b

Bug: T322335
Change-Id: Id5032932842c94f4d3ca3707fbc733f5b9704151
2022-11-03 15:49:04 +01:00
daniel
8e0ae53482 PHPUnit: introduce clearHooks() method.
Since the introduction of the new hooks stystem, it is not possible to
clear all hooks by setting $wgHooks. This would only clear old-style
hooks. This is becoming increasingly problematic as the new hooks system
is adopted by more and more extensions.

Introduce a method that allows tests to reset many or all hooks.
This isn't needed much in core, but extension tests need it.

Change-Id: Ica3eb88fe23fe822d2aadb96ff5d15f80dce0d7b
2022-11-03 13:40:42 +01:00
Bartosz Dziewoński
2422e2ae9f PagerNavigationBuilder: Document that nulls in setLinkQuery() etc. are allowed
We already depend on this behavior in IndexPager::getNavigationBuilder(),
but it wasn't allowed by the type hints and wasn't covered by tests.

Change-Id: I9343e852dc4610a50adf1c22ed429ec0a40da816
2022-11-02 23:56:35 +00:00
Bartosz Dziewoński
08895be51b pager: Remove unused PagerNavigationBuilder::setExtra()
Follow-up to Ic75bd597b210e14612ca3aebb531b659897e8294.
No longer needed after I161dc0159e4372e3478341ee3fbea13b723d9fc1.

This is a public method, but it has not been included in a release
yet, so we can remove it without deprecation.

Change-Id: Ie5eea4d3423136812178747e187771e7cf78e95f
2022-11-02 21:38:56 +01:00
jenkins-bot
1005ba3be8 Merge "Use buildComparison() instead of raw SQL in WatchedItemQueryService" 2022-11-02 10:11:41 +00:00
Winston Sung
a468c172c9 Fix LanguageConverterTestTrait.php didn't normalize language codes
Normalize language code since classes uses underscores.
See tests/phpunit/languages/LanguageClassesTestCase.php Line 55.

Change-Id: Icc5425c41da531c5f403fda525f46451c7b9e3b7
2022-11-02 07:40:21 +00:00
daniel
4ad9c9b035 variant transform: allow input content-language to be a variant
When submitting HTML to transform/html/to/html, the language specified
by the input's content-language header should be allowed to be the
source variant.

It should also be possible to just specify the source variant, and
derive the base language from that rather than the content-language
header or the page language.

Change-Id: I703c112358a921a8b0c9e63b70fd820ae3ea16fc
2022-11-02 01:30:36 -04:00
Aaron Schulz
85eb9b3e66 rdbms: simplify getLagFromPtHeartbeat() in DatabaseMysqlBase
Avoid expensive SHOW query for sites that were explicitly configured
to use pt-heartbeat but configured without a row SELECT condition.

Reduce excessive code complexity for configuration edge cases.
Remove getLagDetectionMethod() and just use the field instead.

Change-Id: I0d8592fde65d8a143506c55dccd1972a148bd489
2022-11-01 21:33:05 -07:00
jenkins-bot
3a61bdbd43 Merge "objectcache: split out WANObjectCache::setMainValue() helper method" 2022-11-01 23:55:47 +00:00
Aaron Schulz
a454105b48 objectcache: split out WANObjectCache::setMainValue() helper method
Make set() and getWithSetCallback() wrap setMainValue(), avoiding some
duplicate option array resolution logic.

Track set() calls via statsd, now that it can be distinguished from
getWithSetCallback() invocations.

Change-Id: Ia1e7b244b1db3b76314d718b3aea9e6e708235c0
2022-11-01 15:53:48 -07:00
jenkins-bot
768c46a886 Merge "tests: Replace deprecated WikiPage::factory in RevisionStoreDbTest" 2022-11-01 20:45:51 +00:00
Abijeet
46989b35ac revision/html endpoint: Support variant conversion
Bug: T317019
Change-Id: Ibcd08d20477dab283e29d37b1387a6289b404b70
2022-11-01 19:21:50 +05:30
Abijeet
1b53f15e7f page/html endpoint: Support variant conversion
Variant conversion is based on the Accept-Language header. Updated
the HtmlOutputRendererHelper to set the HTTP headers related to
variant conversion.

Bug: T317019
Change-Id: I5e11452f1c531a757e8d860f9c727b5810406bce
2022-11-01 19:21:42 +05:30