Test output changed in I3fac0f34d134d8eec46c7eefa3ad2b67abb957da.
Depends-On: I3fac0f34d134d8eec46c7eefa3ad2b67abb957da
Change-Id: I8797ab1adbd44b2766ec803d9b6fe646b3a5a116
As well as:
* Remove redundant `=== null`. The `isset()` before does this already.
* Use convenient PHPUnit shortcuts.
Change-Id: Ibef571e53a48c443d7798fee8abbc2624fbad225
This reverts commit 9adf9ef66c.
Reason for revert: The feature it's testing has been reverted in Ic6c0e31c8247f7d89824d20f28fb0aa56d6ed749
Change-Id: I74b4273bf246560b31911f8953974b9653217ec9
WikiPage::factory() is deprecated since 1.36 and should be replaced
with WikiPageFactory::newFromTitle().
Bug: T297688
Change-Id: Ie333c616c46a71430f8c18db85bdd64c13379ef0
This fixes an incompatibility introduced by Ia73ea587586cb69eb5.
Depends-On: I1f24703b80566220ac6fe8ee500e838ed7fd29af
Change-Id: I31ca0a8987f9694bc3b312a48c2c111ceda6fa3e
::doUserEditContent() is available since 1.36 as a replacement
for ::doEditContent(), which has been deprecated. Bump the
required version of MediaWiki to 1.36 accordingly.
Results in passing a user where previously the fallback
to $wgUser was being used.
Bug: T255507
Change-Id: I11e4a305e66935ea1d1b4692561fb5d49871a729
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
Use $wgInterwikiCache to setup interwiki prefixes for testing instead
of the deprecated InterwikiLoadPrefix hook. This simplifies the test
setup quite a bit as well.
Bug: T270444
Change-Id: Icb772fcee07103a06548011ddd653487477ebfcc
These new error messages were referring to formatDate instead of
formatNum.
Change-Id: Ic20a5a5515ee55d46087449627138cc779909ec3
Follow-up: Ib7706ad40f7ee2da6ab7c6b2dab6ae8d129dab52
Bug: T268758
The core formatNum method only works on strings which pass `is_numeric`,
not NaN and +/- infinity.
Bug: T267587
Change-Id: Ib7706ad40f7ee2da6ab7c6b2dab6ae8d129dab52
Message formatters which expect numeric arguments should not be passed
non-numeric arguments; they will emit a deprecation message if they are
given such (core commit 448a51ae083abc1ca9fccb51a5a533e0fe9f8b71).
Change-Id: I431538873083e14dbd85cb1c8889c3a8350aa75a
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.VariadicArgument.SuperfluousVariadicArgComment
Additional changes:
* Replaced "jakub-onderka" packages with "php-parallel-lint".
Change-Id: I97d1101854d87f7d0d4c8f14b629bee75df6030d
This means that these tests are only run for test runs on this repo,
and will not be run when this repo is included in CI as a dependency
of any other repos, or the Wikimedia-wide gate. Any changes to other
repos are implicitly assumed to be unable to break these tests.
Bug: T125050
Change-Id: I7b77c0627f3fbe9dfbbf3d63cbd57e943d328555
This triggers a needed reparse when a new page is created using a module
that accesses the page ID.
Bug: T237746
Change-Id: I5564c2e896dd2a025c5a886ca478c377fac83e74
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
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.WrongStyle
Change-Id: Ifa2c7a7febc1e06c28318305cfef0b0103c6e8eb
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
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
And use the unit test base on most of the tests, except the ones that need
database. This makes tests considerably faster.
Bug: T230701
Change-Id: Ifbede1e2610c672b4d8a83ce41f74200e0c97be9
MediaWikiIntegrationTestCase (formerlly know as MediaWikiTestCase)
is a very heavy class that resets the database, caches and services between
every test.
Bug: T229180
Change-Id: I3d328d6ba7009e87c0f432a4f8d84d774ea57e5f
The test currently runs a busy loop that does string operations 1
billion times, when really it just needs something that takes more than
2 seconds of CPU time. On the other hand, there's another test that uses
the same method to run only 100 string operations for a different test.
Add a second parameter to have it exit early if enough CPU time has been
used, and use it in the first test.
Bug: T220685
Change-Id: I32309f049bcfb2e1310651818ff8674f0a311f40
RFC 3986 allows IPv6 literals (and future IP versions) by having the
"host" enclosed in brackets, like `http://[2001:db8::]`. mw.uri should
handle these appropriately.
Bug: T223267
Change-Id: I6f712b87bc376cf606c6c2ebbe80176037d6dddb
If TemplateStyles installed, then enable it in the Module namespace
by default. This change is analogous to I96d9601ff80c2d3eb052c01.
Since both extensions use the ContentHandlerDefaultModelFor hook, Scribunto
will check if the sanitized-css model has already been set, and if so, not
override it. If the page is in NS_MODULE, it will set the content model to
Scribunto, but allow further hooks to override it, in which case it is
expected that TemplateStyles would set it to sanitized-css.
Bug: T200914
Depends-On: I2fa9b822ee39bcc5f95a293c8c4aad4d53ede30a
Change-Id: I7a9b445accde35e4a5e7d13100c646f211d21afe
It's easily possible for Lua to raise errors where the string is not
valid UTF-8. When we turn that into a Scribunto_LuaError, we should
normalize it so other things don't break.
Bug: T208689
Change-Id: Idc5514261e99d64222b86877dd0500d425a26988
This test causes spurious CI failures in other projects; to unblock them
for now, remove the test again until we can figure out how to make it
work better.
This reverts commit 7a7f522676.
Bug: T209232
Change-Id: Id2eeeb781b7a8a6298ba06d78bab238b37dac9ca
As documented, string.gub( 'foo', '%a', '%1' ) should raise an invalid
capture index error because there is no capture with index 1 in the
pattern. But in fact it treats %1 as %0 in this situation. The ustring
library should match this behavior.
This patch also adds some tests for the behavior of gsub with table and
function replacements when the pattern does have captures.
Bug: T207623
Change-Id: Ie3e6c2eafa4a05989815c62c7037167642581751
If the replacement table or function results in a value that isn't a
string or number (or nil), string.gsub raises an error. Have ustring
raise the same error.
Bug: T195326
Change-Id: Ic36f9f5d7adc0c14e7a4a94d3747335107acd8b6
Manually import LuaSandbox's git repository as a composer dependency to
provide the PHP stubs for phan.
Change-Id: I6226b9211f31d829da5a2775c6f5cf3599dd8ebc
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.MissingCovers.MissingCovers
Change-Id: I07b2cf945f44fd5532812a712f7dd40d2f208be2
When passing an array from PHP to Lua, stringify integer array keys
beyond the range a lua_Number can represent.
When passing a table from Lua to PHP,
* Avoid exponential encoding for integer keys beyond 1e14, so Zend PHP
will interpret them as integers.
* Always encode integer keys as integers, so HHVM will interpret them as
integers.
* Detect collisions, e.g. { [0] = 'foo', ["0"] = 'bar' }
Bug: T186240
Change-Id: I078068ed57df078248a307608381614bdfc70801
The extraneous whitespace in the return value from wfShellExec() causes
multiplying $size to trigger the newly introduced "A non well formed
numeric value encountered" warning in PHP 7.1+.
Work around that by using trim() to get rid of the whitespace.
Bug: T186299
Change-Id: I3d47ef6cc7fb99b4d4840dc847d150c3939ee535
The two lualib/ustring generation scripts run independently of MediaWiki, so
the new wfIsCLI() isn't usable there.
Bug: T184043
Change-Id: I217657d12e16a7b76dc814be5fed03540c461e7c
This should make sure the tests still work, even if the running
node is heavily overloaded.
Bug: T143389
Change-Id: Ic40c8d76c8799c2e9d11f53945276747c199fd02
Iaa880531 added extra frames in the call stack, so the frame being
tested by the "setfenv invalid level" and "getfenv invalid level" tests
was no longer invalid.
Bug: T175065
Change-Id: Id1028e7c8bbb92fb9d7d01ebeabd94e8ba284b1c
The core {{urlencode:}} parser function doesn't encode various
characters in WIKI mode that it does in other modes. mw.uri.encode
should match that.
Bug: T174239
Change-Id: I2be0811cf39c02c5c0ad3433e4b0ef9030350e24
Make the language cache size configurable, and increase the default from
20 to 30. It needs to be fairly small on default installations, but can
be essentially unlimited if $wgLocalisationCacheConf['manualRecache'] is
true.
Bug: T85461
Change-Id: Idb17691b30b0d2565a1624e5159df7d9b795764d
I252ec046 noticeably broke things by adding a dependency on the pcntl
functions, which tend not to be present under Apache.
It also subtly broke exit handling by using proc_close()'s return value,
which PHP mangles in such a way that we can't tell the difference
between an actual XCPU kill and exit( SIGXCPU ). This one wasn't noticed
because the pcntl functions interpret everything proc_close() is going
to return as a signal kill and we didn't test the 'exited' code path.
I'm not sure what was going on in I57cdf8aa since it provides no details
about what it was trying to fix, but that would have broken signal
handling in the other way: Ibf5f4656 worked because proc_open() on Linux
executes the command by passing it to /bin/sh -c, and that shell is
going to turn any signal that kills Lua (e.g. the SIGXCPU) into an exit
status of 128+signum.
To avoid proc_close()'s broken return value while also avoiding the
race, we can loop on proc_get_status() until $status['running'] is
false.
To have signals that kill Lua actually be interpreted as signals, we
have two options: add an "exec" in front of the command so proc_open()'s
/bin/sh -c is execed away, or detect shell-style signal reporting and
convert it. We may as well do both.
Bug: T128048
Change-Id: I8a62e1660fe1694e9ba5de77d01960c1ab4580aa
When investigating a test failure on T155600 I found the title
'scribuntotitletest:Module:TestFramework' to be rather obscure. Had to
browse the code to findout 'scribuntotitletest' is an interwiki prefix.
Update TitleLibraryTest php/lua and change the interwiki prefix to the
more meaningful 'interwikiprefix'.
Bug: T155600
Change-Id: Iec63734c82b0835a7f2444ea9af35617876831d5
https://www.mediawiki.org/wiki/Extension:Scribunto says that master
requires 1.25+, so let's remove checks for stuff that was added before
that.
* PPFrame::getTTL() was in 1.24.
* PPFrame::setTTL() was in 1.24.
* PPFrame::isVolatile() was in 1.24.
* Parser::fetchCurrentRevisionOfTitle() was in 1.24.
* ObjectCache::getLocalServerInstance() was added in 1.27, so restore the call to ObjectCache::newAccelerator() as BC.
This also removes BC with the php-luasandbox extension older than 1.6, which
was released before MediaWiki 1.22.
Bug: T148012
Change-Id: I36e37f3b65d0f167e1d28b00e0842d9721feee31
An empty pattern isn't "safe" since it could match in between the
bytes of a UTF-8 character.
Also, it turns out there's a bug in PHP <5.6.9 preg_replace() that we
need to work around too.
Change-Id: I282e5909e4663461d60c5386693db182de2fd44c