Commit graph

166 commits

Author SHA1 Message Date
Aryeh Gregor
7b791474a5 Use MainConfigNames instead of string literals, #4
Now largely automated:

VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \
  tr "\n" '|' | sed "s/|$/\n/;s/'//g")
sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \
  $(grep -ERIl "'($VARS)'" includes/)

Then git add -p with lots of error-prone manual checking. Then
semi-manually add all the necessary "use" lines:

vim $(grep -L 'use MediaWiki\\MainConfigNames;' \
  $(git diff --cached --name-only --diff-filter=M HEAD^))

I didn't bother fixing lines that were over 100 characters unless they
were over 120 and triggered phpcs.

Bug: T305805
Change-Id: I74e0ab511abecb276717ad4276a124760a268147
2022-04-26 19:03:37 +03:00
Daimona Eaytoy
da39a91e2d Remove fallback to MediaWikiServices in MovePage::__construct
Also reorder class members so that all dependencies are grouped
together.

Change-Id: Id1c91afd7f9051ea72ba8bea3b5eca7c791e7fb0
2022-04-20 21:06:44 +00:00
Umherirrender
e3a741661a Remove usage of protection related deprecated Title function
Bug: T306131
Change-Id: I487a12a88ae82c367d1cbb2e52083fe20b27d4ce
2022-04-14 21:42:55 +00:00
Timo Tijhof
e3659dfef9 page: Improve class documentation briefs
* Indicate whether a class is a service (to be found via MediaWikiServices)
  or a lower-level class for certain backend logic.

* Indicate how to create / where to get instances of non-service classes,
  e.g. point to the relevant service.

* Remove copy-pasta text in file docblock that is unrelated,
  and incorporate any relevant text into the class docblock instead.

Change-Id: Ia3b9b8c22da4d7160c5e14ae6a6a7c9dca30e9db
2022-04-12 00:49:41 +00:00
jenkins-bot
28e3726be7 Merge "Reduce delete attempts on redirect table for move and page creation" 2022-04-07 17:25:21 +00:00
daniel
552ec41814 Use name constants to access config settings.
Use name constants instead of string literals in calls to Config::get
and ServiceOptions::get, when referring to core configuration variables.
This protects against typos and makes the decumentation and schema
declaration of the config settings discoverable.

This is the first batch, only touching files directly under /includes/

Change-Id: I7252e636c7c86d950d9257b33491af492c6dd5eb
2022-04-07 13:02:28 +02:00
jenkins-bot
2d1734a291 Merge "MovePage: Propagate information about a new redirect using Status" 2022-03-11 21:40:11 +00:00
jenkins-bot
0200221a93 Merge "Fix various documentation related to null types (part II)" 2022-03-09 22:42:42 +00:00
Matěj Suchánek
b1de103176 MovePage: Propagate information about a new redirect using Status
Instead of relying on the source page existence.

Also clean the integration test up a bit and avoid
passing null where string is expected.

Bug: T47348
Change-Id: I15ef9fcedb4b3f5ecc253095e07ceaffe9630b17
2022-03-09 11:15:09 +01:00
Umherirrender
d7248d63fb Fix various documentation related to null types (part II)
The functions returning null or the class property is set explict null.
Some function should not accept null or return null.

Found by phan strict checks

Change-Id: Ie50f23249282cdb18caa332f562a3945a58d86ff
2022-03-08 23:45:31 +00:00
jenkins-bot
e9e925b8ec Merge "MovePage: Simplify data retrieval using selectFieldValues" 2022-03-06 19:12:38 +00:00
Matěj Suchánek
2d317e5937 MovePage: Only return Status from moveToInternal
Instead of returning two different classes from the method, return the Status object only and hide any additional information in its value. This allows us to propagate all additional information we need together with the result.

Change-Id: I5c2bd3f0eb91a225d127fb06101ecfb62dbffa07
2022-03-06 10:14:45 +00:00
Matěj Suchánek
2d67c2b289 MovePage: Simplify data retrieval using selectFieldValues
Change-Id: I24712d56973fe9357aeb93637f578ff6a0d97266
2022-03-06 10:28:23 +01:00
Aaron Schulz
c433c15087 Convert various callers to LoadBalancer::getConnectionRef()
Bug: T193565
Change-Id: I2e2ef6a1d841c632d1f3e53ca3f82a720af15d47
2022-01-27 01:02:44 +00:00
Tim Starling
87d8ccbd3e Move the link updates from moveUnsafe() to LinksUpdate
Since LinksUpdate was already run after a page move, it was just a
matter of propagating a move flag down to it, and resolving the
differences between the move case and the edit case.

This should be faster since it avoids writing to the links tables twice
on a page move.

Change-Id: Ifaa4051a736b01cda82fbd890325e0751ce041f8
2022-01-04 15:35:57 +11:00
Amir Sarabadani
ede308ed55 Drop pr_user from page_restrictions
It's not used for 13 years, safe to say it won't be used anytime soon

Bug: T199377
Change-Id: Iecf4fb6046699a1758ad2d1dc55a3ee8eb4b0389
2021-12-06 14:15:39 +01:00
Umherirrender
f79d8bbb81 Reduce delete attempts on redirect table for move and page creation
Avoid delete of non existing rows which sets gap locks.

For PageUpdater::doCreate: When creating a new page it is known there is
no row in the redirect table, but a "DELETE FROM redirect WHERE page_id
= new page" is running within the open transaction and sets a gap lock
for "last page id in redirect" until unlimited. A redirect page creation
from another user now wants to insert and has to wait for release of the
lock, because it has a page id, which is in the locked gap. That can
result in timeouts for page creation.

For MovePage::moveToInternal: When a normal page is moved it is known
there is no row in the redirect table, but the page move is issue a
delete + gap lock and a parallel move with a page id in that range can
get a deadlock.

Bug: T120140
Change-Id: I5ddfdb690e0cc33b178b5fdcc01ffb6220911fa8
2021-12-01 22:32:11 +01:00
Reedy
7bf779524a Remove or replace usages of "sanity"
Bug: T254646
Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
2021-11-19 23:19:42 +00:00
Derick Alangi
6407361b46 Migrate WikiPage::doEditUpdates() to using PageUpdaterFactory
WikiPage::doEditUpdates() has been deprecated. Using the PageUpdaterFactory's
newDerivedPageDataUpdater() is the new way forward. Also, I made sure to have
the `$options` array with the `causeAction` and `causeAgent` key/value pairs.

Change-Id: I9f2c212d7c83a46799f9f947dc372dc364289680
2021-10-07 11:17:43 +01:00
Petr Pchelko
ee4e19498f MovePage: don't create a recent change for a redirect
Follow-up on e33f6b4b8

Bug: T291677
Change-Id: Ibea22700f5e5d2a8a8bd5995474b45ab847d2ba4
2021-09-23 19:58:04 -07:00
Petr Pchelko
e33f6b4b8e MovePage - use PageUpdater to create redirect page
After parent patch MovePage changed code is covered
by tests, plus tested locally quite a bit. Seems to work.

Change-Id: I0f8db203eb4aa767e5e1f3067f3a9e35835f38ea
2021-09-17 15:49:50 +00:00
Umherirrender
5b3d3ef802 collation: Create CollationFactory service
Use ObjectFactory specs for collation classes
Avoid the language construction in the factory class,
make it a detail of the implementation of each class

Follow-Up of Ifc96f851e6091ce834dbaf0e91695c648a42169c

Bug: T286079
Change-Id: Ib581f64aec8619986fb8dd49ceee0524d59a1b84
2021-09-04 02:46:06 +02:00
jenkins-bot
a31fa46ad5 Merge "Use MovePageFactory and hard deprecate constructing MovePage objects directly" 2021-08-11 20:29:44 +00:00
TChin
715f60357d Use MovePageFactory and hard deprecate constructing MovePage objects directly
Bug: T252934
Change-Id: I9345c1869310b6db82c50984a8ee80cc68ec7ff9
2021-08-11 15:44:09 -04:00
TChin
fa5d3dba51 Support fluent interface for StatusValue
Also refactored some calls to use it.

Bug: T287485
Change-Id: If9e96ce87dc3f3641e9b3ebe093f92d8fa49b9ee
2021-08-02 15:14:11 -04:00
DannyS712
47d70dbfba Post Revision-removal cleanup
Updates for the removal of the Revision class itself
and the various methods/hooks/variables removed in the
process, including:

- Update some documentation removing most references
to the Revision class and updating the MCR migration
notes to reflect the past tense for Revision methods.

- Change some capitalization from "Revision" to "revision"
to make it clear comments are about revisions in general,
not the Revision class in particular.

- Minor code tweaks including removing unused variables that
were around for the old hooks that were removed, and
removing the use of DeprecatablePropertyArray where no
longer needed for anything.

- Fix incorrect documentation for PageUpdater::getStatus(),
the status value changed a while ago to have revision-record
in addition to revision, and recently to only have the
revision-record, but ironically PageUpdater was never updated.

- Removed Parser::$mRevisionObject, used to be a Revision object
and was deprecated in 1.35, missed earlier because it was no
longer being set to Revision objects, always null.

- Add RevisionRecord typehints in DummyLinker to match those
in the corresponding Linker methods

This should be a no-op in terms of functionality.

Bug: T247143
Change-Id: I03bbb94fc29085855448780b1a5ad9063911ecc4
2021-06-24 00:32:39 +00:00
DannyS712
5a229f691f Accept UserIdentity in code to manage edit counts
- UserEditCountUpdate: accept UserIdentity instead of User
- Move User::incEditCount() to UserEditTracker

Change-Id: Ibf1482bcbcbf4d56fc06531bb3e17e2a6e3e2e6f
2021-06-08 05:41:03 +00:00
DannyS712
19739de872 Remove some unneeded uses of full User objects
Change-Id: Ib86399445a77d3005f23ae87d87f3cf742b13b1f
2021-05-22 03:58:25 +00:00
daniel
d320ff25e9 MovePage: clear title cache before parsing new redirect.
Clear all caches to make sure no stale information is used
when parsing the newly created redirect. Without this, moves would fail
under certain conditions when Lua core runs on the new page.
It is not entirely clear why this is needed, but it seems to fix the
issue when I tried it on mwdebug.

Bug: T279832
Change-Id: I222fe577c907aa9e6ac9accc597b3a1e45c9d7cc
2021-05-04 15:15:51 +00: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
James D. Forrester
64898405cb build: Upgrade mediawiki-codesniffer from v35.0.0 to v36.0.0
Change-Id: I8905d0d69738a1cd6997c104080fdf128d315e8b
2021-04-29 13:00:15 -07:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
Petr Pchelko
46db19ecdf Factor out rollback logic from WikiPage
Change-Id: I95da91875fcf2f53143c315560e35ccd5ffbf4b3
2021-04-14 11:49:07 -07:00
Tim Starling
e9a12612d3 SECURITY: Non-admin deleted enwiki page in fast double move
Bug: T272386
Change-Id: I8bf163e9dd056bccdbe9ad39537c46eb115da01a
2021-04-08 20:55:46 +01:00
DannyS712
a57b4c813e MovePage: fetch $wgMaximumMovedPages from config
Instead of using the global...

Change-Id: Idf563e8d9fbf828121bd468ae56ec9ceb9a53ee0
2021-03-29 23:42:16 +00:00
Petr Pchelko
7955db4d8d Convert MovePage to Authority
Change-Id: I7d4503711ab1b739ca88b5fd0aa9e336cbac06aa
2021-03-17 19:43:46 -06:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Ammar Abdulhamid
f1b9408e53 Chain MutableRevisionRecord method calls
Now that we can do this. Use shorter variable names too for simplicity

Change-Id: I6f2fef5de4eba616d34be95976321f8dfb5fa9aa
2021-01-20 20:52:22 +00:00
Umherirrender
3f1c5d0eea Document list of change tags as string[]
Change-Id: I0ce2a8154af82a363fef126033b5819c4ee84842
2020-11-20 14:12:54 +01:00
Kosta Harlan
8f46f71e05 phpunit: Use a closure for services to enable unit testing
See also I2aba02560c41b

Bug: T266441
Change-Id: I2f6fec3e9ec1c63572bdc9fd626a457f8e7da630
2020-11-19 12:59:37 +01:00
Umherirrender
1273d68032 Inject WikiPageFactory into MergeHistory/MovePage
Via PageCommandFactory

Change-Id: Id4f247b9983cb22b8deb9d030ddeffed4ae1c956
2020-11-11 22:10:47 +01:00
jenkins-bot
f80d420949 Merge "MovePage: Handle target page deletion failure gracefully." 2020-10-22 13:53:57 +00:00
Ammar Abdulhamid
db20453b0a MovePage: Handle target page deletion failure gracefully.
Throwing exception is not appropriate here and will prevent proper usage
of ArticleDeleteHook, which is ostensibly meant to allow extensions to
cleanly abort the deletion if they need to.

When the target page deletion fails, instead of blowing everything up
with exception, just cancel the open atomic section and return the
user-friendly deletion error back to the user.

Bug: T265779
Change-Id: I66b4458a103f1274715e22a784344c55a62a59ac
2020-10-21 01:07:36 +00:00
Umherirrender
384938fba3 Use READ_LATEST when checking for exists on page move
This is the last check before moving and update the title on the page
table. Be sure to delete the page too avoid duplicate entry on the
index.

Change-Id: I75582a13bd1feedc072ea8d044470e445a9f6730
2020-10-18 20:36:20 +02:00
Mark A. Hershberger
b0595944e9
Use Title::getArticleID instead of Title::exists for internal check
Bug: T265665
Change-Id: Ifdbbd09709807f2ca0e776b2e9364f4d76cb4a49
2020-10-15 16:57:26 -04:00
jenkins-bot
091895ccd2 Merge "Add delete-redirect for deleting single-rev redirects during moves" 2020-09-04 14:04:35 +00:00
jenkins-bot
2cd59140ec Merge "Add extra details to error log to debug why null revision creation is failing" 2020-09-04 10:14:13 +00:00
DannyS712
77781b08c7 Add delete-redirect for deleting single-rev redirects during moves
A new user right, `delete-redirect`, is added (not given to anyone
by default). At Special:MovePage, if attempting to move to a single
revision redirect that would otherwise be an invalid target (i.e.
doesn't point to the source page), the user is able to delete the
target.

Deletions are logged as `delete/delete_redir2`, and the move is
then logged normally as `move/move`, mirroring current delete and
move logging.

To allow for separate handling by Special:MovePage,
MovePage::isValidMove now returns a fatal status `redirectexists` if
the target isn't valid but passes Title::isSingleRevRedirect.
Otherwise, `articleexists` is returned (as previously). Other callers
that don't intend to treat single revision redirects differently
should treat `redirectexists` the same as `articleexists`.

Currently, this deletion (like normal delete and move) cannot be
done through the move api. Since the deletion is only valid when
moving a page, unlike for normal deletion, deleting redirects with
this right cannot be done via the delete api either.

Bug: T239277
Change-Id: I36c8df0a12d326ae07018046541bd00103936144
2020-09-04 03:50:17 +00:00
Aryeh Gregor
a24e8a06b5 Mark CONSTRUCTOR_OPTIONS as internal
These were never meant to be part of the public interface and should not
ever have been marked with @since. They're only useful for constructing
the respective objects, which no outside users should be doing.

Change-Id: I86e01272d46fc72af32172d8a12b9180971d4613
2020-08-21 00:18:45 -04:00
Ammar Abdulhamid
a6284cc69c Add extra details to error log to debug why null revision creation is failing
Bug: T235589
Change-Id: Icae5cdc5b010e23d4956269f64069c0271217af7
2020-08-17 01:14:56 +00:00