Commit graph

78 commits

Author SHA1 Message Date
Thiemo Kreuz 51592c654f Add missing & and (int) casts
Bug: T290189
Change-Id: I0bd0d06834f91fbc6a4067987e7e9e9e09b4e740
2021-10-27 17:27:33 +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
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
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
Ed Sanders 16f2db8987 Use strict equality when comparing namespaces
Change-Id: I15288a83d1ddb3744653077daddd7ebb7e8bba73
2021-01-01 16:44:40 +00:00
libraryupgrader 7e49f2396e build: Updating mediawiki/mediawiki-phan-config to 0.10.6
Change-Id: I400be95d82c6cc5d0473eaba932b34146526eff8
2020-12-30 14:30:00 +00:00
Umherirrender cb39fead91 Add missing @var and improve documentation
Change-Id: Idb7ff848ba702eac2cde31c6198a70311e3bdb69
2020-12-22 01:15:00 +00:00
shubham656 11244fed16 Add length attribute in TitleLibrary.php
Bug: T209679
Change-Id: Ieb7aac0c4131b76ae872151d6f5b815ce9ca3e0a
2020-12-21 09:15:55 +00:00
libraryupgrader 66e8b6a46f build: Updating dependencies
composer:
* mediawiki/mediawiki-phan-config: 0.10.4 → 0.10.5

npm:
* ini: 1.3.5 → 1.3.7
  * https://npmjs.com/advisories/1589

Change-Id: I334074a31e68cdd8fb4f278fe279d6e1e11d78d6
2020-12-11 16:24:46 +00:00
Derk-Jan Hartman d65c61e49b Error message for formatNum should not refer to formatDate
These new error messages were referring to formatDate instead of
formatNum.

Change-Id: Ic20a5a5515ee55d46087449627138cc779909ec3
Follow-up: Ib7706ad40f7ee2da6ab7c6b2dab6ae8d129dab52
Bug: T268758
2020-11-26 14:12:15 +01:00
libraryupgrader 14046a6414 build: Updating mediawiki/mediawiki-phan-config to 0.10.4
Additionally, unbreak master build after core change T10327.

Change-Id: I8fb240c9b8291d907b857f17d6f4960a24de2ef7
2020-11-20 17:01:25 +00:00
C. Scott Ananian 078253bd06 library: Lua formatNum should check that the value is not infinity or NaN
The core formatNum method only works on strings which pass `is_numeric`,
not NaN and +/- infinity.

Bug: T267587
Change-Id: Ib7706ad40f7ee2da6ab7c6b2dab6ae8d129dab52
2020-11-16 17:44:17 +00:00
Tim Starling eb01c6ad22 Fix invalid UTF-8 in LuaSandbox profiler data
Bug: T228746
Change-Id: Idf5cd4ed230a40f6894ed7b435c28c9ec2764b9b
2020-11-10 15:13:27 +00:00
C. Scott Ananian 7ec0ebfb2a Format Scribunto Lua Preview Limit Report memory numbers in bytes
Makes it consistent with other entries

Bug: T263592
Change-Id: Icc303455feab27966480854ea1c055ceab864ee0
2020-11-05 13:43:27 -05:00
libraryupgrader 00fc2c3f1e build: Updating mediawiki/mediawiki-codesniffer to 33.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam
* MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate
* MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected
* MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic
* MediaWiki.Commenting.PropertyDocumentation.WrongStyle

Additional changes:
* Added the `wikimedia/mediawiki` profile in .eslintrc.json (T262222).
* Added the `wikimedia/jquery` profile in .eslintrc.json (T262222).
* Removed global `$`, included in the `wikimedia/jquery` profile (T262222).
* Removed global `mw`, included via `wikimedia/mediawiki` profile (T262222).
* Dropped the emtpy global definition in .eslintrc.json.

Change-Id: Ib0acbf92bcb8327ecd065db5db1083d7b222976c
2020-11-04 17:24:30 +00:00
Reedy b53689abde Fix double formatting of memory units
Bug: T263592
Change-Id: If8a71419d656530859552abaddeed66d5a9ddc4b
2020-10-23 19:46:57 +00:00
C. Scott Ananian 0cd8904842 Suppress phan false positives in LuaSandboxEngine::formatLimitData()
Most of this function deals with values for the single
scribunto-limitreport-profile key, where $value is an array of
strings.  Phan's security check plugin was getting confused because
*in general* the $value passed to a ParserLimitReportFormat hook can
be almost anything.

Change-Id: I0ef5ef71f00a92bd5db0df340725c88595fcb0c6
2020-10-23 17:02:23 +00:00
C. Scott Ananian 2bec230e3d Use Language::formatNumNoSeparators where appropriate
Avoids using the deprecated $noSeparators parameter to Language::formatNum
in favor of Language::formatNumNoSeparators, which has been around since
MW 1.21.

Change-Id: If3de5645a92514f605d4117fea3a820ed6c86624
2020-09-09 18:17:23 -04:00
libraryupgrader b9c82f4d4a build: Updating mediawiki/mediawiki-phan-config to 0.10.2
Additional changes:
* Removed phan-taint-check-plugin from extra, now inherited from mediawiki-phan-config.

Change-Id: I83fff3a5ff566790bc051d7bfffe7f3b124d3de7
2020-06-02 01:54:01 +00:00
Reedy aeaa5172b9 Fix PSR12.Properties.ConstantVisibility.NotFound
Bug: T253169
Change-Id: I50048f917c4b8cde4ebc002ed57f0e0afcf6e8c6
2020-05-30 01:32:16 +01:00
Brad Jorsch 34fc672f6d Add tests and type checking for mw.addWarning()
Testing was overlooked when this was added in Ibdd2506f.

Change-Id: Ie17020e3082668180dfa1d6532946891ea7951ea
2020-05-08 17:05:11 +00:00
DannyS712 c062595b01 Handle RevisionAccessException with try-catch
Failures caused by a9b073fc62

Bug: T252156
Change-Id: I703c2e0b13e79716f156e1c995fd139fbc68e321
2020-05-07 20:57:42 +00:00
DannyS712 a9b073fc62 Remove use of Parser::fetchCurrentRevisionOfTitle and Revision::getSha1
Use new fetchCurrentRevisionRecordOfTitle

Bug: T249384
Bug: T251233
Change-Id: I9a4974a990f8e4f7935cd8e38da918fd45a2282c
2020-04-28 09:34:26 +00:00
libraryupgrader 9facd741cc build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 29.0.0 → 30.0.0

npm:
* eslint-config-wikimedia: 0.15.0 → 0.15.3
* grunt-stylelint: 0.14.0 → 0.15.0
* stylelint-config-wikimedia: 0.9.0 → 0.10.1

Change-Id: I684372efb0248862700184546a5172bfd6d81ae0
2020-04-22 19:07:11 +00:00
C. Scott Ananian e0837cfd46 Don't use deprecated Parser::OutputType()
Depends-On: I0b4d5f170216597afb259cedbb13b8028d284715
Change-Id: I70e0ecb201d5ffdc3ccb75caf552a1dee4ad9e60
2020-04-17 00:47:42 +00:00
Antoine Musso fda6a663aa Remove trailing newline from log messages
wfDebug() required a newline in the message. That is no need with
wfDebugLog() or with our PSR-3 logging interface.

Bug: T228848
Change-Id: Ieb3de1ab59174ec0e1301e42bccee6cebce8749f
2020-03-23 14:58:33 +00:00
Umherirrender 724c38c892 Use MediaWikiServices::getRepoGroup
This required MediaWiki 1.34

Change-Id: Ie7186b0729b54ef9a52b18bb6a2a2696dca6daed
2020-03-16 17:58:49 +00:00
Umherirrender 92587641dc Use MediaWikiServices::getContentLanguage()
This required MediaWiki 1.32

Change-Id: Iff717eba8f4fad1e80229ebcf317ceec81667846
2020-03-16 17:58:26 +00:00
DannyS712 d1f6e793ee Stop using old deprecated SpecialPageFactory static functions
Bug: T245686
Change-Id: If4d166c9a95bb9381ea4de560168f5d9d683d6f5
2020-02-19 23:12:56 +00:00
Brad Jorsch 66f83331db Record vary-page-id when ID is accessed via mw.title
This triggers a needed reparse when a new page is created using a module
that accesses the page ID.

Bug: T237746
Change-Id: I5564c2e896dd2a025c5a886ca478c377fac83e74
2020-02-13 17:24:41 +00:00
libraryupgrader 7b2cda5591 build: Updating composer dependencies
* mediawiki/minus-x: 0.3.2 → 1.0.0
* jakub-onderka/php-console-highlighter: 0.3.2 → 0.4.0
* mediawiki/mediawiki-phan-config: 0.9.0 → 0.9.1

Change-Id: Ibdedddbf19eb4712c31c1b95024391ff013f73e8
2020-02-07 06:37:29 +00:00
Brad Jorsch 3a19bb8b0c Document a lot of methods
Clear up a bunch of phpcs ignores by documenting many methods.

Also remove Scribunto_LuaError::setLineMap(), which has apparently never
been used since it was added in Ia51f439e.

Change-Id: I763bcdbc7edbbb8e4600495a03acca3439fc0ec9
2020-01-17 23:03:03 +00:00
Umherirrender ef8aff71ec Use class name resolution to refer to class names
::class is validated by phan and avoids misspelled class names

Change-Id: I613d5df56fcee6099e4294f5c6df078aafad1210
2020-01-02 16:59:55 +00:00
libraryupgrader 3b2d40f28d build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Depends-On: I9661ed8dd80cb827d7a1414c1eef952c0933a1f0
Change-Id: Ia34d9d9eade74cbb261dbfe4e39971de57cab888
2019-12-31 20:46:17 +00:00
Umherirrender 9c6f6f905a Split all classes in own files
Move autoload entries for test to TestAutoloadClasses key

Change-Id: Ie705db0e7225600b7b498cfa134733a65f1ae1c9
2019-12-21 10:20:18 +01:00
Umherirrender e70a548fbc build: Updating mediawiki/mediawiki-phan-config to 0.8.0
Bug: T235049
Change-Id: Ia8cb36d60d56eb899e96eacf7640d8da50c4adfe
2019-11-26 09:30:36 +00:00
Max Semenik 764847164a Replace trigger_error('') magic with error_clear_last()
Bug: T191247
Change-Id: I8bedd9c6df4648941c957d92fa8b0c8464f1d796
2019-10-28 14:08:55 +00:00
Brad Jorsch 0ee41431c2 Don't error if someone returns a built-in function from their module
This is getting close to the point of "don't do that, just wrap the
built-in". But since it's a regression in a recent patch, let's restore
the old behavior here.

Bug: T236092
Change-Id: Ieddc23d942bc91fd0246ae14d8a4af7719e3834f
2019-10-23 08:41:40 +00:00
Brad Jorsch 1617bb3deb Return correct frame from mw.getCurrentFrame in certain edge cases
When an #invoke is passed as an argument to another #invoke,
mw.getCurrentFrame() at module scope will return the wrong frame.

On the PHP side, we need to always reset the frame when processing
an #invoke, not just when there's no frame already. I don't remember why
I82dde43e wasn't done that way, but changing it doesn't make any tests
fail and Scribunto tends to have good tests.

On the Lua side, we need to do the same. The logic wih mw.getCurrentFrame()
using a global that gets stored, modified, and reset in several places
was getting confusing, so this patch reworks the logic to inject a
globalless mw.getCurrentFrame() into each #invoke's cloned environment
instead.

Bug: T234368
Change-Id: I8cb5bc4dc14c9b448c9f267e0539daa75e72af4c
2019-10-14 02:39:13 +00:00
Umherirrender fc7a6d5b5e Get GenderCache from MediaWikiServices
GenderCache::singleton is deprecated since 1.28
The service exists since 1.28, this extensions required 1.31

Change-Id: I3925f9ac2facc59cf37c82e16284e53c61abbc6e
2019-08-21 17:13:43 +00:00