Commit graph

1253 commits

Author SHA1 Message Date
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
Ammar Abdulhamid
8d5d00086a Add custom ENUM datatype for doctrine DBAL
Bug: T230428
Change-Id: I5bcdfa4a63b3e278ff7db318fd957c2adf43b2fb
2020-11-17 06:08:24 +01:00
jenkins-bot
d009d75c73 Merge "Start generateSchemaChangeSql.php" 2020-11-16 08:40:36 +00:00
Petr Pchelko
017cfcf016 Forward-compat for merging CacheTime and ParserOutput mOptions
CacheTime::mUsedOptions and ParserOutput::mAccessedOptions
do exactly the same thing and has to be merged into a single property.
This patch adds forward-compatibility and needs to be deployed
at least one train before the patch which actually merges the properties.

Change-Id: Ic9d71a443994e2545ebf2a826b9155c82961cb88
2020-11-10 07:09:41 -07:00
Petr Pchelko
f11ed7e46f Add forgotten import hook interface
When making primitive tests for HookRunner in
I8d0a34e185aad79a391acdd47e506c8911c75257 I've
notived that coverage was not 100% and found that
this hook interface was forgotten.

Change-Id: Ic877fd1f2bbac5a1af708f283e9e0b7a49f89d88
2020-11-02 08:17:34 -07:00
Amir Sarabadani
1125167b8d Start generateSchemaChangeSql.php
Creating schema changes from abstract schema and even abstracting a
schema change.

Bug: T230420
Change-Id: If626e866642af820dd70c5f9b0fe7c6a951e0a25
2020-11-01 21:14:53 +01:00
Petr Pchelko
1f2f71ff60 Remove ProcessCacheLRU, deprecated and unused.
Change-Id: I88c30c2480c51ad18d9a14d9f75700087ed09b99
2020-10-20 12:49:05 -07:00
Petr Pchelko
e11ea52576 Remove SVGMetadataExtractor deprecated and unused.
Change-Id: Ia30e59d1ff93129d48b4e6f0df76879407b5e3e2
2020-10-19 20:53:08 -07:00
Ammar Abdulhamid
bb2d35e8ad Vary timestamp default value per platform in abstract schema
To accommodate PG-unique timestamp format, if there's a
timestamp field in a column, and there's a default value,
the given timestamp will be converted to PG-compatible format
in the final schema output.

SQLite and MySQL use the same format.

Bug: T191231
Change-Id: If344395615087c360597a5b3d66ea03e930b7d9b
2020-10-17 20:21:51 +01:00
Petr Pchelko
13574e8404 Deprecate ParserCache::getKey and replace it with getMetadata
Bug: T263689
Change-Id: I4a71e5a7eb1c25cd53b857c115883cd00160736b
2020-10-13 08:31:22 -07:00
DannyS712
1f1793dc06 Convert UserNamePrefixSearch to a service
Replace existing class with static ::search method
with a service under MediaWiki\User\ and with
dependencies injected

Similar to the creation of the SpecialPageFactory
service, rename the old file to UserNamePrefixSearch_deprecated
so that UserNamePrefixSearch.php can be used for
the service.

Follow-up patches will:
* Inject and use the new service
* Update the release notes
* Replace the use of the UserFactory with UserNameUtils

Change-Id: Ib78b9bdc96c935d75bd03a8af789b8b359c58b07
2020-10-08 00:14:41 +00:00
jenkins-bot
b1308abc3d Merge "maintenance: Move cleanupTable from .inc to .php" 2020-09-29 06:07:39 +00:00
daniel
dc436c3cff Introduce and apply NonSerializableTrait
The NonSerializableTrait prevents object serialization via php's native
serialization mechanism. Most objects are not safe to serialize, and
NonSerializableTrait provides a covenient and uniform way to protect
against serialization attempts.

This patch applies the NonSerializableTrait to some key classes in
MediaWiki.

Bug: T187731
Bug: T259181
Change-Id: I0c3b558d97e3415413bbaa3d98f6ebd5312c4a67
2020-09-28 21:55:49 +02:00
jenkins-bot
f6f40e0f95 Merge "maintenance: Move commandLine from .inc to .php" 2020-09-28 17:29:12 +00:00
jenkins-bot
17291773c1 Merge "Create ParserCacheFactory." 2020-09-28 16:13:37 +00:00
James D. Forrester
7282ea26a4 maintenance: Move commandLine from .inc to .php
… and fix the name to match the class.

Bug: T184782
Change-Id: Id3d0d0a6b3f2da6316d18eb57804c5a2b697108b
2020-09-28 15:03:05 +00:00
Petr Pchelko
fec48eb5a4 Create ParserCacheFactory.
* Makes ParserCache take the root of the key
  as a constructor argument
* Introduces a ParserCacheFactory

Next steps:
- convert FlaggedRevs to using this.
- cleanup

This assumes that we wouldn't want to differentiate
the parser cache settings per use-case, as it is now
for default vs flaggedrevs caches. There are only two settings:
$wgParserCacheType - name of the BagOStuff to use
$wgParserCacheExpireTime - the expiration time.
I think if we wanted to have different settings for different
caches, we could add that as a next step.

Bug: T263583
Change-Id: I188772da541a95c95a5ecece7c7dd748395506c2
2020-09-25 18:17:58 -07:00
James D. Forrester
74ee16732e maintenance: Move cleanupTable from .inc to .php
… and fix the name.

Bug: T184782
Change-Id: I670af00baed690ef57413e721b8f5f615ea46502
2020-09-25 17:36:39 +01:00
James D. Forrester
be448ac1b2 maintenance: Move sqlite from .inc to .php
Bug: T184782
Change-Id: I18fabbcc8588518f5cc10c8e3f0fba2379263c6c
2020-09-25 17:36:38 +01:00
James D. Forrester
4272da2c62 maintenance: Move sqlite.php to SqliteMaintenance.php to match class name
Change-Id: I4d6be08082fd1841d3056a0554376e8e9665b429
2020-09-25 17:36:36 +01:00
James D. Forrester
562f0fa8fb maintenance: Move userDupes from .inc to .php
Bug: T184782
Change-Id: I99056b21664a460ec2b16899e7cfa617511b7d0b
2020-09-23 11:59:41 +01:00
James D. Forrester
edc2b8d323 maintenance: Move CodeCleanerGlobalsPass from .inc to .php
Bug: T184782
Change-Id: Ifefeb88e3e84eff909ad56aef630b94df8250429
2020-09-23 11:59:41 +01:00
jenkins-bot
2cbf3de509 Merge "Remove ParserBeforeStrip/ParserAfterStrip hooks, deprecated in 1.35" 2020-09-23 09:26:01 +00:00
jenkins-bot
a01f759fbb Merge "Add FindMissingActors script." 2020-09-23 06:56:34 +00:00
daniel
dbe7fdb94c Add FindMissingActors script.
This allows bad actor IDs to be overwritten with some default. This
solves the problem of rows in tables like ipblocks, logging, or
revision not being found due to a failing join against the actor table.

Bug: T261325
Change-Id: Ibc554d0b6f52e7b30cdde5138ac165774831ec36
2020-09-22 21:10:16 +02:00
C. Scott Ananian
aae8b558c3 Remove ParserBeforeStrip/ParserAfterStrip hooks, deprecated in 1.35
Everything code search:
https://codesearch.wmflabs.org/search/?q=ParserBeforeStrip%7CParserAfterStrip&i=nope&files=&repos=

Bug: T250449
Bug: T250450
Change-Id: I91e6753a9159bb7f8d699c79fd20483c42be33aa
2020-09-20 14:12:18 +01:00
Amir Sarabadani
c1ffa95444 Introduce TinyInt db datatype for doctrine DBAL
This handles cases like booleans where we go with tinyint.

Bug: T230428
Change-Id: I6cac7d57ac777e1959283f6837b593e4f1726026
2020-09-17 10:21:47 +02:00
Amir Sarabadani
1ac06ab2f2 Introduce TimestampType for handling custom db type in doctrine
This is needed as Doctrine DBAL can't understand the data type we have
here.

Bug: T42626
Change-Id: Id94e74e1b6bdd2bdf36fc21412ed69a271e3a8c8
2020-09-17 10:12:13 +02:00
Ostrzyciel
a47778d5c0 Add mw-reverted change tag
The tag is added to reverted edits as described in T254074.

Functionality:
* Adding the mw-reverted tag to reverted edits (duh)
* Limiting the maximum depth of the update through a config variable
(mitigation #2 from T259014).
* Only applying the reverted tag after the edit has been somehow
approved. Only the patrol subsystem currently implements this, but
there's a hook that extensions can use (mitigation #4 from T259014, more
explanation in T259103).
* When performing the delayed update, it is checked whether the reverted
edit was reverted itself. If so, the update is ignored. This is
probably the only way to make the feature work due to the lack of an
explicit "disapproval" mechanism other than reverting.
* The update is also ignored if the revert is marked as deleted.

Technical design:
* The update code is in RevertedTagUpdate.php, which is a deferrable
update, but is not used as such. It's separated to allow for better DI,
testing and better code reusability in the future.
* The update is queued / ran using the Job subsystem. The relevant job
is in RevertedTagUpdateJob.php
* PageUpdater determines whether the edit is approved or not and passes
that to the DerivedPageDataUpdater.
* The BeforeRevertedTagUpdate hook lets extensions decide whether the
update should be ran right away or await approval.
* DerivedPageDataUpdater checks whether the edit is a revert and if so
either enqueues the job (if it's auto-approved) or caches the EditResult
for later use (if it needs approval).
* RevertedTagUpdateManager allows for easy re-enqueueing of the update
for extensions. Thus, it has a very minimal interface.

Other notes:
* The unit testing setup for RevertedTagUpdate is a bit complicated,
but it was the only way I could make this class testable while using
the static ChangeTags class.

Bug: T254074
Depends-On: I86d0e660f0acd51a7351396c5c82a400d3963b94
Change-Id: I70d5b29fec6b6058613f7ac2fb49f9fad9dc8da4
2020-08-31 13:40:50 +00:00
Reedy
0c91dca0f8 Remove maintenance/createCommonPasswordCdb.php
Change-Id: I7aad72f4b72e68f66547f0f558db013ea6bef936
Follows-Up: I77432ef0257c0dc8aa7c26e075616592e639bfec
2020-08-25 00:11:23 +01:00
Derick A
3e92cf9cde maintenance: Print version of MediaWiki on the command prompt
In the past, $wgVersion was the global container used to keep
track of the version of MediaWiki. It was recently moved to a
constant (MW_VERSION).

Sometimes, it's difficult to know the current version of a MW
install unless checked via Special:Version (on the web interface).
This script is to make a quick command line based version checker
of MediaWiki so when someone is working on a patch and wants to
quickly know which version of MW that master is on (as this is
changing from time to time and no quick way to know if by developers).

It's a very simple script and to run it on your command line, do:

`php maintenance/version.php`

and you'll get a response with the MW version number and other info.
Also, it attempts to check that if the version is an LTS and appends
it to the version number and also build date which is the latest commit
tracked by git.

Change-Id: I547f3e7328cf3f18b9d414619b757efc81e63081
2020-08-23 23:20:44 +00:00
Alex Dean
8c8654cce0 Add a maintenance script to create bot passwords.
This is useful in testing environments where we want to spin up new mediawiki
instances and configure them programatically.

Change-Id: Ice94b67cb8775786a754de51010e78211954b2b0
2020-08-21 07:25:33 +00:00
C. Scott Ananian
34808c011a Remove ParserBeforeTidy hook, deprecated in 1.35
Bug: T198214
Change-Id: I2c8587862a4a7e4f0fe6007894edb1a0d38816e3
2020-08-12 17:45:45 -04:00
Máté Szabó
90c2840cca UserEditTracker: Do not try to initialize edit count in read-only mode
The method UserEditTracker::getUserEditCount (as well as the old User class
logic it replaced) calculates the user's edit count and writes it to the
database if it was not computed yet. However, it attempts this write even if
MediaWiki is in read-only mode, causing errors as this method is frequently
called on read requests as well.

As a fix, move the edit count initialization to the job queue, which will avoid
trying to open a source DB connection (and thus cause a read-only error) on
installs that do not use the DB-based job queue. This change requires a
workaround in UserGroupManagerTest.

Bug: T259719
Change-Id: I6d1c8e9038ae1f98f47bdb2495aecc21654b24c0
2020-08-06 00:50:41 +02:00
Reedy
66cc7bf101 Remove CategoryFinder class
Bug: T250572
Change-Id: I792cf30d9edc330c3a28e2e000f17d9e2dab69d6
2020-07-29 02:41:38 +01:00
jenkins-bot
1454621d09 Merge "Allow skins to override mediawiki.page.ready initialisation" 2020-07-28 20:49:20 +00:00
Peter Ovchyn
ae3104c46d Allow skins to override mediawiki.page.ready initialisation
Add 'ready.config.json' to resource
Add 'collapsible', 'sortable'  field to be possible override via hook.
In order to override setting, new hook ResourceLoaderPageReadyConfigHook has been introduced.

A new config field for search will follow.

Bug: T250851
Change-Id: I041d4a4b9114f1190f28e0283d96cd33b81f9850
2020-07-28 20:08:27 +00:00
DannyS712
f7932710ac Remove hard deprecated old SpecialPageFactory
Bug: T246141
Change-Id: I758fabccdc74ba9a20a3669643d5fffacc244116
2020-07-27 15:01:35 +00:00
jenkins-bot
777d339967 Merge "Create fallback for undefined content models." 2020-07-22 18:54:23 +00:00
daniel
a67cad6d0f Create fallback for undefined content models.
This causes RevisionStore to use FallbackContent instances to represent
content for which no content handler is defined.

This may happen when loading revisions using a model that was defined
by an extension that has since been uninstalled.

Bug: T220594
Bug: T220793
Bug: T228921
Change-Id: I5cc9e61223ab22406091479617b077512aa6ae2d
2020-07-22 19:59:09 +02:00
daniel
08eb0dbc33 Remove obsolete findHooks.php script.
This maintenance script was obsolete in two ways:
* it tries to parse docs/hooks.txt, which no longer lists hooks.
* it searches for calls to Hooks::run, which has been replaced by
HookRunner.

The purpose of the script, namely listing hooks defined in core,
is covered by the fact that HookRunner implements all hook
interfaces.

Bug: T257804
Change-Id: I6313fe2f4366e09f0408d4d698cf92e8ff792a47
2020-07-17 12:31:08 +01:00
daniel
39cbb504bb Remove the obsolete populateContentModel script.
The script is broken in 1.35, since it operates on the rev_content_model
and ar_content_model fields which have been removed.

Bug: T258139
Change-Id: I172c83931a322a908ea8445c883b9333268ceac8
2020-07-16 12:11:39 +02:00
jenkins-bot
e9ad97eead Merge "Add watchlist expiry support to applicable APIs" 2020-07-14 04:37:44 +00:00
MusikAnimal
6a898faed2 Add watchlist expiry support to applicable APIs
This introduces an ApiWatchlistTrait that refactors out common code
across APIs that allow you to watch pages. Some methods have been
migrated from ApiBase and changed completely, but codesearch suggests
they aren't being used outside the API modules in this patch.

Bug: T248512
Bug: T248514
Change-Id: Ia18627b9824dca81f44f0571e8420d89b7626cf6
2020-07-13 18:18:15 -04:00
DannyS712
c32f1bd419 Add purgeExpiredBlocks maintenance script
In case there aren't enough local block for purging to happen automatically

Bug: T257393
Change-Id: I866ac64219bf5f72a6e41ad32bafc5be9d2c89fa
2020-07-08 15:45:56 +00:00
arttsymbar
b795681612 Language: Make common implementation of findVariantLink functions of Language Converters.
Bug: T254778
Change-Id: Id44539eb6ae2efcb092e871ae149be7235f5ba73
2020-07-02 19:14:45 +03:00
Timo Tijhof
f5644ba904 language: Move converters/ to includes/language/converters
These are easy to move. They contain regular, testable, source code,
are loaded only via the autoloader, and have no references to their
file paths from anywhere else in or outside of core (as far as
Codesearch can see).

Change-Id: Ibe94e541637bb273bd11dba6c2bc5b59f601dd19
2020-07-02 01:57:56 +01:00
Timo Tijhof
3806d1b081 language: Put remaining language Hook interfaces under includes/
Follows-up f5aaf75ad1, which introduced the new Hook interfaces,
with some under includes/language/Hook/ and others under languages/Hook/.
Unify under the former.

Bug: T225756
Change-Id: I887f5037771d96f455cc4d0c8aafe185186b917d
2020-07-02 01:54:08 +01:00
Timo Tijhof
a7d9341d79 language: Move LanguageConverterFactory and TrivialLanguageConverter to includes/
Follows-up 61e0908fa2 (I0e4d77de0), which introduced these new classes
in the old languages/ directory instead of under includes/language.

Bug: T226833
Bug: T225756
Change-Id: Ib19db32303c9e2275a0007a3583820c6b1d5529c
2020-07-02 01:47:46 +01:00
DannyS712
5abd50b925 Add HistoryTools and DiffTools hooks
Bug: T255494
Bug: T255495
Change-Id: Ib2ab2e26a95affdd1dfa6b945f752157580ea2d3
2020-06-23 17:30:22 -07:00
Timo Tijhof
9c7dc9e760 installer: Add intro to Welcome page, add Help/Bug/Contribute links
This removes the readme page embedding in the installer.

Bug: T256062
Change-Id: I453a8e691371266634638e81e54ce18e19cb4467
2020-06-22 21:58:43 +01:00
jenkins-bot
c41566413b Merge "skins: Port SkinFallback and SkinApiOutput to a generic SkinMustache class" 2020-06-15 18:13:50 +00:00
jdlrobson
26d5f78f84 skins: Port SkinFallback and SkinApiOutput to a generic SkinMustache class
The new SkinMustache class is based on the emerging class in Vector.
Having this in core, will allow Vector to make use of this class
immediately and provide a minimal generic mechanism going forward
for rendering skins using Mustache. For now, I've fleshed out the minimum
possible data in getTemplateData which are based on existing functions in
Vector.

The Skin class now takes a generic options parameter which allows
registration of a skin using the SkinMustache class with a templateDirectory
option pointing to the associated template. A `styles` option can be passed
to define stylesheets that should be associated with the skin.

The SkinApi and SkinFallback classes are reduced significantly.

There are no known uses of SkinApiTemplate and it is thus removed.

SkinFallbackTemplate is removed and its functions copied across to
SkinFallback

End user changes:
* The fallback skin no longer prints the confusing warning message if the default
  skin is setup incorrectly. Previously viewing the fallback skin with useskin
  indicated that wgDefaultSkin was not set correctly which was misleading and confusing.
* Factory functions now receive skin options as a second parameter and the service as a
  first - this is due to how ObjectFactory handles the extraArgs key for 'factory' key
  - placing it at the beginning.

Bug: T254048
Change-Id: Ibbabd1d0f26efebf8f8ff068966685dc2191c527
2020-06-15 10:51:31 -07:00
jenkins-bot
a2812b8a6a Merge "Rename CoreMagicWords to CoreMagicVariables and update docs" 2020-06-12 19:18:02 +00:00
Tim Starling
a30b328bd4 Rename CoreMagicWords to CoreMagicVariables and update docs
There's already a thing called magic words, and this is not it. These
things are called variables. There are many usages of this term in the
source. The term was introduced by Lee in 2002: originally
OutputPage::replaceVariables() contained only this functionality.

I introduced the term "magic word", meaning a localizable keyword.
Localizable keywords are an abstraction not limited to this use case.

"Magic variables" is a neologism, but I suppose it is permissible, since
it disambiguates. Whereas calling a variable a magic word conflates rather
than disambiguates.

Fix terminology in magicword.md and update the examples.

Change-Id: I621c888e3790a145ca9978f6b30ff1a8f685b64c
2020-06-11 13:28:45 +10:00
mainframe98
4e2897575a Replace BaseTemplateAfterPortlet with SkinAfterPortlet
BaseTemplate should not handle anything but rendering.
In order to allow replacing it with another renderer,
such as Mustache or Vue, its hooks should be moved to
the Skin class instead.

BaseTemplateAfterPortlet is soft deprecated to allow
filtering, preventing the hook from running twice.

Both BaseTemplate::getAfterPortlet and ::renderAfterPortlet
have been deprecated as well, with both now calling
Skin::getAfterPortlet after running the
BaseTemplateAfterPortlet hook.

Bug: T253797
Change-Id: I438daa79d3d97e2518e6258c3213a805bd1f30e8
2020-06-09 21:51:58 +00:00
Petr Pchelko
2704be7df8 Introduce DeprecatablePropertyArray and use it for PageUpdater
Bug: T250638
Change-Id: I53e39be59228ac5a57f34d51d733d1647331889c
2020-06-09 07:09:00 -07:00
jenkins-bot
3f2937810e Merge "mime: Convert built-in MIME mappings to PHP arrays" 2020-05-21 01:01:06 +00:00
Timo Tijhof
b160ffc27f benchmarks: Remove bench_wfIsWindows.php
This was introduced in r75446 based on r75429. This is not a
benchmark of MW code, but rather a static comparison of how
PHP performs. I'm not sure that's useful to keep long-term.

For what it's worth, anecdotally it seems on PHP 7.2, the caching
might actually be slowing it down. I speculate this might be due
to the simpler variant being easier to optimise, but it hardly
matters as this function now has a very different implementation,
and if something were to call this so often that its runtime
is significant, the caller should probably just avoid doing that
in the first place. Lexical caching tends to be easier to reason
about in the long run, compared to static/unreleased/uncontrolled
caches.

> Running PHP version 7.2.30 (x86_64) on Linux 4.19 (Debian 9 Stretch)
> BenchWfIsWindows::wfIsWindows()
>    count: 100
>     rate: 208464.4/s
>    total:     0.48ms
>     mean:     0.00ms
>      max:     0.01ms
>   stddev:     0.00ms
>
> BenchWfIsWindows::wfIsWindowsCached()
>    count: 100
>     rate: 163266.0/s
>    total:     0.61ms
>     mean:     0.01ms
>      max:     0.05ms
>   stddev:     0.01ms

Change-Id: Iedd273705b88268f1f4d2632913983cbd1028649
2020-05-20 03:33:49 +01:00
Ori Livneh
cb44ddf85b mime: Convert built-in MIME mappings to PHP arrays
Currently, MimeAnalyzer builds the internal mappings of MIME types <=> file
extensions by concatenating several string buffers in mime.type format into a
giant string, and then parsing it. The mapping of MIME types to internal
media types is built up in a similar way, except we use a dubious homegrown
format with undocumented conventions. It's a mess, and an expensive one --
~1.5% of api.php CPU time on the WMF cluster is spent building these buffers
and parsing them. Converting the mappings to PHP associative arrays makes
them much cheaper to load and easier to maintain.

Doing this without breaking compatibility with existing behaviors requires
some delicate footwork. The current mime.types buffer is made up of the
following fragments, in order:

  1) MimeAnalyzer::$wellKnownTypes
  2) If $wgMimeTypeFile == 'includes/mime.types' (sic!):
       the contents of includes/libs/mime/mime.types.
     If $wgMimeTypeFile is another file path (e.g., '/etc/mime.types'):
       the contents of that file.
     If !wg$MimeTypeFile, this fragment is blank.
  3) MimeAnalyzer::$extraTypes (populated by extensions via hook).

The mime.info buffer is built up in the exact same way, except it's
MimeAnalyzer::$wellKnownInfo, $wgMimeInfoFile, and MimeAnalyzer::$extraInfo.

What this means in effect is that some built-in MediaWiki MIME mappings are
"baked in" (anything in MimeAnalyzer::$wellKnown*), and others can be
overridden (anything in includes/libs/mime/mime.*).

To avoid breaking backward compatibility, we have to preserve the
distinction.  Thus this change has two MIME mappings, encapsulated in two
classes: 'MimeMapMinimal', which contains just the baked-in mappings, and
'MimeMap' which contains both the baked-in and overridable mappings.  We also
have to keep the code for parsing mime.types and the ad-hoc mime.info format,
at least for now.

In a FUTURE change (i.e., not here), I think we can:

* Deprecate $wgMimeTypeFile in favor of a new config var,
  $wgExtraMimeTypeFile. $wgMimeTypeFile is evil because if you are using to
  add support for additional MIME types, you can end up unwittingly dropping
  support for other types that exist in MediaWiki's mime.types but not your
  file. The new $wgExtraMimeTypeFile would only be used to add new MIME
  mappings on top of the standard MimeMappings, which was probably the
  original intent for $wgMimeTypeFile.
* Deprecate $wgMimeInfoFile. I don't think we need to provide a replacement,
  because extensions can use the hook, and I doubt anyone is using the config
  var. But if we wanted to provide an alternative, we could have a
  $wgExtraMimeInfoMap that has an array of extra mappings.
* Deprecate MimeAnalyzer::addExtraTypes and MimeAnalyzer::addExtraInfo, and
  provide alternative interfaces that take structured input instead of string
  blobs.

I tested this by dumping the internal state of MimeAnalyzer before and after
this CL using the script in Ib856a69fe, using both default and custom values
for $wgMimeInfo(File|Type).

Bug: T252228
Change-Id: I9b2979d3c9c0dee96bb19e0290f680724e718891
2020-05-19 00:59:52 -04:00
Tim Starling
9f7b735e0f Rename SkinAddFooterLinks to SkinAddFooterLinksHook and add HookRunner method
The interface name is the hook name with "Hook" added.

Change-Id: Ic1e98dfbc9f14938ff75645431bc250a08c337cb
2020-05-18 12:18:36 +10:00
jdlrobson
712312f9cb SkinTemplate: Allow modification of the footer directly
Historically skins like MobileFrontend and  WhoIsWatching rely on
the SkinTemplateOutputPageBeforeExec hook.

I want to deprecate this and allow direct manipulation of the footer
prior to rendering.

The new hook is named SkinGetFooterLinks.

The existing getFooterLinks method is modified. Given this is a new
function, is protected and final and currently has no usages, this
can be done safely.

MobileFrontend: Id83ef2f2cba1dce940f89125b5cd26a29421ee48
Usage in Vector: I4e89beb96f6401ed7e51bafdf0aac408f5a2c42f

Bug: T251817
Change-Id: Id258b1ec2ae7008fc4d586d0647a5131ec889fe6
2020-05-13 15:08:47 -07:00
jenkins-bot
dac0f0de1a Merge "Update hook interfaces for recent additions and deprecations" 2020-05-05 06:56:57 +00:00
jenkins-bot
4d9b4ba5fc Merge "maintenance: Remove maintenance/cdb.php" 2020-05-05 02:14:33 +00:00
DannyS712
b361cf7239 Update hook interfaces for recent additions and deprecations
Changes since the interfaces were generated:
5 hooks added:
* RevisionUndeleted
* ParserBeforePreprocess
* RollbackComplete
* HtmlCacheUpdaterAppendUrls
* HtmlCacheUpdaterVaryUrls

9 hooks deprecated:
* ArticleRevisionUndeleted
* ArticleRollbackComplete (soft deprecation)
* UndeleteShowRevision
* InternalParseBeforeSanitize
* ParserFetchTemplate
* ParserSectionCreate
* ParserPreSaveTransformComplete
* BeforeParserrenderImageGallery
* ParserBeforeTidy

Bug: T240307
Change-Id: Ib91b1d8e519e6cb3c74a6fe174fe2fd0103d6d30
2020-05-05 11:22:04 +10:00
Timo Tijhof
6854834ca4 maintenance: Remove maintenance/cdb.php
There are almost no CDB files left in MediaWiki, and that ones
that remain (commonpasswords.cdb and LCStore support) are
sufficiently large, automated or rarely changed that one wouldn't
be expected to debug them regularly enough to warrant a whole
interactive REPL script dedicated to it.

Note that one can still read these with relative ease using
the eval.php REPL, e.g. using Cdb\Reader::open() and then
calling get($key), firstkey(), or nextkey() etc.

And as of I858dbd5746, a simplified version of this CLI
exists in the wikimedia/cdb library as well.

Change-Id: I20654b91cf15cad512cedeab659ab0dcce5d85f0
2020-05-04 23:36:08 +00:00
Amir Sarabadani
8a4c400412 Introduce maintenance/generateSchemaSql.php
A new script to generate SQL schema from abstract json files.

Bug: T230421
Change-Id: I52f36ed40fc8aac6ff44f046169ae59dbb8f888a
2020-05-04 23:23:19 +00:00
Timo Tijhof
b7ac554304 resourceloader: Move RL hooks to own namespace, use PSR-4
Follows-up f5aaf75ad1.

* Improve some docs for these hooks.
* Add type hints.
* Add them as a subgroup within the ResourceLoader docgroup
  for easy navigation.

Bug: T246855
Change-Id: I52f31e2b63dcf265b27e68ba8fd4f885d82088ac
2020-05-04 22:42:00 +00:00
jenkins-bot
eb88d78c3a Merge "Refactor magic word implementations out of Parser.php" 2020-04-22 08:34:54 +00:00
jenkins-bot
4199c80783 Merge "maintenance: Move FakeMaintenance and LoggedUpdateMaintenance to their own files" 2020-04-21 17:26:59 +00:00
Daimona Eaytoy
870743489b maintenance: Move FakeMaintenance and LoggedUpdateMaintenance to their own files
Originally submitted as commit 2cdeb26d0c.

This patch is fully backwards compatible. The Maintenance.php entry
point is now a true entry point (i.e. no classes defined), and it requires
all the *Maintenance classes.

Bug: T246780
Change-Id: I75b22f54b19fe560ab71349189598245af1c5693
2020-04-21 16:42:01 +00:00
jenkins-bot
cc89a81451 Merge "Automatically generated hook interfaces" 2020-04-21 00:07:41 +00:00