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
Provide ResultWrapper::count() as an alias for numRows(), and implement
Countable, so that you can do count($res).
Change-Id: Id9909f7143dae623b318b2fb24205c3e58a7d178
ParserOptions store the result of ParserOptionsRegister
hook execution in a static cache. If we register a lazy
option, which depends on user options and use OptionsLookup,
tests break because a lookup from a destroyed service container
ends up being reused between tests.
The reset was added to resetLegacyGlobals because 1) it's
called at all the right times 2) this static cache is legacy,
when we have a factory service for ParserOptions, this will
not be needed anymore.
Change-Id: I9e820045443be1df2c89e1ed4b56f0d55662c486
Removing this deprecated cache allows LanguageFactory
to start using MapCacheLRU instead of implementing
LRU semantics manually.
Change-Id: I8093067fb6f51110351b8592fcbcfa7559d942ee
Results in passing a user where previously the fallback
to $wgUser was being used, mostly in tests.
Bug: T255507
Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
AuthManager has been converted to a service in 1.35.
AuthManager::$instance is only used in AuthManager::resetCache(),
where it is set to null.
This patch also removes AuthManager::resetCache() because with
removing AuthManager::$instance AuthManager::resetCache() has no
longer any effect.
Change-Id: I8b27f9a2d0d3f7acec6b93f64f9c256084990026
This option has been dysfunctional since at least MW 1.32: with
the option set, no tables would be cloned, and all tests trying to
access the database would fail.
Apparently the option was originally introduced to improve speed
when testing against a Oracle database backend in
5933586266.
Since nobody complained about the option being broken,
and we no longer support Oracle, it should just be removed.
Bug: T283146
Change-Id: I7d7f10b2c863ab92279c7817893086ad50e6ac4d
Use was removed in I7dc3fe90385c8066b89a5e06c55f5455edfbb4ca
when the logic that was using it was moved to MediaWikiTestCaseTrait
Change-Id: I3be7fdb0ad3e76d0f0bff713c21cb9216b77ee20
This replaces JobQueueGroup::singleton and ::destroySingletons.
A JobQueueGroup service has been added to serve as convenience
getter.
Bug: T277648
Change-Id: Ic8709119773ab788a07531193dc65d418536eda2
Have MySQL emulate PostgreSQL's standards-compliant GROUP BY
nitpicking, so that MySQL developers can tell whether queries would fail
on PostgreSQL.
Bug: T281329
Change-Id: Ia9e6c6ad3286dd37f7efb55045e8556d85791c37
JobRunner catches all exceptions and hides them in the status array,
meaning that it is not obvious when a job fails during a test case.
So, introduce MediaWikiIntegrationTestCase::runJobs(), which runs jobs
and asserts various things about the returned status array.
Depends-On: I4f4790c5d16a0767790eeff202e0be8fcdaeda93
Depends-On: I118f9e3f8950fd82d7b02baed6705b29fd6ab7d5
Change-Id: I63603aa158f77df4b40add096cb248f3b24979f4
This logic is not needed to run on every PHP process and was making
it difficult to run offline maintenance scripts without additional
complexity based on Maintenance::getDbType and DB_NONE.
Instead of skipping this only for DB_NONE, and establishing a pattern
that may spread to other ad-hoc places throughout the codebase, instead
remove this entirely from the eager set up code for all PHP processes
and move it to the service wiring and dependency injection.
That way, it naturally doesn't happen until and unless the DB service
is actually called upon. Scripts and entry point that need to disable
the DB service, can continue to use
MediaWikiServices::disableStorageBackend.
== Impact on SiteStatsUpdate ==
With wgCommandLineMode no longer being read at run-time from a global,
but in service wiring, this means SiteStatsUpdateTest can't change
the behaviour between CLI-like and Web-like, unless it e.g. resets
the 'DBLoadBalancerFactory' service first. Unfortunately, while most
any reset is supported, a reset of the 'DBLoadBalancerFactory' would
be unsupported as that would lose the temporary db clone context and
such, bringing us to either the developer's live db, or a broken set
up altogether. If there is a strong need for toggling oppertunistic
updates off and on at run-time, this could be supported in the
DeferredUpdates class perhaps, but we already have numerous methods
there (incl db begin/commit being a good proxy already), which this
test already used, so for now I've just removed the extra assertion
for this as it wasn't essential to that test.
Bug: T228895
Bug: T238436
Change-Id: Icf29bc484c155f52b6d8f61e5902233a15ba0c6d
Set functions to final.
This avoids that the function is overwritten without parent call
Follows-up I9d4771c28160356ff58.
Change-Id: I40cde489a892b06284692ecbbef14e650afe7c9e
Discovered in another patch that while integration
tests automatically reset fake timestamps afterwards,
unit tests don't. Add a shared method to MediaWikiTestCaseTrait
to reset for both integration tests and unit tests
Do the same for TypeDefTestCase
Change-Id: I677aec4e60894053fc554f2e13b069fb599858f2
No integration needed, though it did rely on
checkPHPExtension which was only available in
MediaWikiIntegrationTestCase, moved to
MediaWikiTestCaseTrait
Also put under /includes/historyblob/ to match covered class
Change-Id: I0bfe3e44bd45535c18f5ee2534430330586a1c4c
Without this, expectDeprecation() will not work if the same
deprecation is emitted in more than one test in the same test suite.
Change-Id: I850a072cc61437d1ab33af082ee99534bc6deee6
Refactor the database setup code to share more code between
ParserTestRunner and MediaWikiIntegrationTestCase. Made
`::setupAllTestDBs` static so it can be reused from
ParserTestRunner.
Made ParserTestRunner::addArticle more like
MediaWikiIntegrationTestCase::addCoreDBData(). Some additional
refactoring work could be done here in the future to share more code.
After the refactoring the ParserTestTables hook is no longer necessary
and so has been (soft) deprecated. MediaWikiIntegrationTestCase
clones all database tables, so ParserTestRunner no longer needs to ask
extensions for a list of specific tables it should clone. Cleaning up
the handful of extensions which define this hook will be left to a
future patch set.
Change-Id: I5124789fac333a664b73b4b4a1e801ecc0a618ca
Also fix two places where we were using `$this->` in a corner case.
Using `static::` lets subclasses override these method definitions,
at least in theory.
Change-Id: I76a6d10ce463a5bc79e14051a31f469668924494
Deprecated since 1.35, not compatible with PHPUnit 8. This could've
happened earlier, but here we go.
Unused in known repos (except for the sniff looking for this usage):
https://codesearch.wmcloud.org/search/?q=assertType%5C(&i=nope&files=php&repos=
Bug: T192167
Change-Id: I479cf71d0941c35096d21686077b4d1cbc4f898d
Some User methods fail if they are called before $wgRequest is
set. But according to the Setup.php comment, it is only set for b/c.
The global request object can be lazy-initialised at any time.
This is sufficient to avoid T263911 (loss/obfuscation of the $wgServer
error message).
In tests, try to keep $wgRequest and RequestContext::$request in sync.
Introduce MediaWikiIntegrationTestCase::setRequest() which sets both at
once, and use that instead of setMwGlobals() or direct assignment.
BlockManagerTest was accidentally exploiting the fact that the global
context request and $wgRequest were separate objects. Making them the
same causes session cookies to appear in the response, breaking the
cookie counts. Use a new response for the test.
Bug: T263911
Bug: T245940
Change-Id: I2be99f7251a837bc6b62be0b152038157dec10f2