Commit graph

1233 commits

Author SHA1 Message Date
Tim Starling
f5d86ec75e Replace usage of custom File properties
Some MediaHandler subclasses were setting custom properties on the File
object in order to cache file-associated state. So:

* Add File::getHandlerState() and File::setHandlerState().
* Put them in an interface, which will be used in a subsequent commit in
  MediaHandler::getSizeAndMetadata().
* Use them in DjvuHandler.
* Provide a trivial implementation of the interface, for use in testing
  and in the subsequent commit.

Change-Id: Ic365384ff13f7898c1203da38c4405abf03d7563
2021-05-27 18:48:06 +10:00
jenkins-bot
be5631743e Merge "WikiImporter: inject services" 2021-05-26 16:45:59 +00:00
ZabeMath
3c978f6fc6 WikiImporter: inject services
This patch injects services into WikiImporter. It also adds
a WikiImporterFactory service for creating WikiImporter
instances.

Change-Id: I2966297e5728fca1ae8280361f1008cef6c6041b
2021-05-24 23:10:07 +02:00
Derk-Jan Hartman
3db119428a Basic JPEG2000 handler
Basic handler for JPEG2000 files. Both jp2 and jpx are supported by
php's image functions.

No support for:
- metadata
- lossy vs lossless thumbnail
- bucketing
- thumbor

Bug: T161934
Change-Id: I1a72d4dfb034f3ae24661db515cf03b35ec18fa2
2021-05-19 12:42:08 -07:00
Ammar Abdulhamid
12870e98c9 Add maintenance script to delete corrupted pages
These are rows in page_table that have 'page_latest' entry with
corresponding 'rev_id' but no associated 'rev_page' entry in revision
table. Such rows create ghost pages because their 'page_latest' rev is
actually missing or moved to a different page now (which possess the -
associated 'rev_page' on revision table now).

https://en.wikipedia.org/wiki/Module:Jct/city/Chinissai
(page_id=41871839) is an example of such pages. Its page_latest rev is
819371998. But this revision has been moved to another page now
(page_id= 56252475), rendering the former inaccessible.

fb58d39 will prevent this going forward (for scribunto content), but we
need to clear the extant pages for module namespace and others caused
by something else.

Bug: T263340
Change-Id: I51abc295e37030ab181d4380f62c30d7998f1b9e
2021-05-17 16:41:53 +10:00
jenkins-bot
cc3b0d6f27 Merge "Create FauxRequestUpload to fake uploads in tests" 2021-05-15 12:20:38 +00:00
daniel
0deb3b0891 Remove aliases for SearchResultPageIdentity
SearchResultPageIdentity and SearchResultPageIdentityValue were
introduced as placeholders for PageIdentity and PageIdentityValue.
They were marked @unstable, and should be unused now. So we can delete
them.

Depends-On: I7a1dfc26d0985e645c785297c849e4c2854c034b
Depends-On: I7e4f6099083ec0eed8878a67ed1b2ee30b5fe43e
Change-Id: I07d6eb019d4570f293ca12035092705b447aa458
2021-05-15 01:45:28 +00:00
daniel
7b832c1fa3 Remove SearchResultPageIdentity interface
SearchResultPageIdentity and SearchResultPageIdentityValue were
introduced as placeholders for PageIdentity and PageIdentityValues.
They can now become aliases.

Bug: T282091
Depends-On: I9b1ab02e0acf12ace107361ea2c443aa543c4880
Depends-On: Ie405ea9539cd18e15b0abb6db6df64ec0135825d
Change-Id: I6eb55c78a0a72be66814f8bc854ba663e7c6f62b
2021-05-10 16:05:45 +02:00
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
Umherirrender
f338645527 Create FauxRequestUpload to fake uploads in tests
And use it in core
Avoid direct use of super global $_FILES

This can breaks all FauxRequest relaying on $_FILES
in tests or production code via FauxRequest::getUpload.
Falls back to $_FILES for the moment

Bug: T48163
Change-Id: I7392acc9bb682ec6b7025dbed0734c142f45c91a
2021-04-06 23:10:43 +02: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