Commit graph

128 commits

Author SHA1 Message Date
Kunal Mehta 4ccebcdf4b Simplify creating JSON pages in the Module namespace
Pages ending with a ".json" suffix in the Module namespace will use the
built-in JSON content model by default. Previously editors had to use
Special:ChangeContentModel to get a JSON page, which requires the
"editcontentmodel" userright that is not granted to a wide set of users
by default.

Bug: T144475
Change-Id: I1546fcad823a55a8c5a93177df8715844de1e87c
2022-09-22 19:48:52 -07:00
Subramanya Sastry 23ac31e746 Add Parsoid-specific support for handling preprocessed nowikis
* This patch builds on core functionality provided in
  Ied0295feab06027a8df885b3215435e596f0353b.

* This removes any nowiki wrappers present in unstripped text
  (which there would be for preprocssed nowiki tags) which mimics
  the effect of procssing nowikis in core when generating HTML.

* Updated lua tests to verify the new expectation.

* A previously failing parser test added to test T272507 now passes
  and has been re-enabled.

Bug: T272507
Depends-On: Ied0295feab06027a8df885b3215435e596f0353b
Change-Id: I1613ac7bd60cf3ef4a3308b08ea3705b3cf2dee0
2022-09-08 23:17:46 +00:00
Tim Starling 6f437487b8 Fix incorrect param type, causing phan error
Change-Id: I3a87b0c58fd897ea83dbb44c51a01d206d1cd024
2022-08-22 17:26:57 +00:00
Alexander Vorwerk 738ca8d72d Bump scribunto-stats cache version
The addition of PSquare::__serialize() in wikimedia/running-stat is
having the same cache implication as the issue this was meant to fix.

The legacy PHP serialized form is not compatible with the stable
serialize form that we're switching to.

Bug: T313341
Change-Id: Iec4c1c958e10560abcbd4184a0ca4e1a0c19183a
2022-08-16 19:09:36 +00:00
Lucas Werkmeister (WMDE) 18d122b60d Revert "Namespace LuaCommon"
This reverts commit 62e1fb0b5f.

Reason for revert: caused several errors:
* unnamespaced HooksTest collides with core’s class of the same name
* Scribunto_LuaError renamed without class alias despite being used in Wikibase

Bug: T314464
Change-Id: I8b151327236bf86945e59823fba155497e4b3fc6
2022-08-03 10:03:12 +00:00
Reedy 62e1fb0b5f Namespace LuaCommon
Change-Id: Ib6e912e71fb797942aca4b4f22eb0ff9e005a662
2022-08-03 06:03:57 +00:00
Reedy c479ad6f86 Namespace LuaStandalone engine
Change-Id: I7d3f77a56c8b74e0481197224006f19ff4c9d108
2022-08-03 06:03:48 +00:00
Reedy dc97acc945 Update mediawiki/mediawiki-phan-config to 0.11.1
Bug: T295285
Change-Id: I65db513703b54b377dfbeacf2956c1ff13a27b99
2022-08-02 01:14:06 +00:00
Reedy 1628cfa367 Namespace LuaSandbox engine
Change-Id: I485401c202057ae0fea7226ab21e68ce1c7d40c8
2022-07-30 22:51:42 +01:00
Reedy 0eaa8edfb0 Fix MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment
Change-Id: Ia2148daf26cb167cbe71a0ab419473a31d97a506
2022-07-30 18:56:55 +00:00
Timo Tijhof e9988b8473 Hooks: Minor clean up, remove redundant PSquare check
PSquare is part of wikimedia/running-stat which is bundled with
MediaWiki core. There is no valid way to install a wiki without
the vendor libraries present.

The check was introduced in 2015 with I0d39920733fe7 when the class
was newly added to the package and deployment was happening
concurrently to the extension change.

Bug: T313341
Change-Id: I6717151c39b589f2e5b5e87da6896f62252cb5d8
2022-07-19 14:58:17 -05:00
Timo Tijhof e5362f639e Hooks: Bump scribunto-stats cache version
The Wikimedia\PSquare class has changed such that its serialization
is incompatible with its prior version. We should probably refactor
this to use an actually supported serialization format, possibly
by enhancing PSquare with some kind of getter method that provides
a plain array that its constructor can accept again instead of relying
on internal PHP serialisation format, but for now we can bump the
cache version.

The side-effect of this will be that the performance stats captured
by Scribunto for visualiation in Grafana, will briefly split its
sampling logic between two versions instead of being global across
all wikis until the train is fully deployed. This does not have any
effect on its business logic or runtime behaviour, and is presumably
by design as that's the only way to bump the cache version, which was
a pre-existing factor in its cache key.

Basically, this means that during the deployment days on weeks where
this is bumped, we will briefly capture fewer samples as there are then
two separate counters trying to reach 1000 before flushing a median
to Graphite. We can remedy that by backporting and deploying to both.

While at it, I'm changing the cache key to conform to our conventions
and make it an explicit, greppable, lowercase and descriptive name
(scribuntu-stats) instead of the implicit __METHOD__ which expanded
to "Scribunto\Hooks::reportTiming". I note that this means the split
brain sampling actually happened at least once before during the week
where the namespace was introduced as that will have implicily changed
the cache-key. Another reason not to use __METHOD__ in a cache key.

Bug: T313341
Change-Id: Ic9dad0f55cba18ec03272b87366a091a396beb74
2022-07-19 14:53:53 -05:00
Ferran Tufan 674e58b87a Replace usage of Linker with LinkRenderer service
Bug: T279335
Change-Id: I778e86cf3fad2cf333031aca95aeba65a88405ce
2022-07-11 20:24:35 +00:00
Thiemo Kreuz 8654dfc466 Use new ContentHandler::supportsPreloadContent() feature
Bug: T300644
Depends-On: Ia5c491cd856ca395fb431bcefd63026084b01a99
Change-Id: I301cbb6b2d547e622ee695fd20a910f8553788c5
2022-07-06 22:39:44 +00:00
Tim Starling a0a0c3ee7e In ScribuntoContentHandler use the new ParserFactory::getInstance()
To avoid an exception when the parser is re-entered.

Bug: T310948
Depends-On: I762b191e978c2d1bbc9f332c9cfa047888ce2e67
Change-Id: I5013ed2a2958c3ff422778f9146f663aff0f5939
2022-07-05 04:31:52 +00:00
Thiemo Kreuz 0860648680 Remove unused defaults from class properties
As well as:
* Remove redundant `=== null`. The `isset()` before does this already.
* Use convenient PHPUnit shortcuts.

Change-Id: Ibef571e53a48c443d7798fee8abbc2624fbad225
2022-05-21 18:45:52 +00:00
Sam Wilson 2f0775fe8a Increase mw.dumpObject() indent size
Increase from one space to two.

Bug: T307343
Change-Id: I14126475579bae310e5cbea0bdb992fb824b30ab
2022-05-21 13:51:14 +00:00
Reedy 8e73003fee Start namespacing extension
Change-Id: Ib632434861c2df03dfcddbd195f556c937812196
2022-05-12 01:33:11 +00:00
Reedy 09b60f174c Use namespaced SyntaxHighlight class
Also swap class_exists() for ExtensionRegistry->isLoaded() call

Change-Id: I3435e3775a28f4f056599ae26ba23f54d32cde18
2022-04-27 16:10:48 +00:00
Reedy 6f411e3921 Minor cleanup
Change-Id: Ic81ab852c43e98370097d01c3b6d6cddee7a5850
2022-04-16 22:09:10 +01:00
gerritbot 14589459a1 Fix usage of ApiBase::PARAM_* deprecated constants
The ones that are replaced with ParamValidator

Bug: T275455
Change-Id: I69cfbbe5b00a4e15a0d6492541292bcddd61069a
2022-04-04 02:30:20 +00:00
Umherirrender 9c3fe53170 Adjust argument for local interwiki in InterwikiLookup::getAllPrefixes
To match the type change in core

Depends-On: I63ed9772429c6f5bfe38a9fad190491812866f3f
Change-Id: I5394d82e7c78b12453f824664f53fe8e6a73aa0b
2022-04-04 02:30:19 +00:00
Reedy 5ca204aa0d Replace usages of Wikimedia\(suppress|restore)Warnings()
Change-Id: I6bf98327dafe3d2a7009cd0897f6418ca84690dd
2022-02-24 21:16:46 +00:00
Ammarpad b8d7d70084 Use Category::getMemberCount from core
Core now provides all-member count separately with type guarantee.

Depends-On: I8780a4f9bc6c4cb588d0da10b457130df104ced9
Change-Id: Iae795c7c46360727dd4a4d47e7b8bb4dc1c607ab
2022-02-06 16:35:03 +01:00
Thiemo Kreuz 6d7d686441 Remove comments that literally repeat the code
Change-Id: I6508745504af15a233ed4f6981c5114b72f1805a
2022-01-18 23:50:13 +00:00
C. Scott Ananian 6633e446d9 Passing a string to ParserOutput::addModules()/addModuleStyles() is deprecated
In addition, several variables which contained instances of ParserOutput
were renamed to $parserOutput to help future humans and code-searchers
to distinguish these from instances of OutputPage.

Bug: T296123
Change-Id: Ic532bca4348b17882716fcb2ca8656a04766c095
2022-01-12 11:31:31 -05:00
20after4 5e7cfe4b84 Revert "mw.title: Add pageLanguage property"
This reverts commit 602cef87e0.

Reason for revert: Production errors in 1.38.0-wmf.16

Bug: T298659
Change-Id: Ic6c0e31c8247f7d89824d20f28fb0aa56d6ed749
2022-01-06 22:13:30 +00:00
Alexander Vorwerk aae6e29547 Replace usages of deprecated wfWikiID()
The global function wfWikiID() is deprecated since 1.35 and it's usages
should be replaced with WikiMap::getCurrentWikiId().

Bug: T298059
Change-Id: Idb937a82b08679f6552699ecc4a7ea1da7006e09
2021-12-21 02:32:15 +01:00
Brad Jorsch 602cef87e0 mw.title: Add pageLanguage property
Bug: T161976
Change-Id: Ifc7a462efb11b28f20ebaad5d62cba8f1f1f8e91
2021-12-17 04:10:40 +00:00
Brian Wolff 405045c416 Return correct lua version on windows
For some reason this is hard coded 5.1.4. But if you look at the
included binaries, the windows ones are clearly 5.1.5.

Change-Id: If0e7e6ae47b058b3d425b586955cc87a14b21eb8
2021-11-15 19:33:30 -08:00
Roman Stolar d2c23dd3a3 Override ContentHandler::validateSave instead of Content::prepareSave.
Prepare override for ScribuntoContentHandler, remove usage in ScribuntoContent.

Bug: T287159
Depends-On: I7f23e6e97b1c7d27a6aaefdb88b19b2fc6e8b3a8
Change-Id: I4b9287372a95f4b6178dc321105081552d040ef8
2021-11-11 16:01:05 +00:00
Thiemo Kreuz 51592c654f Add missing & and (int) casts
Bug: T290189
Change-Id: I0bd0d06834f91fbc6a4067987e7e9e9e09b4e740
2021-10-27 17:27:33 +00:00
Roman Stolar 8c66ac25c9 Override ContentHandler::fillParserOutput instead of Content::fillParserOutput.
Prepare override for ScribuntoContentHandler, remove usage in ScribuntoContent.

Bug: T287158
Change-Id: I91f6a077f5cc0de25f83bea26d9f1772af0d3d68
2021-10-19 14:08:17 +00:00
C. Scott Ananian 1af638f8db Replace use of deprecated ParserOutput::addWarning()
Bug: T293515
Depends-On: I6a7c04c67ac586ab00d4edcbb3d09485a7794e23
Change-Id: Ib51c75e38b9bf490b4ded481ee92ede0949f272e
2021-10-16 01:17:20 +00:00
C. Scott Ananian c0963eced7 Replace use of deprecated ParserOutput::{get,set}Flag()
Depends-On: I39bc58d207836df6f328c54be9e3330719cebbeb
Change-Id: I906a5970088965c187bf653267ac4b369dac9b9b
2021-10-15 23:41:06 +00:00
C. Scott Ananian 0453ef6021 Replace use of deprecated ParserOutput::addTrackingCategory()
Depends-On: I697ce188a912e445a6a748121575548e79aabac6
Change-Id: Ie41ad70f1fb5de202355314a96a1243234fb267c
2021-10-13 21:46:57 -04:00
Petr Pchelko ae920ae5b8 Replace deprecated ParserOptions::getUser with ::getUserIdentity
Bug: T292589
Change-Id: I381863a62340292e8bbc7840256f591a31afb42e
2021-10-05 14:48:28 -07:00
Arlo Breault 97cae0d3e0 Apply utf normalize to lua module name in error messages
This previously bypassed normalization because only the "value" part
of the internal exception message was normalized, the "module" part
can be invalid as well since it's derived from the original message.

Similar to Idc5514261e99d64222b86877dd0500d425a26988

Bug: T289358
Change-Id: I1ce09dd521eb80ba0d2fb6f84508a1a77d339496
2021-09-13 19:33:24 +00:00
libraryupgrader 5c63190944 build: Updating dependencies
composer:
* mediawiki/mediawiki-phan-config: 0.10.6 → 0.11.0
* php-parallel-lint/php-parallel-lint: 1.3.0 → 1.3.1

npm:
* stylelint-config-wikimedia: 0.10.3 → 0.11.1

Change-Id: I82e56565364f0502b0e70fe7414057ae876c0b98
2021-09-11 22:36:44 +00:00
daniel 1a24ade06c Use mock restriction store in tests
This fixes an incompatibility introduced by Ia73ea587586cb69eb5.

Depends-On: I1f24703b80566220ac6fe8ee500e838ed7fd29af
Change-Id: I31ca0a8987f9694bc3b312a48c2c111ceda6fa3e
2021-09-10 14:50:04 +00:00
Func b765524ac8 Handle EditFilterMergedContent hook properly to break hook chains and display error message
Extensions are supposed to return false to break hook chains when failed, which can avoid unnecessary call of later handlers in other extensions and work around with problems caused by difference betwen multiple triggers.

On mediawiki version 1.36 and before, just returning false in this hook can't display error message by default.
Set $status->value manually still to provide backward compatibility.

Bug: T280312
Change-Id: I935eb40d41c4bf9c123e131a54f6bfca2d517450
2021-06-26 12:21:06 +00:00
Alexander Vorwerk 0533aa40ab Avoid using MWNamespace
The MWNamespace class has been deprecated in favor of the NamespaceInfo
service. All methods in the MWNamespace should be replaced with the
equavilent methods of the NamespaceInfo service.

Change-Id: I964d3b191cc3129b8e467e6fbbccd2fcc0b89e11
2021-06-09 01:25:55 +00:00
Umherirrender 87e2d2ed18 Remove PHP 5.3 $this closure workaround
Change-Id: I7f2b71823844e39339811ca4bee316b432b54adb
2021-05-15 02:03:24 +02:00
libraryupgrader 31335d4602 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

npm:
* grunt: 1.3.0 → 1.4.0
* lodash: 4.17.19 → 4.17.21
  * https://npmjs.com/advisories/1673 (CVE-2021-23337)
* hosted-git-info: 3.0.7 → 3.0.8
  * https://npmjs.com/advisories/1677 (CVE-2021-23362)
* postcss: 7.0.35 → 8.2.15
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)

Change-Id: If78d89f465be14d63824f2701daca5a257edba30
2021-05-13 08:26:27 +00:00
Umherirrender d5781bd8a2 build: Swap deprecated @codingStandardsIgnore to phpcs:ignore
Bug: T278594
Change-Id: I33cc55782915f819ca3a05f2c6a535d73ac03e00
2021-04-04 19:06:50 +00:00
Ori Livneh 47f0194c2a Avoid calling into PHP from Lua to check if 'current' or 'empty' frames exist
On the Wikimedia cluster, 1.6% of MediaWiki wall-clock time is burnt on
calls from Lua into Scribunto_LuaSandboxCallback::frameExists()[1]. We
can optimize away many of these calls by not calling into PHP to check
if 'empty' or 'current' exist: the engine always reports that the
'empty' frame exists, and 'current' is guaranteed to have been set up
(in LuaEngine::setupCurrentFrames) prior to calling into Lua.

To help validate this, I added debug logging to the current production
branch of Scribunto[2] to see if there are any cases where
Scribunto_LuaSandboxCallback::frameExists('current') is false. As I
write this commit message, the logging code has been active for 24H and
there have not been any occurrences.

  [1]: https://performance.wikimedia.org/arclamp/svgs/daily/2021-03-16.excimer-wall.all.reversed.svgz
  [2]: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Scribunto/+/672836

Change-Id: I1902b711c9a442a5a42745a582a6a9ff988a355f
2021-03-17 18:04:09 -07:00
vladshapik 7ee79747e8 Avoid using User::getDefaultOption
Remove using of User::getDefaultOption since this method will be hard-deprecated. Now it is soft-deprecated

Bug: T276035
Change-Id: I34a9ece7ee25c8fa85849c9dc8d6634cde53cfe5
2021-03-01 13:19:04 +02:00
C. Scott Ananian 96da9fe0e9 Replace use of Parser::$mStripState, deprecated in 1.35
The replacement, Parser::getStripState(), was added to MediaWiki in
1.34.

The extension.json for this extension already requires MW >= 1.35.

Bug: T275160
Change-Id: I062ac8b69756a7ad35d8cc744b4735fd2e70f13e
2021-02-25 03:03:29 +00:00
Umherirrender 764d265623 Remove wrong return type from ScribuntoEngineBase::reportLimitData
Change-Id: Ide01f5c5a497d6ee9553daaacbf2e098826860f6
2021-02-03 22:10:20 +01:00
Ed Sanders 999ec38d90 Add line link anchors
Bug: T29531
Change-Id: I312169142fa901bb4bd0a359089b90e7b8dc35c5
2021-01-11 19:06:04 +00:00