Commit graph

91 commits

Author SHA1 Message Date
Brad Jorsch
68e0ff3f64 MovePage: Don't fail to delete a nonexistent file
If there's no file to be moved (e.g. it's a redirect in the File
namespace), don't fail with an error about being unable to delete the
nonexistent file. Just let it work.

Bug: T249550
Change-Id: I605b0e4b39e7863bddbebf339994c819528e3a4c
2020-04-07 13:58:39 +00:00
Brad Jorsch
3309ead776 MovePage: Use correct Title when creating the null revision
Prior to I4a5fe41fe, the call to Revision::newNullRevision() would load
the Title from the database and use that to create the null revision.

I4a5fe41fe, in removing uses of the deprecated Revision, changed that to
call RevisionStore::newNullRevision() directly. Instead of loading the
Title, that takes one as a parameter. $this->oldTitle was being passed,
which at this point in the execution contains the correct page_id but
the *old* page_namespace/page_title. Passing $nt would also not work,
since that contains the target page's old page_id (likely 0).

The solution is to reset the ID in $nt (so it contains both the correct
ID and name), so we can then pass it to RevisionStore::newNullRevision().

Bug: T248789
Change-Id: I8e0ae616006c0cebde60cfa53c0a842bd2cc1545
2020-04-02 11:59:08 -04:00
Brad Jorsch
c81f992387 MovePage: Remove pre-MCR code
The code path updating rev_content_model on a page move wasn't flagged
with $wgMultiContentRevisionSchemaMigrationStage, so removing it was
missed in I1d9f5465.

Bug: T198557
Change-Id: Ibf3fe35112136393c69091fd02f8b433f53f6eb8
2020-03-26 10:23:20 -04:00
daniel
495323c063 Remove compat code for pre-MCR schema.
NOTE: This was manually tested to ensure it does not
break updates, see T242764.

Bug: T198557
Change-Id: I1d9f5465018bae10124514bc38169e23e0e613e6
2020-03-24 19:45:47 +01:00
jenkins-bot
f39160300a Merge "Pass a user to WikiPage::doDeleteArticleReal, use new signature" 2020-03-19 14:42:51 +00:00
DannyS712
7380aba100 Pass a user to WikiPage::doDeleteArticleReal, use new signature
Don't need to worry about supporting prior versions, since its core

Bug: T247869
Change-Id: Iad9397327731817b8c276d0b9786c3bc5ecf6476
2020-03-19 00:54:29 +00:00
Petr Pchelko
f6f1c41992 Remove usages of deprecated Revision from MovePage
Still have to wrap into the Revision object for hooks.

Bug: T246284
Change-Id: I4a5fe41fe4ba42defab7ecefd942f13ec5711538
2020-03-18 16:46:05 -07:00
Tim Starling
30d5810572 Reconcile differences between arguments in hooks.txt and at the call site
The interface generator script now flags any differences between the
argument list at the call site and the documented arguments. Resolve all
such differences.

* In AlternateEditPreview, $parserOutput is a reference, and a
  WMF-deployed extension replaces it.
* In DeleteUnknownPreferences, fix missing "$" in &$where
* In LocalisationCacheRecache, document the unused parameter, as is the
  convention elsewhere in the file.
* In NewRevisionFromEditComplete, make all callers pass a $tags
  variable, and document the fact that there are multiple callers.
* In PageContentInsertComplete, document legacy references
* In PageContentSave, document the fact that $flags and $status are
  references. I made them legacy references, since although replacement
  will have an effect, no extension relies on this and it is not
  documented on the Manual:Hooks page.
* In PageContentSaveComplete, document $wikiPage, $user, $flags and
  $status as legacy references. Replacement of $status was broken
  by If610c68f4912e89 (MW 1.32), but I confirmed that no extensions
  in CodeSearch are currently affected.
* In ParserGetVariableValueSwitch, document $frame as a legacy reference
* In WatchArticleComplete and UnwatchArticleComplete, SpecialEditWatchlist
  was passing $user by value where as the other callers were passing it
  by reference. Passed by reference. It was already marked legacy.

Bug: T240307

Change-Id: I33f69ebdb5242982fd7986d9877959d2d33149b9
2020-03-06 15:49:15 +11:00
Tim Starling
7cdebd61b7 Use array literals when calling Hooks::run()
To make static analysis and call site replacement easier.

Bug: T240307
Change-Id: I93ab9784b60df633292997ccb1c28f303634c87c
2020-03-04 11:08:30 +11:00
ArtBaltai
30e54b3962 Introduce ContentHandlerFactory
Added:
- ContentHandlerFactory
Tests:
- PHPUnit
Changed
- Calls of changed and deprecated
- DI for some service/api
Deprecated:
- ContentHandler::* then similar to ContentHandlerFactory
- ContentHandler::getForTitle
- ContentHandler::$handlers

Bug: T235165
Change-Id: I59246938c7ad7b3e70e46c9e698708ef9bc672c6
2020-02-07 00:53:51 +03:00
jenkins-bot
da658f33f5 Merge "Add target page as a parameter to articleexists message" 2020-01-02 21:08:50 +00:00
DannyS712
4dd30a93c8 Add target page as a parameter to articleexists message
Bug: T184357
Change-Id: I350d9a8f1504ca878992340db3dd0d60f73594bd
2019-12-20 00:09:45 +00:00
Umherirrender
c7ad21c25f Improve param docs
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
2019-11-28 19:08:59 +01:00
Umherirrender
337ecb0514 Add missing @param and @return to documentation
Change-Id: Ibc5849cc8ea7e7c4eb30ded9c1cfa5f52187c377
2019-11-10 22:12:58 +00:00
Max Semenik
0809a10b90 MovePageFactory: make $constructorOptions a constant
Change-Id: Ia24add9d2805f61aae65bb1a56e13221f57d4547
2019-10-05 12:55:01 -07:00
James D. Forrester
60a064feaa HHVM removal: Drop HHVM support for MovePage execution of TimeMoveComplete
Change-Id: I5b1a41d8267ca322d641b66cff9ca418eba585ea
2019-10-03 18:10:15 +00:00
Umherirrender
268346e562 phan: Enable PhanTypeMismatchArgument issue
Bug: T231636
Depends-On: I5de4f8f32a47c3f41c990ffe2ebd091fc23d1a58
Change-Id: I34d65fe3ff1916f2af675f0b1f19641b0cdfadc0
2019-09-19 20:11:42 +02:00
Aaron Schulz
a5c7fd0db2 Move callers away from Title::GAID_FOR_UPDATE
These callers just need to load some data from DB_MASTER.
Subsequent code needing that latest title data should also use the
required flags, rather than relying on flakey global cache state.

Change-Id: I53248ea4b5bf1cd953f956c41b8244831ec5ef04
2019-09-09 13:19:08 -07:00
Aaron Schulz
b7fce1c2f4 Fix PhpStorm IDE warnings in ServiceWiring.php
Change-Id: Ic1352311908a08a19346ebbee5f5ce73db7633f3
2019-09-03 23:03:23 +00:00
jenkins-bot
75f1fe04a8 Merge "Avoid usage of deprecated setTags() method, use addTags() instead" 2019-09-01 15:25:02 +00:00
Derick Alangi
89cd937798 Avoid usage of deprecated setTags() method, use addTags() instead
$tags can be `null` as seen in most cases and this causes failures,
so, the safer path is to make sure if $tags is a null, do nothing.

Change-Id: I5b7e39adba5d08fdcd42c437a72a391be98c8695
2019-09-01 14:54:03 +00:00
Derick Alangi
52a21ace03 Fix method/function names case mismatch in core files
PHP doesn't care much but I think we humans do because we should
call methods by the name we give them. Method fixed are;

- isOk() -> isOK()
- setOk() -> setOK()
- teardown() -> tearDown()

Change-Id: I6b3f0cf3902887058efa426968da380803869e0b
2019-08-31 23:17:51 +00:00
jenkins-bot
36fdf484e9 Merge "Replace User::isAllowed with PermissionManager." 2019-08-21 08:00:33 +00:00
Petr Pchelko
1d286560d2 Replace User::isAllowed with PermissionManager.
Covers root includes, actions, api, block, changes,
changetags, diff and PermissionManager itself.

Bug: T220191
Change-Id: Ic027d32f5dd8f4c74865df0c8a9fcf91123c889c
2019-08-20 14:43:51 -07:00
Aryeh Gregor
4f912600c0 Return better errors from MovePage::isValidMove()
Previously the errors returned were incorrect or redundant in a number
of cases.

Change-Id: Ief96e69b0ae09afb9642f9ed93b2419a36351292
2019-08-19 20:26:02 +03:00
Aryeh Gregor
b3e4a9c456 Use RepoGroup service in MovePage
Change-Id: I2b59de374d49652b61f074a9da5483c0d991e7a6
2019-08-19 20:26:01 +03:00
Aryeh Gregor
8ec24b607a Introduce MovePageFactory
This will help make MovePage more testable.

In the course of abstracting the logic out of ParserFactoryTest to
FactoryArgTestTrait so it could be used in MovePageFactoryTest, I made
them all unit tests instead of integration. This required some
modification to the Parser constructor so that it didn't access
MediaWikiServices unnecessarily.

Change-Id: Idaa1633f32dfedfa37516bb9180cfcfbe7ca31aa
2019-08-19 20:25:31 +03:00
Aryeh Gregor
ed625e11cd Hard-deprecate Title::moveTo and friends
moveSubpages wasn't officially deprecated at all before this release,
but there were no callers in codesearch outside core, so it should be
safe to hard-deprecate.

Bug: T208775
Change-Id: Icea9f1dc45d8bd8c96cc159d631f18c394aab4b7
2019-05-28 11:52:36 -05:00
Aryeh Gregor
9510dbc4ce Introduce MovePage::moveSubpages(IfAllowed)
Title::moveSubpages() is now deprecated, and the one caller in core and
extensions was ported.

Change-Id: Ic1dc5a6f1a1bef89a35c13f0a72f6740c6a01c50
2019-05-22 14:44:27 -05:00
Aryeh Gregor
2e1ac38485 Mass conversion to NamespaceInfo
Change-Id: I2fef157ceec772f304c0923a1cd8c0eef2e82a0f
2019-05-07 22:44:56 +02:00
Aryeh Gregor
24949e738d MovePage methods need to run safety checks
A move method that doesn't check for things like moving a page on top of
itself or moving to a namespace with a different content model does not
seem like it's what callers would expect, and not what Title::moveTo
ever did. If there's a caller that really wants this behavior, we can
make moveUnsafe public.

I also made the $reason and $createRedirect parameters to move()
optional to match Title::moveTo() behavior. However, I made $reason
default to null instead of '', to distinguish between an empty edit
reason provided by the user and no edit reason provided at all (e.g., a
move done internally without specific user request).

Depends-On: I971e619eb76c4474fe037fad258f9c496717bf41
Change-Id: I6ddcc9f34a48f997ae39b79cd2df40dd2cc10197
2019-05-06 10:04:26 +03:00
Aryeh Gregor
76661cf129 NamespaceInfo service to replace MWNamespace
MWNamespace::clearCaches() has been removed entirely, along with the
$rebuild parameter to MWNamespace::getCanonicalNamespaces(). The rest of
MWNamespace is deprecated.

Diff best viewed with -C1 so git notices that NamespaceInfo is a copy of
MWNamespace.

Depends-On: Icb7a4a2a5d19fb1f2453b4b57a5271196b0e316d
Depends-On: Ib3c914fc99394e4876ac9fe27317a1eafa2ff69e
Change-Id: I1a03d4e146f5414ae73c7d1a5807c873323e8abc
2019-04-10 02:07:36 +00:00
Kunal Mehta
8c98f51778 Fix PhanUnextractableAnnotation* errors (#7)
Change-Id: I8194a7b9c9abce951002590030913706e9bd743e
2019-04-05 23:20:07 -07:00
Thiemo Kreuz
5833dda61d Replace strlen() calls with strict string comparisons
Note there is an important difference between the two ways to express
this: strlen() does a string cast, but the `=== ''` and `!== ''`
comparisons will only detect empty strings, but not null, false, or any
other falsy value that becomes an empty string when cast to be one.

I am only touching code where I'm sure the variable is guaranteed to be
a string.

This change is done because I find the strict comparisons much more
readable. The code does exactly one thing now, and no magic casts any
more.

Change-Id: I3e908a0c7c7b6c29b0e5a1414f2ba9062a215b93
2019-03-28 12:32:39 +01:00
Kunal Mehta
cc5d9a92a2 build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Change-Id: I66b1775b7c1d36076d9ca78cbeb42787a743f2aa
2019-02-07 18:39:42 +00:00
Gergő Tisza
792b23d710
Fix exception language in MovePage
Follows up I8f6c9647ee.

Change-Id: Iff2941bfc9e14f52ddd33f0a3d522c5a0d594c3e
2019-01-17 15:56:07 -08:00
Gergő Tisza
e1d2c92ac6
Fix error reporting in MovePage
Bug: T210739
Change-Id: I8f6c9647ee949b33fd4daeae6aed6b94bb1988aa
2019-01-16 18:14:52 -08:00
Gergő Tisza
eda915cb7a
Fix missing ATOMIC_CANCELABLE in MovePage::move()
Follow-up to I4aaa8af50d684de.

Bug: T213168
Change-Id: I0566b37117b6c69d4043e77e6368bf79fa84e325
2019-01-08 11:37:27 -08:00
Alexia E. Smith
d81f57dc24 Can't call escaped() on a string.
Bug: T211442
Change-Id: Ica5b9cf380a646d9520d5307a937d1e51b7b0099
2018-12-10 13:32:12 -06:00
Alexia E. Smith
ea1781053e Cancel the transaction if the file fails to move. This prevents
losing files when there is a database error.

Bug: T211442
Change-Id: I4aaa8af50d684de9d72224d43dfe5209b930810f
2018-12-10 10:14:26 -06:00
daniel
db987c700a [MCR] Introduce SlotRoleHandler and SlotRoleRegistry
These new classes provide a mechanism for defining the
behavior of slots, like the content models it supports.
This acts as an extension point for extensions that need
to define custom slots, like the MediaInfo extension
for the SDC project.

Bug: T194046
Change-Id: Ia20c98eee819293199e541be75b5521f6413bc2f
2018-11-30 12:29:05 -08:00
Daimona Eaytoy
495331ff07 Add a Status and a $reason parameter to TitleMove hook
So that using this hook it's possible to prevent the move, also
providing some more context.
Also, clean error message: instead of going with "you do not have
permission blah blah" for *every* kind of error, use it only when the
error is actually about permissions, and use a generic message
otherwise.

Bug: T208907
Change-Id: I4733724075b7514e9db59e7be772d9409aa9da87
2018-11-13 08:51:02 +00:00
GeoffreyT2000
19dd287981 Increment edit count for all page moves
The user_editcount field should be incremented for all page moves, not just those done using Special:MovePage. Also, if talk pages and/or subpages are moved along with the base page, they will all be included in the edit count.

Bug: T195550
Change-Id: If75a45e4404ca7162b59bf85fa62a996383658b9
2018-10-26 23:35:01 +00:00
daniel
539cb2816a Avoid fatal when finding no base revision for a null revision.
Bug: T205675
Change-Id: Iae67649a1be9597086033ad34d9d00556ba35730
2018-10-04 19:54:31 +02:00
Brad Jorsch
56fddb98a1 Provide a RevisionRecord with the correct title after a move
Currently we're creating the null revision for the move before actually
updating the page's title, so when it gets passed through
RevisionRenderer the output uses the old page's title in the <h1>.

To make that null revision have the correct title, let's try simply
updating the page table before creating it instead. The ordering
shouldn't matter since this all happens in an atomic section.

Bug: T203661
Change-Id: I9ebdcbc566b11dea3a9bdd402ea4418c4e51b096
2018-09-06 14:05:17 -04:00
Kevin Israel
a50f61009d MWNamespace: Add getCategoryLinkType() method
This method returns the value used as cl_type for category links that
are "from" pages within the namespace, and is added to avoid duplication
of code across a few classes.

Change-Id: I4e55932a5a27858cfedb12009b455fcd02f9b5df
2018-06-29 15:37:11 +00:00
jenkins-bot
2f8e83821b Merge "Replace call_user_func_array(), part 2" 2018-06-09 14:25:26 +00:00
Max Semenik
6e956d55aa Replace call_user_func_array(), part 2
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

In one occurrence, a simple conditional instead of trickery was much more readable.

This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.

Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
2018-06-07 20:19:26 -07:00
Kunal Mehta
d5e4bf920c Ensure $user is passed by reference in TitleMoveComplete hook on HHVM
Suggested by Anomie in T118683#3688320.

Bug: T118683
Change-Id: I57e05c5ae42c8b85d0a8f9631a459c5686b27893
2018-06-07 13:41:09 -07:00
Matěj Suchánek
18a2fd3268 Tag redirects from moves as new redirects
Bug: T184117
Change-Id: Ic9a0abcb530787f652e7d439ecc7cac5f603be56
2018-02-09 15:45:29 +00:00