In getFulltext the namespace number is converted to text, for NS_USER
this trigger the gender cache. Use canonical namespace instead.
When Title::canExist is called to fill a LinkBatch (Like done for
Special:Log/block via BlockLogFormatter::getPreloadTitles),
the effect of the batch lookup is not the best, because GenderCache
filled with single database queries instead.
This is similar to the usage of makeName in Title::makeTitleSafe
Handle invalid namespace numbers in Title::makeName the same as in
Title::prefix
Change-Id: Ibbdc7e0762568bb29ae59764c3666f275d201c6c
Use this class to track the entry point and handler used for requests,
making it available for use in profiling, stats, and logging code.
This makes it possible for periodic and/or shutdown profiling callbacks
to know the basic action handler that applies to the request (if any).
Metric names can easily include this string along with MW_ENTRY_POINT
to create per-action profiling dashboards.
This info cannot otherwise be acquired from things like excimer stack
traces since the router and handler classes do not appear in the stack
during PRESEND deferred updates and variations like ApiMain/SpecialPage
"inclusion mode" would have to be detected somehow.
Bug: T330810
Change-Id: Icca5a7a343faeeb18652994c96752acb61a61fd1
If you store a WeakMap in the object, containing only circular
references in the values, then nothing is keeping the WeakMap alive and
it can be deleted along with its parent TempFSFile by the garbage
collector.
A WeakMap contains normal references to its values, so those normal
references can be marked by the GC like any other references.
Instead, store the WeakMap as a static property.
Bug: T332461
Bug: T332397
Change-Id: Idbaa1019c2bac3d1dd9b001753c2f4c0aaf66e98
Make it more obviously correct and straight forward, as you want
as little doubt and confusion as possible when debugging a test.
Doubt and confusion from our source code is... enough to make ones
day interesting.
Change-Id: I440be81d4ee7c505c0f2c11af7edaf513b8ff2d7
Enforce underscores as used by the most languages in the namespace
aliases and special page aliases
Change-Id: I53d895f4b1d241954bd31973ad4996beed91bfb2
* ParserTestRunner: LocalisationCache needs to be reset since it has a
reference to LanguageNameUtils which has a copy of
$wgUsePigLatinVariant. Also factor out some
MediaWikiServices::getInstance() calls.
* In some other tests, set the variable.
Change-Id: I6c1e9bfad9790cf805809c28a3f8d45952cbb981
It should be clearer that these pages have special capabilities
than it is currently.
Bug: T311891
Change-Id: Id2114a65635c050a2017926274622f0a3c2d58d6
Skins can choose to provide these values using Codex tokens by importing
one of the Codex themes in their mediawiki.skin.variables.less. To
guarantee that the variables corresponding to Codex tokens always exist,
provide neutral fallback values for all of them in
mediawiki.skin.defaults.less.
To ensure that mediawiki.skin.defaults.less doesn't get out of sync with
Codex when new tokens are added, add a structure test that verifies that
every Codex token has a corresponding default variable. This isn't an
ideal system, and we'll be able to handle this better once Codex has a
real theme system (T286689) and we can upstream this set of neutral
values into Codex itself.
For now, keep (almost) all existing variables' values the same. This
means overriding some of the values from Codex. We should consider whether
some of these should be changed in a follow-up patch. The only values
changed in this patch are:
- @max-width-breakpoint-tablet from calc(719px) to 719px (no visual
impact; but we should consider changing this to 1119px which is what
it is in Codex)
Bug: T325237
Change-Id: I04f9e48a1cf9dee915cf51e1e12b17ff0a595a06
The existing MockMessageLocalizer can't be used in unit tests because it
uses real Message objects that make a number of database calls via
services.
Codewise, this is based on \ListToggleTest::testGetHTML and
\EntitySchema\MediaWiki\SpecificLanguageMessageLocalizer.
It came out from the conversation on I4122bc8b2
Change-Id: I5297e4c43495b7e959798a21929f6d24d0b4b466
Split concepts of "match pattern" and "reserved pattern". Add config
"reservedPattern" which specifies a username pattern to be denied for
creation, but unlike matchPattern, it does not immediately flag all
accounts with such names as temp accounts. This can be used before
migration or after rollback to safely prevent creation of conflicting
accounts.
* Add TempUserConfig::isTempName(), which does what isReservedName()
previously did, i.e. determines if a name is a temp username.
* Make TempUserConfig::isReservedName() return true if the name matches
either the match pattern or the reserved pattern.
* UserNameUtils::isTemp() continues to determine whether a username is
actually a temp username.
* Add UserNameUtils::isTempReserved() as a proxy for
TempUserConfig::isReservedName()
Bug: T307064
Change-Id: I26755731fad89530a06824181106cd7b4e077d9e
The page/html endpoint should only return an ETag if stashing was
requested. Otherwise, the ETag is meaningless.
Bug: T331629
Change-Id: I55d7c5e33ef7275695ee93e2937da1a998e2eda3
If possible, load the script file before running Setup.php. This way,
script files can control the setup process by defining constants. This
is needed by scome scripts, namely:
- instal.php, to override config loading by defining MW_CONFIG_CALLBACK
- generateConfigSchema.php, for setting MW_USE_CONFIG_SCHEMA_CLASS
- mergeMessageFileList.php, for setting MW_NO_EXTENSION_MESSAGES
- shell.php, for setting MW_NO_SESSION
Note that this will not work for scripts defined in extensions.
In order to allow script files to be loaded based on class name,
AutoLoader.php is included before Setup.php is run.
This is a modified version of I638f99c3cc6f8ab8216bd65ada959a6a11ff454b.
Co-authored-by: PleaseStand <pleasestand@live.com>
Change-Id: I2bf3b91c0a7162413cd1392252cb4f29a0d3d594
Combine the good/bad MapCacheLRU instances and use class constants
for row/flag keys of entry arrays. Treat query flags the same way
for missing/existing link entries.
Discourage the use of READ_LATEST via code comments.
Simplify fetchPageRow() given that page_touched is already part
of getSelectFields().
Avoid method call overhead for getGoodLinkFieldObj() type casting.
Create getPersistentCacheKey() method to avoid duplication.
Change-Id: I8701466650fd4988de2fa5aba02d64eac7bd6c1a
Allow clients to use an If-Match header with the
transform/html/to/wikitext endpoint.
This follows up on Ida81a314f015e205f2081c68a82d486145097c92
(reverted and reapplied)
It adds support for stashing in wt2html, enabling it for Parsoid's
page/html endpoint. It also ensures we are only emitting ETags if
stashing is enabled.
This also removes handling for use-stash from ParsoidHandler,
which did nothing.
Bug: T310464
Bug: T331629
Needed-By: I08f1388faaccef6c1d9a393f8011011d30a25ec7
Change-Id: I9d6eaf45d5b4978afc17493720777e77f0e645b2
It is very easy for developers and maintainers to mix up "internal
MediaWiki language codes" and "BCP-47 language codes"; the latter are
standards-compliant and used in web protocols like HTTP, HTML, and
SVG; but much of WMF production is very dependent on historical codes
used by MediaWiki which in some cases predate the IANA standardized
name for the language in question.
Phan and other static checking tools aren't much help distinguishing
BCP-47 from internal codes when both are represented with the PHP
string type, so the wikimedia/bcp-47-code package introduced a very
lightweight wrapper type in order to uniquely identify BCP-47 codes.
Language implements Bcp47Code, and LanguageFactory::getLanguage() is
an easy way to convert (or downcast) between Bcp47Code and Language
objects.
This patch updates the Parsoid integration code and the associated
REST handlers to use Bcp47Code in APIs so that the standalone Parsoid
library does not need to know anything about MediaWiki-internal codes.
The principle has been, first, to try to convert a string to a
Bcp47Code as soon as possible and as close to the original input as
possible, so it is easy to see *why* a given string is a BCP-47 code
(usually, because it is coming from HTTP/HTML/etc) and we're not stuck
deep inside some method trying to figure out where a string we're
given is coming from and therefore what sort of string code it might
be. Second, we've added explicit compatibility code to accept
MediaWiki internal codes and convert them to Bcp47Code for backward
compatibility with existing clients, using the @internal
LanguageCode::normalizeNonstandardCodeAndWarn() method. The intention
is to gradually remove these backward compatibility thunks and replace
them with HTTP 400 errors or wfDeprecated messages in order to
identify and repair callers who are incorrectly using
non-standard-compliant language codes in web standards
(HTTP/HTML/SVG/etc).
Finally, maintaining a code as a Bcp47Code and not immediately
converting to Language helps us delay or even avoid full loading of a
Language object in some cases, which is another reason to occasionally
push Bcp47Code (instead of Language) down the call stack.
Bug: T327379
Depends-On: I830867d58f8962d6a57be16ce3735e8384f9ac1c
Change-Id: I982e0df706a633b05dcc02b5220b737c19adc401
The Parsoid entrypoints should always have a "real" ParserOutput
passed as the ContentMetadataCollector object, so that recursive
invocations of extensions, etc, can set appropriate metadata
properties in the ParserOutput.
This is part of a belt-and-suspenders fix for T331084, where a
StubMetadataCollector is being used in production -- production should
never use a stub, it should always use a real ParserOutput object.
The other fix for T331084 is
I30ea2bb24e6c9b0950a8f46dc8e5b9bf5ee3378b, which ensures that if you
*were* to use a StubMetadataCollector in production, it wouldn't throw
an error when a numeric category string was encountered.
Bug: T331084
Change-Id: I8711a51fc1bcac48eae92ab1ba15a33fe05937ed
Use server names to handle the case where server indexes get
shifted around due to the depooling or provisioning of a server.
Previously, loads could be assigned to a wrong server, assigned
to a server that was depooled, or assigned to a server that is
to new to appear in the current "servers" array. This would mean
that getReaderIndex() or getLagTimes() could trigger exceptions.
Only change loads for depooled servers. Update the loads of other
servers to the current loads only makes sense in the context of
using all the current servers. This does not apply to reconfigure()
since it does not see newly pooled servers (for simplicity).
Handle servers depooled only from custom query groups.
Bug: T322156
Change-Id: I9f710aa32f5d5b74796bb80a8426a5f653b8e4d3
There was no clean way to do this but using the global state.
The parameter is three-state to keep backward compatibility.
Bug: T304428
Change-Id: I01c5f8e9646cbe861516100c3b8d165aefb95ca0
* Use IConnectionProvider
* Inject services into the job
* Use JobSpecification to avoid unnecessary service construction
Bug: T27482
Change-Id: I75ac8c53b874742a3a54526692767d0f549e5259
Provide a way for backend code to determine the primary language of a
ParserOutput, eg for setting the Content-Language header of an API
response.
This is read-only and backed by extension data at the moment for
transition purposes; if this API sticks we'll graduate it to a
"real" property in the future, with appropriate serialization
to/from JSON (T303329).
Similarly, this patch only includes the most basic code to handle
the various ParserOutput merge cases in
ParserOutput::merge{Internal,Html,Tracking}MetaDataFrom(),
ParserOutput::collectMetadata(), and
OutputPage::addParserOutput{Content,Metadata,Text,}(); mostly
inherited from the fact that the storage is backed by extension
data at the moment.
Generally only the "top-level" parser output gets to set the
primary language; we'll presumably need to ensure that the
language is consistent during merge.
Change-Id: I767daba22805a877d9b806fd77334e508902844b
Language::commafy and mw.language.commafy have been deprecated in
4bc5c761 included in MW 1.36.
Bug: T331708
Change-Id: I874c2c904fa4a7f04486113d1d92709c21d1f5bb
* Split up SpecialRenameuser::execute() into several smaller methods
* Some style and consistency tweaks: camel case variable names etc.
* Use $oldName instead of $oldTitle->getText() -- the title was
created without validation, so these are definitely the same.
* Use conversion to boolean instead of is_object().
* Don't bother calling UserNameUtils::isCreatable(). We already asked
for RIGOR_CREATABLE in newFromName which causes a call to the same
method. The error message is the same either way.
* Use SelectQueryBuilder.
* Remove unused method showLogExtract().
Bug: T27482
Change-Id: Ic5d394a9a386695c5684028c38268a4d5262ca69
* Use dependency injection or centralize access to the service
container.
* Remove code from RenameUserJob which was obsoleted by the actor table
migration. This job class is not used to update revision or logging
anymore.
Bug: T27482
Change-Id: I2bbea713f4c68a15e22e5c3f64d8decbd0b0a9de
A naive reading of the SrConverter code might lead one to believe that
final roman numerals aren't properly handled -- but split actually
returns an empty string in the trailing position in that case, so the
code works correctly. Add a test case demonstrating that conversion
is handled correctly for initial and final roman numerals.
Change-Id: Ia4857cab74bbb581baf46a51a080cf098cbb61d8
We currently output 50 slow tests in integration test runs. I'm not sure
if anyone is taking action based on this report, but if so, it seems
like reporting the top 10 (or even fewer, top 5?) would be sufficient.
Change-Id: Id2eed09e404a00090671bc67271d35be5c93fdf3
$wgHooks should be treated like a regular setting, which cannot be
manipulated after bootstrapping is complete. This will allow us to
greatly simplify the logic in HookContainer.
Replacing $wgHooks with a fake array after bootstrapping allows us to
detect any remaining live access to $wgHooks without breaking
functionality.
The plan is to have the fake array emit deprecation warnings in the 1.40
release, and make it throw exceptions in later releases.
See Iddcb760cf8961316d6527e81b9aa968657d8354c for the deprecation
warnings.
Bug: T331602
Change-Id: I0ebba9a29f81b0d86ad8fd84d478fb244f9e9c15
Prepare phpunit tests for a world where $wgHooks behaves like other
config variables: on-the-fly manipulation doesn't have an effect,
service objects need to be reset after changing it.
Change-Id: I34385f4c52febfe1c91bd7ea4100c06d1331adc8
We always wrap the local cluster cache, and there are no subclasses
of WANObjectCache. It was never documented or recommended how these
would be used. It is a left-over from the original 2015 Multi-DC plan
in which WANObjectCache would work differently. See task for details.
Note that this requires no configuration changes, even in the
theoretical case of these variables being used, as the only
option is to use the main cache, and that's also the default.
* Update WAN overrides to override the underlying main cache
instead.
* Fix EditPageTest which was previously implicitly using a 'hash'
as main cache but also relying on wan cache to be 'none'.
The part that it actually needs is the 'none'. When WAN cache is
enabled, testUpdateNoMinor fails due to an edit conflict because
one of the edits it makes is made with a current timestamp whereas
it expects to simulate wpEdittime in the year 2012 which, when
caching is enabled, is ignored and becomes the current time instead.
I don't understand exactly why, but I'm going to conserve that
behaviour for now.
* Fix TemplateCategoriesTest, which was failing due to an unexpected
cache hit:
> [objectcache] fetchOrRegenerate(…:page:10:…): volatile hit
This could be solved in a more realistic way by splitting the test,
or by explicitly resetting services half-way the test to clear
WikiPageFactory, PageStore and WANCache process state.
For now, keep the prior behaviour of no cache in this test.
Bug: T305093
Bug: T329680
Depends-On: If890622eed0d0f8b4bd73d36ba1815a3d760ea05
Depends-On: Ie1def75208822bdf19bb2cfd7e6edf32c2000e6b
Depends-On: I35cce61dc3ee90dcee3dd6f0b36f84133be029ed
Change-Id: I53781a8c06ebb2583f6ca83dd91bbfe8a5c88b13
SelectQueryBuilder::lockForUpdate() is confusable with a mutator that
enables for update mode, by analogy with lockInShareMode().
IDatabase::lockForUpdate() is a nice shortcut but the name is confusing
when the return value is used.
So,
* Deprecate SelectQueryBuilder::lockForUpdate()
* Add SelectQueryBuilder::acquireRowLocks(), which performs the query
but throws away the results.
* Migrate callers of IDatabase::lockForUpdate() to SelectQueryBuilder.
Change-Id: I3f18e9c48349838dcf0ba00a5beb67eace3029e1