Commit graph

1464 commits

Author SHA1 Message Date
Jon Robson
e80a981702 Separate skin data for copyright and last modified
Bug: T326265
Change-Id: Ic545825e8296897bc0756c13971c00e88d3432f8
2023-01-24 18:36:26 +00:00
daniel
d9003dd275 Add dependency injection for Job classes
Introduces JobFactory

Bug: T245900
Change-Id: I094cc9325e5eaf2717ae510ef988a72407195224
2023-01-19 15:44:11 +00:00
jenkins-bot
8b53f0d36c Merge "poolcounter: Create PoolCounterFactory service class" 2023-01-19 07:48:35 +00:00
Timo Tijhof
04a1760b54 poolcounter: Create PoolCounterFactory service class
* Allow for DI of config and PoolCounterConnectionManager.

* Manage the PoolCounterConnectionManager singleton without using
  a global/static field.

* Allow for test overrides (in ParserOutputAccessTest) without needing
  to bring all of ObjectFactory and 'factory' and thus exposing class
  constructors to stable interface (except not really since the args
  are hardcoded in practice).

Bug: T201223
Change-Id: I514fee20b388f04f9c85c5a1373845d621c65395
2023-01-19 07:33:58 +00:00
Alexander Vorwerk
9c05e6da86 Add migrateRevisionCommentTemp maintenance script
Introduce migrateRevisionCommentTemp which copies data from
revision_comment_temp to rev_comment_id. The code is similar to
migrateRevisionActorTemp.php.

Bug: T299954
Change-Id: I3140d7efb18d4dfda783831ecb1549262e4bdc32
2023-01-18 20:05:05 +00:00
jenkins-bot
9ceecb76b7 Merge "psysh: Add MW_NO_SESSION mode for testing related features" 2023-01-18 09:49:43 +00:00
Gergő Tisza
969f701fce
psysh: Add MW_NO_SESSION mode for testing related features
Add a --no-session option to shell.php for easier manual
testing/debugging of code for which that flag is relevant.

Exempt from autoloading to avoid breaking ScopeStructureTest.

Change-Id: I97548c8fe76a833837b131a5cd5bd0006a5f7326
2023-01-18 00:49:15 -08:00
Derick Alangi
1afd52e3e4 REST: Move Helper classes to their own namespace
Mixing Handlers with Helpers doesn't look nice for consistency
reasons. Helpers should be in their own place (grouped) in the
Handlers directory as they're really "helpers for the handlers".

Change-Id: Ieeb7a0a706a4cb38778f312bfbfe781a1f366d14
2023-01-16 21:16:09 +01:00
Kevin Israel
7c07484ade maintenance: Migrate mcc.php from CommandLineInc to Maintenance
This allows methods to be defined instead of global functions, which in
this case, were missing the "wf" prefix.

Change-Id: I2413675f46a29d914cb756071cd6abbcf38b500e
2023-01-14 02:02:59 +00:00
jenkins-bot
fce85fd193 Merge "Add script to compare output between Parser and Parsoid" 2023-01-12 14:27:17 +00:00
Abijeet
4c8e6a25ac Add script to compare output between Parser and Parsoid
This maintenance script takes the page, target variant code, and
a username to compare the output from Parser to Parsoid.

To distinguish if Parsoid use the core LanguageConverter, added
a comment to the output.

Bug: T323303
Change-Id: Idab6ee7e6e832b9937e2bd6f1bf64027ad23b668
2023-01-12 17:16:17 +05:30
Derick Alangi
99d989087d jobqueue: Warm parsoid parser cache using a job
This patch introduces ParsoidParserCachePrewarm job
that is used to warm PC with parsoid outputs in order
to speed up page reads on large wikis.

Bug: T322427
Change-Id: Ib63a02d3cf5348b36f4f166ff6939f4d2e7fef6f
2023-01-11 15:15:15 +01:00
Alexander Vorwerk
545c46bd4a Drop an ancient script
The script fixes a specific problem of a version which is long EOL
and from which we do not support any upgrade anymore.

Change-Id: Iab8589065e504ae479ffecf3158595a6c0e6c609
2023-01-04 20:40:27 +01:00
Alexander Vorwerk
f6bd18d6c2 Split a base class out of CommentStore
so that extensions (i.e. CheckUser) can implement their own comment
store without having a lot of code duplication

basically the comment store version of I3a6486532f2ef36

Bug: T233004
Change-Id: Ib40f99e00a514d41776ce521baf113e46d37e9cd
2023-01-01 22:34:36 +00:00
jenkins-bot
34f4280b2d Merge "Update moveToExternal and resolveStubs" 2022-12-20 04:00:34 +00:00
Tim Starling
096ea23208 Update moveToExternal and resolveStubs
Convert these two old scripts to Maintenance subclasses.

* Uncomment the resolveStub() call in moveToExternal and fix one obvious
  bug with it, i.e. the fact that stubs need to be resolved after CGZ
  blobs are moved.
* Replace get_class() with instanceof.
* Make the "tiny text" threshold configurable. Normally this is not
  wanted in WMF production since new revisions are written to ES
  unconditionally.
* Add a dry run mode.
* Add an undo log.
* Add --skip-resolve option.
* Make resolveStub() be much more defensive about what it resolves.
* In moveToExternal, make compression optional and do it also for plain
  text.
* Optionally convert the legacy encoding to UTF-8.

Bug: T299387
Change-Id: I52d54e3b6b785ac072796031be06499221340f51
2022-12-20 13:43:44 +11:00
jenkins-bot
00b7eedc14 Merge "poolcounter: Merge Client and ConnectionManager from extension repo" 2022-12-19 00:18:31 +00:00
Amir Sarabadani
cb18d1007e Reorg: Move ActorMigration and ActorMigrationBase to user/
This may seem a bit weird but anything else related to actor is already
under user/ including ActorCache, ActorNormalization, ActorStore and
ActorStoreFactory.

Bug: T321882
Change-Id: I7072b374bba7a0cd9d905e399c822bf30bd5c0d8
2022-12-16 13:44:33 +01:00
Derick Alangi
ce8e5f1549 Introduce HtmlMessageOutputHelper for system messages
This introduces an interface HtmlOutputHelper that is implemented
by both HtmlMessageOutputHelper or HtmlOutputRendererHelper based
on the page we're dealing with.

Bug: T323558
Change-Id: I1fb8dcc5cc05ce3f32f3c1862b88045f1c8e612b
2022-12-16 11:49:56 +01:00
Amir Sarabadani
523ab7cff8 Reorg: Move RawMessage to under language/
To follow Message. This is approved as part of RFC T166010.

Also namespace it but doing it properly with PSR-4 would require
namespacing every class under language/ and that will take some time.

Bug: T321882
Change-Id: I195cf4c67bd51410556c2dd1e33cc9c1033d5d18
2022-12-16 11:30:19 +01:00
jenkins-bot
59862c9f8d Merge "Generalize History pager tools for use in other contexts" 2022-12-15 23:21:43 +00:00
Jon Robson
012a387587 Generalize History pager tools for use in other contexts
The history page renders an extensible list of tools for each
change list row. I've factored this code out so that it
can also be used on other pages that use the Pager class.

This generalizes the logic for the rollback link and makes sure
the control is standardized across pages. It also allows
the onHistoryTools hook run. I suggest we rename this to something
more generic in a follow up.

Right now usages of onHistoryTools are low but there should be
no issues with running it on more than the history page. One of
the benefits of this is the thanks link will now show on the
contributions page, watchlist and recent changes.

Bug: T51541
Change-Id: Ia03038e86c6a607c8b75eefedbf0285ca1a2f8c8
2022-12-15 14:44:18 -08:00
Amir Sarabadani
9b078129d2 rdbms: Moving replication-related code to its own component
Remove 'insertSelectIsSafe' option, unused.

Remove 'topologicalPrimaryConnRef' option, no longer used as of two
months ago with I41a57247503 (8c9398f7f9).

Remove unneeded DatabaseSqlite::getTopologyBasedServerId
implementation which can inherit null instead of overriding with string
of "0". Only caller is SqlBagOStuff::makeTimestampedModificationToken
which can be used as MainStash DB, where its important that a given
server always has the same unique name within a set of db hosts that
may replicate to each other. By inheriting null as topology server ID,
it SqlBagOStuff will use IDatabase::getServerName instead. That in turn
uses the 'host' connection parameter, which defaults to null in
DatabaseFactory, and then falls back to the string "unknown" which is
as good as "0" for this purpose.

Bug: T299691
Change-Id: Iceb65c28cdd3c4a89b3c8b34c3f95d3285718ec0
2022-12-15 00:37:02 +00:00
Timo Tijhof
adb9c0cc1b poolcounter: Merge Client and ConnectionManager from extension repo
Code moved as-is from the extension repo with minor changes:

* Adopt PSR-4 namespace.
* Keep backward-compatibility with "PoolCounter_Client"
  in LocalSettings, from before the extension was namespaced recently.
* Document how `connect_timeout` actually works, and that it
  was introduced in MW 1.28 (via extension).
* Add stable interface annotations.

Bug: T201223
Change-Id: Iadec5b4b5d2fc7e76509c9be0a8fa605d95c64a7
2022-12-14 20:28:14 +00:00
Amir Sarabadani
a1b4699fea Reorg: Move MagicWord related files to under parser/
This is approved as part of T166010 RFC.

Bug: T321882
Change-Id: Ia4498c0a20e38a6a288dc14065ea8242c84fbc49
2022-12-09 13:48:35 +01:00
Amir Sarabadani
ca9ec658cb Reorg: Move PageProps to page/ and namespace it to MediaWiki\Page\
We should slowly migrate page/ to have proper namespace too but that'll
be pretty big.

Bug: T321882
Change-Id: I3e57be8aa8ac08971f190233196e84ea33023d4a
2022-12-09 13:17:40 +01:00
Amir Sarabadani
2d60ba0c63 Reorg: Move DummyLinker and Linker to linker/
This feels like a no-brainer unless I'm missing something obvious

Bug: T321882
Change-Id: Id49c3d0dd6ea4593211048850856b5b8e05a8fb3
2022-12-08 06:38:17 +01:00
jenkins-bot
81ab58ed82 Merge "Protect HistoryBlob storage against malicious class injection" 2022-12-07 20:54:34 +00:00
jenkins-bot
c11cd1770a Merge "Add migrateExternallinks maintenance script" 2022-12-06 23:47:44 +00:00
Tim Starling
540bddfb1f When content is marked bad, show an error, don't pretend it is empty
It misrepresents the users contribution to show empty text for a
revision when in fact the revision contained some text which we later
lost.

Also, errors from SqlBlobStore::fetchBlobs() did not stop a cache entry
from being written, so a subsequent cache hit would show the bad
revision as empty.

So, in Storage:
* Add BadBlobException, which is thrown by the Storage layer to
  indicate that a revision is marked as bad.
* Have SqlBlobStore::getBlobStore() return an error for bad blobs
  instead of an empty string.
* Duplicate the check for flags=error into SqlBlobStore::expandBlob().
  This avoids an unnecessary cache fetch, and avoids making
  decompressData() throw on error, which would be a b/c break.
* In SqlBlobStore::getBlob(), suppress the cache when there was an
  error.

In Revision:
* Add BadRevisionException, to wrap BadBlobException in the Revision
  layer.
* Return null from RevisionRecord::getContent() on a broader set of
  errors. Make it mostly non-throwing.
* Add RevisionRecord::getContentOrThrow() which returns a non-nullable
  Content.
* Note that SlotRecord::getContent() returns a non-nullable Content so
  now throws in more cases.

In the UI:
* In Article::view(), catch the exception and show an error message.
* In DifferenceEngine, catch the exception and make a suitable error
  message available via getRevisionLoadErrors(). In the diff page, show
  the error message in a box.
* In ApiComparePages and the legacy rvdiffto, show a warning.
* In RawAction, show a 404 by analogy with other error cases.
* In EditPage, there was already handling for $content=null with an
  appropriate error message (missing-revision-content). But having
  $this->textbox1 = null caused PHP 8.1 deprecation warnings, so I fixed
  that.
* In EditPage undo, there was already handling for null content, but I
  improved the error message: "does not exist or was deleted" seems more
  appropriate than "conflicting intermediate edits".

Change-Id: Idd1278d6d756ef37d64addb7b5f3be30747ea603
2022-12-05 22:03:45 +00:00
jenkins-bot
d36136b1b0 Merge "Follow redirects for page/{title} formats source/bare" 2022-12-04 22:45:55 +00:00
msantos
fb5c29e2c0 Follow redirects for page/{title} formats source/bare
* Share logic previously implemented for html/with formats through
a trait class

* source/bare formats doesn't execute a temporary redirect. the
JSON body will contain a key "redirect_target" instead if a wiki
redirect is found

* Introduce PageRedirectHandlerTest to test redirect logic shared
between multiple handlers

* Move Handler instatiation to HandlerTestTrait

* Update api-testing tests in Update.js

Change-Id: Id66e33e19adabdb3c9621eaea4a5d441f23edafd
2022-12-02 13:22:14 -03:00
Tim Starling
21352255ad Protect HistoryBlob storage against malicious class injection
* Add a safe unserialize() wrapper for HistoryBlob classes
* Add a safe unserialize() wrapper for plain array data as used for
  compressed internal storage by ConcatenatedGzipHistoryBlob and
  DiffHistoryBlob.
* Fix tests broken by this.
* Fix unnecessary call to uncompress(), __wakeup() does this already.
  Was a phan error now that we have more information about the type of
  $obj.
* Add tests for successful unserialize and wakeup of WMF production
  data.

Change-Id: Ic995dda16d9c6045b33f2fdae7f6575ac8329976
2022-12-02 00:26:11 +00:00
jenkins-bot
5d536461f9 Merge "Drop more unused hard deprecated hooks" 2022-12-01 13:02:11 +00:00
jenkins-bot
0db76c4a0c Merge "Introduce PageUpdateStatus" 2022-12-01 03:35:53 +00:00
Amir Sarabadani
02e5a33057 Drop more unused hard deprecated hooks
None are used in WMF-deployed extensions and have been hard deprecated
for multiple releases as well.

Change-Id: I62cfa22291f81295b4908192de8657a750c6716d
2022-12-01 03:36:48 +01:00
daniel
491278a649 Introduce PageUpdateStatus
This provides clean access to the RevisionRecord created by an edit.

Change-Id: Iee071d1d1ba1c0c7f2ef72a0ace61436402546aa
2022-11-30 14:49:01 +01:00
jenkins-bot
e1707135d8 Merge "Drop unused deprecated hooks" 2022-11-28 15:46:02 +00:00
Amir Sarabadani
20c5632c4e Drop unused deprecated hooks
Part one, none of these hooks are used in extensions deployed in
production. I skipped any hook that has silenced its deprecation
warnings.

Change-Id: Idf1fd12cc61ca30867dc9f8aeb1701fe035fc5ff
2022-11-28 13:15:19 +00:00
jenkins-bot
3c3c28aa6a Merge "profiler: Drop support for Tideways 4.x in ProfilerXhprof" 2022-11-28 06:35:24 +00:00
Kevin Israel
b3a2c88cea profiler: Drop support for Tideways 4.x in ProfilerXhprof
This branch fails to compile against PHP 7.4.3, our lowest supported
version, and will not be updated to support that or any newer version:

https://tideways.com/profiler/blog/releasing-new-tideways-xhprof-extension

In doing so, remove the Xhprof class. At this point, it doesn't do
anything other than calling either of two functions from whichever
extension is installed, which can just be done in ProfilerXhprof.

Change-Id: Iba1c16f47c68b36982f5d2dcda3bdf4dcb83501d
2022-11-28 06:20:45 +00:00
Amir Sarabadani
09b18a8f4c Reorg: Move Title-related classes to title/
These three classes:
 - TitleArray
 - TitleArrayFromResult
 - TitleFactory

We need to move these and the rest of files under title/ to Title/ (and
namespace them) but the patch will become way too big given that Title class is
also one of them.

Bug: T321882
Change-Id: Iac1688172ee457348a08a470c86e047571feb8e0
2022-11-26 09:30:32 +00:00
Amir Sarabadani
08a30e4e5f Add migrateExternallinks maintenance script
To backfill the old data

Bug: T321663
Change-Id: I1f7f140c3bc71bf3ce243b3802284fc502efa986
2022-11-25 22:08:45 +01:00
jenkins-bot
a94b359376 Merge "Implement LanguageConverter for sh.wiki" 2022-11-24 22:28:46 +00:00
daniel
2ec1791d40 Introduce PageRestHelperFactory
This allows extensions like VisualEditor to safely instantiate REST
helper objects. It also reduces the number of services that need to be
injected into REST handlers from route definitions.

Change-Id: I10af85b2da96568cfffd03867d1cb299645fb371
2022-11-21 07:23:26 +00:00
jenkins-bot
2562d05fa1 Merge "Metrics: move metric implementations to subdirectory" 2022-11-17 19:19:44 +00:00
Tim Starling
f94dfb6e0b ResourceLoader: Clean up PHP 7.2 hacks
Remove workarounds for the lack of proper autoloading for aliased
parameter type declarations which was fixed in PHP 7.4.

Change-Id: Ic4485d06e7ad8d02859dc3e5c67867c4b084386f
2022-11-17 09:51:33 +00:00
Acamicamacaraca
a573bea01b Implement LanguageConverter for sh.wiki
This patch will implement a one-way transliterator (Latin->Cyrillic), per community consensus.

Bug: T268033
Change-Id: I6f3e7efe3630e9960584dca3a5ee55cb92ea722c
Co-Authored-By: Deni <deni@deni.dk>
Co-Authored-By: Winston Sung <winston21.sung@gmail.com>
2022-11-15 06:29:11 +00:00
Cole White
784598add8 Metrics: move metric implementations to subdirectory
Bug: T240685
Change-Id: I38e8f9fac12542909364f06e0484cc1355796673
2022-11-09 19:53:32 -01:00
jenkins-bot
0753263ac5 Merge "title: Move Title.php to includes/title/ where related classes are" 2022-11-09 02:24:47 +00:00