If the default is not set for a lazy loaded option,
canonical parser output key ends up being 'lazy_option=default',
because when computing the keys we exclude defaults.
If on the other hand we register a default for a lazy option,
it does not get loaded, since in lazyLoadOption we believe
the default is already the loaded value.
Change-Id: I92b3e18fabef4eecac2ec2a4844f1be2716e5d89
Needed-By: I3bce04684070ad306685dabbc51267def25773cd
No need to manually reset MWTimestamp fake time,
MediaWikiTestCaseTrait::fakeTimestampTearDown() does
that after all tests anyway.
Change-Id: Ie45e837c693d7f21b6c7e25471cdaad6f60a3de9
ParserOptions::__construct() and ::newCanonical()
no longer accept null and fallback to the global
$wgUser - instead, ::__construct() has a typehint
for a UserIdentity, and ::newCanonical() will throw
an exception.
Bug: T284977
Change-Id: I35865e160190582ab10abaa696c6fc6686cc8989
Ended up using
grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g'
special-casing setMethods( null ) -> onlyMethods( [] )
and then manual fix of failing test (from PS2 onwards).
Bug: T278010
Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
Code that needs to store an actor ID in the database to
represent a UserIdentity, or needs to construct a UserIdentity based on
an actor ID loaded from the database, should use the ActorNormalization
service.
Note: The getActorId() method is removed from the UserIdentity interface,
but all concrete classes continue to support it for now.
UsererIdentityValue::getActorId() is hard deprecated and should
be removed in 1.37. It always returns 0.
User::getActorId() is not deprecated at this point.
Bug: T274179
Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237
Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
CachedBagOStuff caches negatives, so it breaks PoolCounter.
We only need to cache metadata in-process, since it's commonly
used twice within the request.
Bug: T277829
Change-Id: I11a147c24b6cdb275b521b48802d6f3d0e1a4387
ParserOptions not updated cause they depend on Title::getLanguage
implementation.
Tests converted to not require a DB anymore. Can't be proper unit
tests yet due to globals in ParserOptions and fake time hacks,
but exec time does go down from 70 seconds to 9 seconds.
Page content model is still emitted in the metrics since
it was considered useful. Should be removed when we get
something like a page type concept.
Change-Id: Ib16fd0b5b87ffc3cb4d21f4aa43d1203cb7206d2
We can't avoid this entirely where we're testing upstream features
that are yet to be renamed, but this is a start.
Bug:T277986
Change-Id: I5c1ae717cc008ca147ea31fe35c44b19d1fe5d98
We still need a lot of refactoring in ParserOptions
constructions, but for now converting the public interface
should be enough.
Change-Id: I04663c39ca037129b827b33555c3f59def5f9b59
testSubjectpagename was probably copied from
testTalkpagename and so uses the wrong data provider
and tests the wrong code
Change-Id: Ied4023a8fdd57a1c2b538eca6034c37e94967bc7
Providing a PageIdentity to getRevisionById removes the need
to look up page related data, and to construct a Title.
Bug: T275531
Bug: T273284
Depends-On: I8d0dc30ecd0c0c65c337170d271c2e2531914686
Change-Id: I683362ccd669acf2aadf56853afeb1ca6dee6f8c
Initializing the preprocessor in the constructor allows better
dependency injection, and removes code complexity caused by
lazy initialization. Any use of the parser is going to end
up creating the preprocessor in any case, so deferring the
initialization doesn't save any performance. (Best performance
is given by not creating the Parser in the first place if it
is not needed, which is what DI allows.)
Old code tried to unbreak cyclic dependencies by setting the
preprocessor to null. This is somewhat of a lost cause,
since there are a number of other cyclic dependencies
involving the parser, including StripState, LinkHolders,
etc. The code complexity is not worth it, given how
ineffective it is in any case.
This is part of T275160 in so far as it allows
Parser::getPreprocessor() to be a simple getter, and thus
(once this patch is merged) we can safely replace any
direct access to Parser::$mPreprocessor with a call to
Parser::getPreprocessor().
Bug: T275160
Change-Id: I38c6fe7d5a97badffdbf34d8b9d725756ed86514
A number of different argument variants were deprecated in 1.34,
and direct calls to the Parser constructor were deprecated at the
same time (a ParserFactory should be used instead). These were
hard-deprecated in 1.35. They should be safe to remove now.
Code search:
https://codesearch.wmcloud.org/deployed/?q=new%20Parser%5C%28&i=nope&files=%5C.php%24&excludeFiles=&repos=
Bug: T236811
Change-Id: I58f7b3ba1b1d62851b2db71197a8d9129e8d473d
Instead of refusing to run MediaWiki at all, just fix the test which
fails on 7.4.3.
* Add ParserOptions::clearStaticCache(), which resets static cached
values back to their pre-hook values.
* Add accessors for these private static variables to protect against
access before initialisation.
* Rename "inCache" to "cacheVaryingOptionsHash" for clarity.
* In ParserOptions::match(), filter static properties by detecting them
with ReflectionProperty, instead of making a big list of them.
* Update ParserOptionsTest for the fact that stubthreshold is no longer
a cache-varying option. This was hidden by
ParserOptionsTest::clearCache() injecting the wrong array into
ParserOptions.
Bug: T270228
Change-Id: I6b5ba022e1b889a10f9fbe93da63da9831504df8
This also means we don't need to take special care for French spacing in
attributes, since it's no longer applied there.
Adds a test that captures this change.
Note that the test "Nowiki and french spacing" wonders whether this
escaping should be applied to nowiki content.
Bug: T255007
Change-Id: Ic8965e81882d7cf024bdced437f684064a30ac86
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.
Created by I25a17fb22b6b669e817317a0f45051ae9c608208
Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
As we convert the RevisionRecord to using Authority,
we no longer need Title instances, so we can convert
that to PageIdentity.
Ideally, we'd part away from using Title at all, but:
1. For foreign wikis PageIdentity has stronger validation,
so calling PageIdentity getId() on Title will break things.
There's still a lot of code depending on lax Title guarantees,
so we keep it.
2. A lot of code still depends on Title, so we try to pass it
through even if we don't nesessarily need to, to save cost
on recreating it later on.
Bug: T271458
Depends-On: I287400b967b467ea18bebbb579e881a785a19158
Change-Id: I63d9807264d7e2295afef51fc9d982447f92fcbd
Make the caching logic use getWithSetCallback() and simplify
the code given that there is only one Preprocessor subclass.
Also, keep the cached values JSON serializable but rely on
the serialization in BagOStuff instead for simplicity.
Add related class constants for injecting preprocessor flags.
Bug: T254608
Change-Id: I72f9f0c0bc352ed5120469090c71294ff0c24999
* parent::setUp() should be first, and ::tearDown()
should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
to /unit
Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
Emit deprecation notices in the constructor
if falling back to $wgUser, and fix core
calls
Bug: T246861
Depends-On: I51117931d527a3bdda468b48de577a7faafbcd69
Change-Id: Ibd0a8ffd0494c17a378cc43e6b6164166130adf4