Commit graph

1224 commits

Author SHA1 Message Date
jenkins-bot
eee48dfed0 Merge "Split a base class out of ActorMigration" 2021-05-06 11:48:50 +00:00
Tim Starling
3faf97c78d Split a base class out of ActorMigration
AbuseFilter needs a class which is almost identical to core's
ActorMigration, so I split out the generic facilities into
ActorMigrationBase, leaving the bits specific to core in ActorMigration.

I changed the way fields and tables are specified so that it's easier to
override in subclasses.

Proper injection of ActorStoreFactory in
ActorMigrationTest::testGetWhere() was necessary to avoid a test failure
due to a teardown issue.

Bug: T278917
Change-Id: I3a6486532f2ef360d1fd01b3a609de71d412f739
2021-05-03 15:14:06 +10:00
Reedy
417de8f5c4 Delete maintenance/cleanupAncientTables.php
Bug: T281635
Change-Id: Ia746f301467e62e4544e451ccc7f46f4e2c6380c
2021-05-03 01:07:39 +01:00
DannyS712
7bd7d2a6c1 Remove hooks that use Revision objects
All hooks were previously hard deprecated
in 1.35. Affected hooks:
* ArticleRevisionUndeleted - use RevisionUndeleted
* ArticleRollbackComplete - use RollbackComplete
* DiffRevisionTools - use DiffTools
* DiffViewHeader - use DifferenceEngineViewHeader
* HistoryRevisionTools - use HistoryTools
* NewRevisionFromEditComplete - use RevisionFromEditComplete
* PageContentInsertComplete - use PageSaveComplete
* PageContentSaveComplete - use PageSaveComplete
* ParserFetchTemplate - use BeforeParserFetchTemplateRevisionRecord
* RevisionInsertComplete - use RevisionRecordInserted
* TitleMoveComplete - use PageMoveComplete
* TitleMoveCompleting - use PageMoveCompleting
* UndeleteShowRevision - no replacement

Includes a fix for setting the associated rev id
of page protections, which previously was only done
using $nullRevision which was a Revision object created
if any hooks needed it; those hooks were hard deprecated
and so for WMF prod the rev id was not being set.

Bug: T247143
Depends-On: Idfa345193ae99fb2f1c9a8f8d28d8d540a6e3d62
Change-Id: I519167f76a5a3c1f5410415b2721462a3dcc3ec8
2021-04-30 17:28:20 +00:00
jenkins-bot
5b818d23e7 Merge "rdbms: move DBAL-related classes under /dbal directory" 2021-04-29 18:44:22 +00:00
jenkins-bot
1d7e23e460 Merge "Add script for resolving class names to files" 2021-04-27 14:45:17 +00:00
Aaron Schulz
dcdec1a2b3 rdbms: move DBAL-related classes under /dbal directory
Change-Id: I116e266835c59a9f7d8731614e13c4db5afb975c
2021-04-26 18:08:09 -07:00
Petr Pchelko
ab9ecc0268 Drop hard-deprecated CacheHelper classes
Bug: T249230
Change-Id: I8fb43e862a19031520dda5a147e533becd7eb89e
2021-04-20 12:56:01 +00:00
Petr Pchelko
c925cb1a4a Drop Autopromote class, deprecated since 1.35
Change-Id: Iee9a3e43fc1689dde867ec7349f0347c741abc36
2021-04-19 09:20:36 -07:00
daniel
6627e42284 Add script for resolving class names to files
Use case: for a list of classes used in a specific context such as
MediaWikiServices, list all files containing these classes, so they can
be processed with command line tools such as grep.

Change-Id: I88dbee72dc5a560624f8cc1da0d905460309f624
2021-04-16 11:04:39 +00:00
jenkins-bot
150601f875 Merge "Update updateSearchIndex.php to 2006+ standards" 2021-04-13 23:48:46 +00:00
jenkins-bot
0d547d95ee Merge "Remove checkLess.php" 2021-04-13 21:40:16 +00:00
jenkins-bot
b61fbb0ab5 Merge "rebuildLocalisationCache: Add --skip-message-purge and accompanying script" 2021-04-13 21:28:12 +00:00
gengh
d59983739e Remove checkLess.php
Bug: T279026
Change-Id: I7b7425bd18df05edc8b2716e44fc03152613efbd
2021-04-13 21:13:04 +00:00
Tim Starling
221162b803 Update updateSearchIndex.php to 2006+ standards
* Remove LOCK TABLES. It was probably never necessary, but in any case
  we have transactions now.
* Delete updateDoubleWidthSearch.php, it was for upgrading from 1.17 or
  earlier, which is no longer supported. Revert the move of various
  updateSearchIndex.php functions to Maintenance. Nothing has ever used
  these except updateSearchIndex.php and updateDoubleWidthSearch.php.
* Convert the query to use the new Database:select() method.
* Remove migration from searchUpdate.pos to searchUpdate.wiki.pos, which
  was put there to support upgrades to 1.16.

Bug: T252853
Change-Id: I19bb44a9a46c2ebdb16a777bb462375278b05b7b
2021-04-09 07:35:07 +10:00
Cindy Cicalese
f1dadbb4ca Rename WatchlistNotificationManager to WatchlistManager
Change-Id: Ic9707c6b74180ef111d128f9f00de218d191c175
2021-04-07 18:16:24 -04:00
Timo Tijhof
0af11e2740 rebuildLocalisationCache: Add --skip-message-purge and accompanying script
== Adding --skip-message-purge

Follows-up d91c6627a9. Per CR and Phab comments, I don't think we
can (yet) promise a generic "--offline" mode. This seems too easy to
misuse. Both for users of the script, as well as for future development
to the script. It can fall out out of sync with requirements of the
overall system and leaves no natural place to discover what
responsibilities are being deferred and how the operator should fulfill
those duties.

We know LCStoreDB doesn't work offline, but there are likely other
aspects of this that don't yet work offline for some users. It would
require a much more rigorous refactor (and dropping signifant extension
hooks) to make this reliably offline. I'd welcome a standalone script
using only vendor libs, that does nothing other than scan directories
and build JSON/PHP/CDB files, but that's not what it is today.

What we can do is skip the one operation we know requires a live
DB connection, and (my main motivation for this commit) then document
that skipping it, require the user to perform the purge by other means
instead, since the purge itself is not actually optional.

Also, make this not a WMF-specific option in MW core, by committing
the accompanying script needed for this to work. This was previously
in the WikimediaMaintenance extension as "refreshMessageBlobs.php".

== Keeping --offline (as --no-database)

As far as I know, the purge is the only action we ran into that needed
a database connection, and important to note was that it's not optional.

I think for WMF we did not run into any other logic in our configuration
that uses a database, so --skip-message-purge should suffice. However,
I've kept the option for two reasons:

1. To recognise in some way the business need for WMF to use this
   script in an offline manner, and thus document that the script
   should at least have a way to work offline, even if there may be
   site configurations and extensions that make this impossible, from
   a core perspective we want to (experimentally) try to support this.

2. There is unimportant setup logic that happens in doMaintenance.php
   where the service wiring for LBFactory is activated by default.
   This seems avoidable and technical debt, but at least for now
   we do need a way to skip that, so this option will continue to
   have that effect.

However, I've renamed the option and inverted its promise. This is not
a promise from core *to* the user to offer an offline mode. Rather,
it is a promise *from* the user that they think nothing DB-needy is in
use.

Bug: T268698
Bug: T263872
Change-Id: I7878fdf4a901fb5e75da540293bb9df9fb508c20
2021-04-07 00:36:59 +01:00
Petr Pchelko
c621548cf8 Convert mail namespace to Authority/UserIdentity
Change-Id: I1e1ea72f94735ddaf66eab29aad1296e1abffb9b
2021-04-01 15:46:09 -06:00
Amir Sarabadani
0dacf7d68d Drop two 1.13 updates
- doCategoryPopulation is not needed nor being called anymore. There's
   not much use for the maintenance script either.
 - doPopulateParentId ditto.

Bug: T272199
Change-Id: Id7fc111b71e8ee9a37a3e2e56849ac5afeea9f9d
2021-03-26 21:34:00 +01:00
jenkins-bot
ad9661c4b8 Merge "Add HTMLTagMultiselectField" 2021-03-26 16:37:37 +00:00
STran
ee93d068d2 Add HTMLTagMultiselectField
Implements HTMLTagMultiselectField, a form field that instantiates
TagMultiselectWidget, the PHP representation of the OOUI's js-based
widget of the same name with the implemented parameters:
* allowArbitrary
* allowedValues

Bug: T278317
Change-Id: I3a6a30506d493be4185f917c577b3837fffd8ae1
2021-03-26 08:15:38 -07:00
James D. Forrester
b4c6a5d629 Drop Avro format option for monolog without deprecation
Bug: T265967
Change-Id: I1b46df143b71db7cc387d3239a4a4489c1f47c96
2021-03-25 08:26:17 -07:00
Ammarpad
ffff04b375 Abstract schema: Handle MySQL Float/Double precision types
Subclass DBAL\Platforms\MySqlPlatform so that we can override
methods cleanly. Move the current MySQL hack from the schema
generator script to this class.

If 'float' is specified in the json spec without any option, the
FLOAT data type will be used. To use DOUBLE PRECISION (aka REAL)
a 'doublePrecision' option has to be specified and set to true.
No support for specifying arbitrary precision since no current
table is using that and the feature is deprecated in MySQL 8 anyway

Due to T270740, the subclassing is not straightforward because
the base DBAL MySqlPlatform class is renamed in DBAL 3.0.0. For
now a compatibility intermediate class is used as in PG subclass

Other changes: Use switch instead of if/else and remove brackets
in instantiating a class without arguments.

Bug: T191231
Change-Id: I9a5087b1e2afc2b63e30d67ea2ca616f047a0258
2021-03-21 05:00:55 +00:00
Amir Sarabadani
81089a2eff Drop maintenance/populateLogUsertext.php
This script was introduced in 1.16 to fill log_user_text. We don't
support direct upgrade from this version anymore.

Bug: T272199
Change-Id: I2876a07f906f2e88c3408bcb51b9887e7e3cb3dc
2021-03-20 18:24:38 +00:00
Amir Sarabadani
79974de53b Drop populating log_search table
This table was introduced in 1.15 that we don't support direct upgrade
from anymore and it should be already pre-filled since then.

Bug: T272199
Change-Id: I2f74243c813b6c15481fffed65ebc82136017f02
2021-03-20 18:24:00 +00:00
Amir Sarabadani
90abe093ff Drop convertUserOptions.php
This is only needed for upgrading from 1.15 which we don't support direct
upgrade from anymore

Bug: T272199
Change-Id: I0f716140a5abb5230d6ae19c0e67ce3bcd80e402
2021-03-19 02:56:23 +01:00
Amir Sarabadani
c1c339d41e Drop convertLinks.php
This is only needed for upgrading from 1.3 which we don't support direct
upgrade from anymore (and I doubt anyone can run 1.3 now)

Bug: T272199
Change-Id: I3e5140c85265a7bfbe912fc0a40ada0eafcfb7c3
2021-03-18 10:18:38 +01:00
Amir Sarabadani
59af2e3132 Drop MysqlUpdater::doUserUniqueUpdate and its sql patch
This was introduced in version 1.5 which we don't support upgrading from
anymore and it's already removed from update.php checks.

Also dropping its related maintenance script which is not needed
anymore.

Bug: T272199
Change-Id: I5a755fd04f0e69880f27628fd805f865f4bc86bf
2021-03-08 17:17:55 +01:00
jenkins-bot
da99ed653f Merge "maintenance: Remove preprocessDump.php" 2021-03-04 22:09:53 +00:00
Timo Tijhof
245bdafd9e resourceloader: Add wikimedia/minify package and remove local copies
- JavaScriptMinifier: The public interface for this internal class is
  ResourceLoader::filter which, except for one caller (minify.php)
  is indeed consistently used already, no other callers need replacing.

- CSSMin: Idem for minification, however, this class has some other
  method as well, which have a number of internal users, but none
  outside core. These have all been replaced in this commit.

- Remove pear/net_url2 as own dependency as this was only used by CSSMin
  and recently added there. This is now a dependency of wikimedia/minify
  instead. This was not part of the public API and no longer mentioned
  here in composer.json or RELEASE-NOTES. (It remains pinned in
  mediawiki-vendor, however.)

Bug: T273247
Depends-On: Iadff8c2112d5e53bd994ab4882006e8c644a2379
Depends-On: Id3c6dcc0b952a9efe34b3a9ed88b716101a51f87
Depends-On: I589be910f57289fd908b22db87241b0e52da60d4
Change-Id: I8d71fc64aeecdb31db218b02e361ae9bb0d19b48
2021-02-24 21:03:02 +00:00
Amir Aharoni
14d363c29f Add converter for the Talysh language (tly)
Mostly copied from UzConverter.

This is a very simple converter, with bidirectional one to one
correspondence: for every Latin letter there is a corresponding
Cyrillic letter and vice versa. There are no digraphs or punctuation
to convert.

The Latin alphabet is the primary one used for this language today,
and will probably remain so for the foreseeable future, so "tly" remains
the usual code, and "tly-cyrl" is added for Cyrillic.

Language name is changed:
* The main language name is now Latin.
* The word "language" ("зывон") is removed.
* The spelling of the word "Talysh" is based on the Pireyko dictionary.

Bug: T258975
Change-Id: I552e07967ea82e03c413a0b10b129a846aa007c7
2021-02-17 13:49:36 +00:00
jenkins-bot
183d83b572 Merge "parser: new BeforeParserFetchTemplateRevisionRecord hook" 2021-02-16 04:31:16 +00:00
Petr Pchelko
26be00fac4 Introduce helper WikiAwareEntityTrait
Bug: T273948
Change-Id: I21180d7031646f13413e2edb1bf0a17fbfdada13
2021-02-08 13:49:50 -06:00
C. Scott Ananian
0676256ccc parser: new BeforeParserFetchTemplateRevisionRecord hook
This new hook provides for the use case in T47096 (allowing the
Translate extension to transclude a page from another language) by
adding a new hook which would let us deprecate and replace two awkward
legacy hooks (one with an embarrassing capitalization issue).  The new
hook is a little more tightly scoped in terms of what it allows and
gives access to, and it uses the new RevisionRecord API.

In addition, the new hook uses LinkTarget instead of Title per
current best practices. (PageIdentity is not appropriate for
reasons documented at the hook invocation site.)

The original BeforeParserFetchTemplateAndtitle (sic) hook allowed
redirecting the revision id of a template inclusion, but not the
title. The only known current use is Extension:ApprovedRevs; the
FlaggedRevs extension replaces the entire function using
ParserOptions::setCurrentRevisionRecordCallback().

Extension:Translate would like to redirect the title as well, possibly
recursively (for a limited number of hops) to handle fallback
languages.  That is, when invoked on Foo/fr, including Template:Bar
would redirect to Template:Bar/fr -- and, if that doesn't exist, then
Template:Bar/fr would redirect to its fallback language, say
Template:Bar/en. It uses the top-level page title as context to set
the desired page language.  This would require 2 invocations of the
hook; we've set the recursion limit to 3 to provide a little bit
of future-proofing.

The hook added in this patch uses RevisionRecord instead of int
$rev_id, and thus can handle the case where the redirect is to a page
which doesn't exist (by setting the RevisionRecord to a
MutableRevisionRecord with the correct title and no main slot content)
in the fallback language case above.

The new hook deprecates BeforeParserFetchTemplateAndtitle and replaces
ParserFetchTemplate as well (deprecated in 1.35).  Code search:

https://codesearch.wmcloud.org/search/?q=BeforeParserFetchTemplateAndtitle&i=nope&files=&repos=

Bug: T47096
Change-Id: Ia5b5d339706ce4084c16948300e0e3418b11792e
2021-02-05 09:37:32 -05:00
DannyS712
58660d6a86 Remove DeferredStringifier class
Soft deprecated since 1.31, no need for hard deprecation
since it is unused and not stable to create

Change-Id: Ie854f422870e1f7666566544d4ed5df9abe240fb
2021-02-03 07:16:19 +00:00
Petr Pchelko
653789eaee Add WikiAwareEntity interface for cross-wiki entity methods.
Add an interface to hold cross-wiki assertion and constants.
This also is a good place to document the expectations.

Currently planned to be implemented by PageIdentity, RevisionRecord,
UserIdentity.

Change-Id: I41a7a82a0386a52a765774ade1ab56a26aaf0741
2021-01-29 10:29:03 +00:00
Timo Tijhof
ec7d35795d maintenance: Remove preprocessDump.php
This script takes an offline XML dump file, containing wikitext pages, and
feeds them through the Preprocessor without actually importing any content
into the wiki as revisions or pages.

The documented purpose of the script is to "get statistics" or "fill the cache".

- I was unable to find any stats being emitted.

- I did find that the called Preprocessor method indirectly writes to
  "preprocess-hash" cache keys, which have a TTL of 24 hours (e.g. Memcached).
  I could not think of a use case for populating Memcached with parse results
  for pages that do not exist on a given wiki.

It was created in 2011 with r80466 (ad8b42449d) without a use case described
or referenced. I suspect it may've been used to help inform the development of
a major change to the Preprocessor around that time, but it doesn't appear to
be needed for that any more, and does not appear to have been aimed at general
usage by site operators. If and when something it is needed for new
developments, it can be easily brought back rather than maintained as-is.

Change-Id: I139aa4ee8c2f92a40e94824c709556dda7ec74ff
2021-01-28 04:09:13 +00:00
jenkins-bot
524a992458 Merge "Create HtmlFileField" 2021-01-21 23:52:27 +00:00
Ed Sanders
b28809cb16 Create HtmlFileField
Bug: T243476
Change-Id: I21d17de56f753c4f62c17c0baf988e1ca890bfda
2021-01-21 22:55:00 +00:00
jenkins-bot
398c39b6de Merge "deferred: make DeferredUpdates::doUpdates() recursion more uniform" 2021-01-15 16:52:31 +00:00
Aaron Schulz
4b7ddd3c67 deferred: make DeferredUpdates::doUpdates() recursion more uniform
Follow-up ba6490aa1e.

That patch worked around $executeContext iteration errors due to the
lack of recursion support in doUpdates()/handleUpdateQueue(). Errors
were triggered by MediaWiki::schedulePostSendJobs() enqueueing deferred
updates that invoke JobRunner::run(), which, in turn, invoke doUpdates()
for each job via JobRunner:: doExecuteJob(). The doUpdates() method was
changed to operate on the sub-queue for the in-progress DeferrableUpdate.

Further improve the recursion logic:
* Use classes for the scope stack and scope queues.
* Put *all* updates added during a DeferrableUpdate::doUpdate() call into
  the subqueue, regardless of "defer until" stage or whether it implements
  MergeableUpdate. Now, doUpdate() can run *everything* it enqueued instead
  of a non-obvious subset. Note that the TransactionRoundDefiningUpdate
  that invokes JobRunner was already a POSTSEND update before ba6490aa1eb;
  the only effect of this change is that MergeableUpdate instances from jobs
  will once again run in doExecuteJob().
* Make recursive DeferredUpdates::doUpdate() calls error out immediately
  unless the DeferrableUpdate responsible is a TransactionRoundAwareUpdate
  with the TRX_ROUND_ABSENT flag. This covers the schedulePostSendJobs()
  scenario and only prohibits insane call patterns. Failing early avoids
  the risk of handleUpdateQueue() dropping all the updates due to the same
  DBTransactionError error in DeferredUpdates::attemptUpdate().
* Avoid recursion loop in tryOpportunisticExecute() when JobQueueDB is in
  use and a large number of tasks are pending. This happened due to methods
  like onTransactionPreCommitOrIdle() being used within JobQueueDB.

Mark DeferredUpdates::doUpdates()/tryOpportunisticExecute() as @internal
and create a Maintenance::shutdown() method to avoid a direct call in the
doMaintenance.php file.

Bug: T249069
Bug: T268840
Change-Id: Ib369f0e74243a48ababdb9cd83b155c9a0f5e741
2021-01-14 15:37:58 -08:00
Tim Starling
20d06b34bb Safer autoloading with respect to file-scope code
Many files were in the autoloader despite having potentially harmful
file-scope code.

* Exclude all CommandLineInc maintenance scripts from the autoloader.
* Introduce  "NO_AUTOLOAD" tag which excludes the file containing it
  from the autoloader. Use it on CommandLineInc.php and a few
  suspicious-looking files without classes in case they are refactored
  to add classes in the future.
* Add a test which parses all non-PSR4 class files and confirms that
  they do not contain dangerous file-scope code. It's slow (15s) but
  its results were enlightening.
* Several maintenance scripts define constants in the file scope,
  intending to modify the behaviour of MediaWiki. Either move the
  define() to a later setup function, or protect with NO_AUTOLOAD.
* Use require_once consistently with Maintenance.php and
  doMaintenance.php, per the original convention which is supposed to
  allow one maintenance script to use the class of another maintenance
  script. Using require breaks autoloading of these maintenance class
  files.
* When Maintenance.php is included, check if MediaWiki has already
  started, and if so, return early. Revert the fix for T250003 which
  is incompatible with this safety measure. Hopefully it was superseded
  by splitting out the class file.
* In runScript.php add a redundant PHP_SAPI check since it does some
  things in file-scope code before any other check will be run.
* Change the if(false) class_alias(...) to something more hackish and
  more compatible with the new test.
* Some site-related scripts found Maintenance.php in a non-standard way.
  Use the standard way.
* fileOpPerfTest.php called error_reporting(). Probably debugging code
  left in; removed.
* Moved mediawiki.compress.7z registration from the class file to the
  caller.

Change-Id: I1b1be90343a5ab678df6f1b1bdd03319dcf6537f
2021-01-11 11:59:36 +11:00
Aaron Schulz
6cbd1f5926 Remove SquidPurgeClient classes
Bug: T250417
Change-Id: I62b66d0e2298d3d003f95d0ed1e893a8c59b00b9
2021-01-04 15:07:51 -08:00
Reedy
b16a862d43 Upgrade doctrine/dbal from 2.10.4 to 3.0.0 for PHP 8.0 support
Some irritating breaking changes, including dropping PHP 7.2 support
and renaming the classes we care about. For now, hack in via || and
some back-compatibility class aliases.

Bug: T270732
Change-Id: I685f099584d2f0e5fa17f1f4275eab5289c7bfee
2020-12-23 02:24:31 +00:00
David Kamholz
9cb5187944 Implement Balinese language converter
This patch implements the BanConverter class for Balinese. Its purpose is to transliterate Balinese in Balinese script to Latin script. Latin to Balinese is not currently supported, because (1) the Latin transliteration is not fully one-to-one, (2) I'm not aware of any users who currently need Latin to Balinese.

The converter supports three distinct Latin transliteration variants: ban-dharma, ban-palmleaf, and ban-puri-kauhan-ubud. All three variants have been requested by different Balinese community members working with Balinese palm-leaf manuscripts. ban-puri-kauhan-ubud is the default, as it is the most familiar to lontar scholars, but Balinese Wikisource users will be able to select their preferred variant via a user script.

Conversion is accomplished via ICU Rule-Based Transliterators, bindings for which are available through the Intl extension.

This patchset adds the abstract class LanguageConverterIcu and has BanConverter inherit from it (makes future ICU-based LanguageConverters easier).

Bug: T263082
Change-Id: Ic3a46a215fbf020a022726e6b130b1d25496e284
2020-12-21 12:45:41 -08:00
daniel
00a3439dce Introduce RevisionOutputCache
Bug: T267981
Change-Id: Ib1dc641ed10d786918362b25bd655780d5844ba1
2020-12-14 16:50:28 +00:00
jenkins-bot
8cafbac2b8 Merge "Introduce DoctrineAbstractSchemaTrait to share schema spec logic" 2020-11-19 04:46:20 +00:00
Amir Sarabadani
1f1ff1377a Introduce DoctrineAbstractSchemaTrait to share schema spec logic
Bug: T230420
Change-Id: I4d78b57c097e4213e2c1462a83f02bbfa7ac0a0e
2020-11-19 01:16:10 +01:00
daniel
a2ae4192c0 ParserOutputAccess: cache ouput for old revisions
DEPLOY: Set $wgOldRevisionParserCacheExpireTime = 0 in production first!

Bug: T267832
Depends-On: I3c73f5d9f6a54e2736600e8f9506659a3fb0e7f6
Change-Id: I0fe275b4991f1bf89c7bb587132bc4fb0ea862e2
2020-11-17 20:52:35 +00:00
daniel
ed41864370 Extract PoolWorlArticleViewCurrent
Extracts a specialized subclass for rendering the current revision
from PoolWorlArticleView, which then no longer knowes about caching.

In the next step, we will add a subclass that implements caching for old
revisions.

Bug: T267832
Change-Id: I56fb365962951e6c723a01cf9243dbc0094b5581
2020-11-17 20:17:02 +01:00