Commit graph

9783 commits

Author SHA1 Message Date
Universal Omega
e20793255d checkStorage: pass no parameters to WikiRevision::getContent()
This defaults to SlotRecord::MAIN, which is what it should be rather than RevisionRecord::RAW

Bug: T294043
Change-Id: Ib035fe4eea778747f47a476c8aa2cfaab44aa7d8
2021-10-24 11:47:32 +00:00
Reedy
c5134d9c39 CheckStorage: Annotate importRevision $revision parameter as being WikiRevision
Change-Id: Ic07cd955a3a25a70db2a1589a57d19a592813986
2021-10-21 21:03:35 +01:00
Universal Omega
328257bf72 Fix checkStorage.php
Fixes checkStorage.php --fix

* importRevision() is required to be public for WikiImporter::setRevisionCallback()
* $revision must not be passed by reference
* $importer is unused, so removed

Change-Id: I53ef3825308af3b6e632cb88b9a3eb2f40ab5239
2021-10-21 06:57:39 +00:00
jenkins-bot
e875b742e2 Merge "HistoryBlobStub: add getLocation() to get $mOldId" 2021-10-20 18:42:25 +00:00
Roman Stolar
fa5237eb48 Replace Content::getParserOutput call to ContentRenderer::getParserOutput
Bug: T287158
Change-Id: I8a13f45027e08e2d8ddefa140dd47a0c55094934
2021-10-20 12:11:24 +03:00
Universal Omega
2708a82ea0 HistoryBlobStub: add getLocation() to get $mOldId
For use in the checkStorage and resolveStubs maintenance scripts, in order to fix them.

Follows-Up: Id1f530c2c8ec1171615f726dc7446431ee7ca8fe
Change-Id: Iade3d1660f2b7db62f829f5e5ca94372614ae7e5
2021-10-19 18:23:30 +00:00
Gergő Tisza
d3004df478
importDump.php: handle fopen error
Bug: T293569
Change-Id: I13c05d754513f01f6a3f293d299cb9d55cc19265
2021-10-17 21:34:41 -07:00
jenkins-bot
fb67fdbe14 Merge "namespaceDupes.php: Handle invalid titles" 2021-10-16 12:48:58 +00:00
Gergő Tisza
551e7448ca namespaceDupes.php: Handle invalid titles
Apply prefix and suffix to invalid titles just like it's applied
to conflicting titles. (Typically this will be needed when the
Foo namespace is created and there is a Foo: article already.)

Also remove a broken for loop. Presumably the intent was to
repeatedly add prefix/suffix on conflict, but actually it would
just get into an infinite loop. The behavior doesn't seem that
useful anyway.

Bug: T293407
Change-Id: Ieef6698b461e7db003dc326e5cd82accd2909540
2021-10-16 12:26:24 +00:00
Timo Tijhof
df32228920 profiler: Remove dependency on WebRequest from Profiler
I intent to remove Profiler::getContext/setContext after a week
without deprecation. I consider these methods as internal (they
predate the stable interface policy, and we forgot to triage this
class, it has neither `@stable` nor `@internal`).

The hard-deprecation in this commit is to detect any use that may
have gone unnoticed in WMF production from Codesearch analysis alone,
where no usage was found.

Bug: T292269
Change-Id: Id40679f21cc7a3f77a1b96a4bbd55daeaea16892
2021-10-09 03:00:45 +00:00
jenkins-bot
ec3ab502f9 Merge "Convert TrackingCategories to a service with DI" 2021-10-09 00:19:26 +00:00
jenkins-bot
885d99fcb9 Merge "Remove unimplemented "bogus" parts of CleanupPreferences" 2021-10-08 20:37:47 +00:00
DannyS712
b9663bed45 Convert TrackingCategories to a service with DI
Bug: T247194
Change-Id: I50012e2a5e65aeee7671023d2fd5367e21e8ae67
2021-10-08 16:36:20 -04:00
jenkins-bot
ba8a7b16fe Merge "Deprecate wfLogProfilingData(), improve statsd/profiling docs" 2021-10-07 14:53:49 +00:00
Petr Pchelko
756eefa6bf uppercaseTitlesForUnicodeTransition: improve userlist format
This script is used to rename things to prepare for unicode
update. The script does not rename the users, instead it generates
a list of users to be renamed with renameInvalidUsernames.php,
but this script output is incompatible with the other script input.
It would be more convinient to be able to directly feed the result
of this script as input to the other script.

renameInvalidUsernames.php expects input as TSV with domain, user_id,
new_user_name. That's what we want to output. Also opening the
output file in append mode is more convenient - that way we can
collect all usernames for renames for all wikis when running
the script with foreachwiki

Bug: T219279
Change-Id: I27e182247d55c635e75027065546285be74934b6
2021-10-04 14:56:01 -07:00
Timo Tijhof
c49a45f6bf Deprecate wfLogProfilingData(), improve statsd/profiling docs
* Document that Maintenance::shutdown is the CLI equivalent of
  MediaWiki::restInPeace.

* Centrally document in the emitStats method why we flush stats
  regularly, and clarify that these OOM concerns are specific to
  CLI processes there. That isn't to say it could never happen on a
  web request, but all our early flush handling (even DB trx hooks)
  are explicitly limited to command-line mode today and always have
  been.

* Ref T253547. It is now clear why --profiler=text doesn't work on
  the CLI (it is missing the non-external profiler output handling),
  which I'll fix in a follow-up.

* Ref T292269. The WebRequest-dependency in Profiler is now much more
  clearly problematic. Previously this was masked by wfLogProfilingData
  effectively silencing the warning on the CLI without it being so
  obviously wrong. I'll fix that in a follow-up.

* Ref T292253. All this is already post-send, and flame graphs confirm
  that we don't have any calls to emitBufferedStatsdData nor
  StatsdClient::send apart from the post-send one via restInPeace.

Bug: T253547
Bug: T292269
Bug: T292253
Change-Id: If78c37046cf8651c7a8d6690e01d38c3ca29d8d8
2021-10-02 23:23:01 +01:00
Umherirrender
ceceb2242f Remove unimplemented "bogus" parts of CleanupPreferences
Change-Id: I50b5a1bfde6f132b449eda9576ba163f1301ca13
2021-09-29 18:47:01 +02:00
jenkins-bot
ff04006810 Merge "Bump minimum required version for upgrade to 1.29" 2021-09-29 07:43:48 +00:00
Tim Starling
f7f84dddb3 Introduce CommentFormatter
CommentParser:

* Move comment formatting backend from Linker to a CommentParser service.
  Allow link existence and file existence to be batched.
* Rename $local to $samePage since I think that is clearer.
* Rename $title to $selfLinkTarget since it was unclear what the title
  was used for.
* Rename the "autocomment" concept to "section link" in public
  interfaces, although the old term remains in CSS classes.
* Keep unsafe HTML pass-through in separate "unsafe" methods, for easier
  static analysis and code review.

CommentFormatter:

* Add CommentFormatter and RowCommentFormatter services as a usable
  frontend for comment batches, and to replace the Linker static methods.
* Provide fluent and parametric interfaces.

Linker:

* Remove Linker::makeCommentLink() without deprecation -- nothing calls
  it and it is obviously an internal helper.
* Soft-deprecate Linker methods formatComment(), formatLinksInComment(),
  commentBlock() and revComment().

Caller migration:

* CommentFormatter single: Linker, RollbackAction, ApiComparePages,
  ApiParse
* CommentFormatter parametric batch: ImageHistoryPseudoPager
* CommentFormatter fluent batch: ApiQueryFilearchive
* RowCommentFormatter sequential: History feed, BlocklistPager,
  ProtectedPagesPager, ApiQueryProtectedTitles
* RowCommentFormatter with index: ChangesFeed, ChangesList,
  ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryRecentChanges
* RevisionCommentBatch: HistoryPager, ContribsPager

Bug: T285917
Change-Id: Ia3fd50a4a13138ba5003d884962da24746d562d0
2021-09-28 11:13:03 -07:00
Amir Sarabadani
753a4ecdd3 Bump minimum required version for upgrade to 1.29
Since the branch cut has happened, we can bump and get rid of legacy
cruft. According to the policy we can go up to 1.31 but let's keep it
that way to avoid major distruptions.

Change-Id: I9d697445a3bb5047726c8b2a7f808edb8403cdda
2021-09-28 17:57:57 +02:00
jenkins-bot
f253e8f4cb Merge "Use 0 instead of "" in phpCharToUpper.json" 2021-09-28 10:21:07 +00:00
jenkins-bot
39c546d706 Merge "Change 'fromdbmaster' to WikiPage::READ_LATEST" 2021-09-27 22:44:26 +00:00
Samuel Guebo
a8db81dc71 Add script to delete a user email's address
Can be used for a variety of operations
including preservation of users privacy.

Bug: T290099
Change-Id: Iad75810310c95e96b5f8998b201ed04ace5af656
2021-09-27 18:02:11 +00:00
jenkins-bot
07f3f8053b Merge "UndeletePage cleanup, part 1" 2021-09-27 14:24:53 +00:00
jenkins-bot
5c570f46da Merge "Move code from PageArchive to a new UndeletePage command" 2021-09-27 14:22:05 +00:00
Umherirrender
0e4bb6d611 Change 'fromdbmaster' to WikiPage::READ_LATEST
Constants are harder to misspell

Change-Id: Ie1afcc8580cccf815df1cc97f05a5be81676d9f7
2021-09-26 19:27:33 +00:00
jenkins-bot
a6e125c109 Merge "Chinese Conversion Table Update 2021-2" 2021-09-25 18:11:37 +00:00
Umherirrender
769bdbf091 docs: Fix nullable documentation for class properties
Change-Id: I6d0577124d852103f485ffdc819876a13f6641c3
2021-09-24 00:54:53 +00:00
Reedy
62181c53ac sql.php: Fix typos
Change-Id: I8de1d70039390a3e204dddac9d445187b4bf554d
2021-09-23 23:12:28 +00:00
Fomafix
b28b79ddb9 Use 0 instead of "" in phpCharToUpper.json
Use 0 instead of "" to signal an unchanged character. 0 is only one
character and "" are two characters. This reduces the uncompressed size
of the JSON file by 770 byte.

Change-Id: Ibb6d2d1d9af712ad73733d3179fb82751028e054
2021-09-23 05:56:42 +00:00
Daimona Eaytoy
c0f64981bf UndeletePage cleanup, part 1
Bug: T290021
Change-Id: Idaf25a209a65b9a36a0a24473c76523ee3a17e8d
2021-09-21 18:13:57 +02:00
Daimona Eaytoy
beadd4454f Move code from PageArchive to a new UndeletePage command
This is just moving code verbatim, removing now-unneeded stuff, and
duplicating tests as well.

Bug: T290021
Change-Id: I540ddaaa11dfabcf0b87b608b151b5e34d199fd8
2021-09-21 16:11:29 +00:00
Chiefwei
d1989b857f Chinese Conversion Table Update 2021-2
Update the Chinese conversion table routinely to fix bugs reported at
https://zh.wikipedia.org/wiki/Wikipedia:字词转换/修复请求.

It is only data changes and only works for Chinese WikiProjects.

Change-Id: I14fc68ae8f6792e24127aaa93f6fe7aa1f786a26
2021-09-20 12:31:57 +08:00
jenkins-bot
bdd87c9753 Merge "objectcache: Avoid getCurrentTime() call in MapCacheLRU::has()" 2021-09-17 14:39:01 +00:00
jenkins-bot
76ba780e41 Merge "WikiExporter: inject services" 2021-09-16 17:04:04 +00:00
DannyS712
a2b20b63d7 Emit deprecation warnings reading from $wgUser
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
2021-09-15 20:17:04 -07:00
Timo Tijhof
5873c937d2 objectcache: Avoid getCurrentTime() call in MapCacheLRU::has()
== Background

During a parse request [1] for a popular Wikipedia article, there
are 180,949 calls to MapCacheLRU::has and 188,542 calls to
::getCurrentTime via ::getAge. (Note, getCurrentTime has more calls
than ::has, as there are also calls via ::set and ::setField).

In a one-off XHGui profile, these calls had 246ms wall-time or 258ms
cpu-time attributed to them, which is 0.25s of a 12s parse or 2%.

In a day's worth of index.php samples [2] [3], there is 1.1% cpu-time
or 1.4% wall-time attributed to MapCacheLRU, of which ~0.3% in
getCurrentTime() alone.

== Change

Most uses of MapCacheLRU are without any in-process TTL, and thus have
$maxAge at its default of INF. Avoid calling getAge and getCurrentTime
in that case.

I think long-term it might make sense to deprecate the TTL feature
in MapCacheLRU, as it is very very rarely used, and still adds
significant overhead to all uses MapCacheLRU and its set() code path.
For cases where in-process TTLs are really needed, the HashBagOStuff
class could be used instead. I can't find any complex uses of
get/setFields, let alone with per-sub field TTL, but a theoretical
or third-party use case could potentially use HashBagOStuff with
sub-fields either as their own key, or refactor to put arrays under
a single key and TTL, or re-create it in their own code base if really
needed.

== Difference

I've added a benchmark since generating random values and populating
MapCacheLRU seems non-trivial enough to be worth a re-usable bench.

Using `benchmarkLruHash.php --method get --count 1000`, before:

> MapCacheLRU::get with 500 keys
>    count: 100
>     rate:     28.5/s
>     mean:    35.06ms

... and after:

>   count: 100
>    rate:     35.6/s
>    mean:    28.10ms

[1] POST en.wikipedia.org /w/api.php?action=parse&title=Barack_Obama&text={{:Barack_Obama}}
[2] https://performance.wikimedia.org/arclamp/svgs/daily/2021-09-06.excimer.index.reversed.svgz
[3] https://performance.wikimedia.org/arclamp/svgs/daily/2021-09-06.excimer-wall.index.reversed.svgz

Bug: T275673
Change-Id: Id8c747f0d0a9454274c296090a2ca80e440f97bb
2021-09-10 02:18:00 +00:00
Umherirrender
44fd53fee3 Using @return never documentation on always-throw-function
This helps phan to detect unreachable code and also impossible types
after the functions.
It helps phan to avoid false positives for array keys
when the keys are checked before

Bug: T240141
Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
2021-09-07 17:29:03 +02:00
Umherirrender
07b499fbcf build: Update mediawiki/mediawiki-phan-config to 0.11.0
Addition and remove of suppression needs to be done with the version
update.

Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
2021-09-07 17:19:05 +02:00
jenkins-bot
c574766a8a Merge "Remove unreachable code after exception/die/exit" 2021-09-07 09:15:48 +00:00
Alexander Vorwerk
2fbf13812a WikiExporter: inject services
This patch injects services into WikiExporter. It also adds a
WikiExporterFactory service for creating WikiExporter instances.

Change-Id: Ib1547defea54c309865c116bc83d617c21568843
2021-09-06 10:03:37 +00:00
jenkins-bot
93edb608e1 Merge "renameRestrictions.php: Update protected_titles as well" 2021-09-06 05:41:43 +00:00
Martin Urbanec
3137f9404a renameRestrictions.php: Update protected_titles as well
Restriction names are used in two tables, we should update
both.

Bug: T290398
Change-Id: Ic5e77ee451f12acfd0c69afe9a5c498885ffeaa5
2021-09-05 21:02:18 +02:00
jenkins-bot
1e76c7bfb0 Merge "Remove unneeded variable assignment" 2021-09-04 23:48:21 +00:00
Umherirrender
5b3d3ef802 collation: Create CollationFactory service
Use ObjectFactory specs for collation classes
Avoid the language construction in the factory class,
make it a detail of the implementation of each class

Follow-Up of Ifc96f851e6091ce834dbaf0e91695c648a42169c

Bug: T286079
Change-Id: Ib581f64aec8619986fb8dd49ceee0524d59a1b84
2021-09-04 02:46:06 +02:00
Umherirrender
a7bb7cc5c5 Remove unreachable code after exception/die/exit
Change-Id: Ia81903fb2a8157625fbe63115097eccc1161b5db
2021-09-03 23:14:28 +00:00
Umherirrender
2e4ee47c3d Cleanup mixed space/tab line indent
Change-Id: I833052a656b1ce419c0929f6f0514f2a33c2c4cc
2021-09-04 00:52:31 +02:00
Umherirrender
032b03dc7a Remove unneeded variable assignment
The variable already has the value

Change-Id: I75f25cc944e30d91a65e1d2bb0abce7d671b19b8
2021-09-03 22:51:22 +00:00
James D. Forrester
eeaec4ce6b ExternalStoreDB: Rename getMaster to getPrimary
Bug: T282894
Change-Id: I6d6361a0b84f7130a27df6a6c75a983c73e5dd95
2021-09-03 13:44:04 -07:00
James D. Forrester
df1e801cca Miscellaneous master -> primary switches for private functions and variables
Change-Id: I5c90822f1da6af7354ee7e2d67d579bd72bce8c3
2021-09-03 20:14:41 +00:00