Commit graph

54 commits

Author SHA1 Message Date
jenkins-bot
e1e4f7514f Merge "Convert various callers to LoadBalancer::getConnectionRef()" 2022-01-27 23:34:39 +00:00
Alexander Vorwerk
decbaf4f38 phpunit: use ->getServiceContainer() in integration tests
Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
2022-01-27 22:04:16 +01:00
jenkins-bot
fd84c0f087 Merge "tests: Replace usages of deprecated WikiPage::doDeleteArticleReal" 2022-01-27 19:32:06 +00:00
Aaron Schulz
c433c15087 Convert various callers to LoadBalancer::getConnectionRef()
Bug: T193565
Change-Id: I2e2ef6a1d841c632d1f3e53ca3f82a720af15d47
2022-01-27 01:02:44 +00:00
daniel
4799905dca MovePage: test links table updates
This adds a high level regression test that ensures that xyz_from_namespace
fields are updated when a page is moved to another namespace.

Bug: T299275
Change-Id: I3f42802fab9c8b8747a587d7119731517be5518b
2022-01-18 17:42:11 +00:00
Daimona Eaytoy
2688c59606 tests: Replace usages of deprecated WikiPage::doDeleteArticleReal
Add a new helper to MediaWikiIntegrationTestCase, since deleting pages
seems to be pretty common in tests.

Some calls to WikiPage::factory were also updated to use WikiPageFactory.

Change-Id: I5b5100273a00ac292a1900022ca79708fa254347
2022-01-17 15:38:02 +00:00
Reedy
8c39aab84b Remove or replace usages of "sanity"
Bug: T254646
Change-Id: Ib192dc5704a14d02c7c374d0ab29bac55c5df24a
2021-11-21 19:35:49 +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
Petr Pchelko
339fd93f67 Make MovePageTest actually test valid moves
Before MovePageTest was skipped if the move was valid,
claiming we can't test actual moves. Now we can.

Additionally, use MediaTestTrait for file and repo
mocking.

Change-Id: Ie8a1edbdb2f22432919f03a60c2dacc5d4528615
2021-07-28 09:18:59 -07:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
DannyS712
b45ddb2ab3 Use WikiPage::doUserEditContent() instead of ::doEditContent()
Results in passing a user where previously the fallback
to $wgUser was being used, mostly in tests.

Bug: T255507
Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
2021-06-28 00:11:30 -07:00
DannyS712
26dec11987 Use DummyServicesTrait::getDummyNamespaceInfo in more places
Make it possible for callers to override config as needed

Change-Id: I54e7ba8d56d7d168248aca85c2e4e973b012806a
2021-05-05 01:53:30 +00:00
Petr Pchelko
46db19ecdf Factor out rollback logic from WikiPage
Change-Id: I95da91875fcf2f53143c315560e35ccd5ffbf4b3
2021-04-14 11:49:07 -07: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
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +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
addshore
959bc315f2 MediaWikiTestCase to MediaWikiIntegrationTestCase
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)

My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.

Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
2020-06-30 17:02:22 +01:00
Thiemo Kreuz
5f3a92385b Fix visibility of setUp/tearDown
Change-Id: I636be48eb9f713680abac35d46091f7b49374696
2020-06-16 21:02:05 +02:00
DannyS712
c595f2fd7e Remove use of the Revision object returned in WikiPage::doEditContent (2)
Each file's changes are independent and can be reviewed separately

Bug: T251853
Bug: T254952
Change-Id: Ifdc192796f0989c12fda7c0317bf2458874d6e19
2020-06-10 01:15:45 +00:00
jenkins-bot
8cbf108de7 Merge "immobile-source-namespace: use blanknamespace for main namespace" 2020-05-28 21:32:09 +00:00
Reedy
229b2c15e8 Fix a plethora of class and function call case mismatches
Bug: T231412
Change-Id: I597a25de3294a6673424f30475760280ef209a8a
2020-05-26 14:14:46 +01:00
DannyS712
29aa36c06e Add MergeHistoryFactory interface, implemented by PageCommandFactory
Bug: T249446
Change-Id: I94676e065a8aed5cad2fe2d5cf16ca586adce97d
2020-05-13 19:08:09 +00:00
DannyS712
b14965e75e Convert MovePageFactory to interface, implement in PageHandlerFactory
Bug: T249446
Change-Id: I1335d976b992f44c8609c298f0ec19d81afa7b84
2020-04-27 23:26:28 +00:00
DannyS712
77bcb3a1b1 immobile-source-namespace: use blanknamespace for main namespace
Also for target-namespace

Bug: T224350
Change-Id: I878b5f7ea1d2cebfc295bf08de372726a580cc28
2020-04-11 01:08:31 +00:00
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
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
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
DannyS712
fdd814d3ee Remove Title move functions, deprecated in favor of MovePage class
Removes Title::isValidMoveOperation(), ::moveTo(), and
::isValidMoveTarget()

Bug: T241341
Change-Id: I56993a7f29923c467940318ee77f58dd64abcc30
2020-02-19 20:44:55 -08: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
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
Max Semenik
665b7758c5 tests: getMock() is deprecated
Bug: T192167
Change-Id: I94a4674103b0946d208ff0c28f260506048cb211
2019-10-22 14:20:25 -07:00
jenkins-bot
05ce3b7740 Merge "Title: make newFromText, isValid, and canExist behave consistently." 2019-10-08 13:54:57 +00:00
daniel
9171cbe4ca Title: make newFromText, isValid, and canExist behave consistently.
This patch fixes the documentation of newFromText and makeTitleSafe to
no longer state incorrectly that any Title they return is guaranteed to
be valid. That has never been true.

It also makes canExist() checks a lot stricter, to match the assumptions
of current callers, namely that the title can exist as a wiki page.

Finally, it replaces several existing calls to isValid() with calls to
canExist().

Bug: T229705
Change-Id: I2a483136ec6acca49afb5eb32cb94616672b8fb2
2019-10-08 11:16:11 +02:00
Max Semenik
0809a10b90 MovePageFactory: make $constructorOptions a constant
Change-Id: Ia24add9d2805f61aae65bb1a56e13221f57d4547
2019-10-05 12:55:01 -07:00
jenkins-bot
eba2737ab9 Merge "createNoOpMock() method for PHPUnit tests" 2019-08-29 18:15:43 +00:00
Aryeh Gregor
709773ab57 createNoOpMock() method for PHPUnit tests
This is just a shortcut for a commonly-used pattern, when you want to
create a mock that's never supposed to have methods called.

Change-Id: Ia7267e3d3108c1ff94485f7e44bf409808a762be
2019-08-29 18:00:37 +03:00
Aryeh Gregor
7fb4a95563 Remove unneeded overrideMwServices/resetServices
Change-Id: If6cbdec05b8f310ef3a0b4649aaa16d9fb80a047
2019-08-29 14:26:18 +03: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
8a8f23ddc6 Add a bunch of MovePage tests
The expected values in many cases are silly, because our code is
currently silly and could use some refactoring. These are marked with
@todo. In one case the return value is even wrong (moving to an invalid
non-empty name is considered valid).

Change-Id: I9649a4de12bbcd6263c85de37d7b9365d9c0aeb4
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
a3e8e22f9d Don't use new MCR schema without using DB
If $wgContentHandlerUseDB is false and
$wgMultiContentRevisionSchemaMigrationStage is not SCHEMA_COMPAT_OLD,
RevisionStoreFactory::getRevisionStore() throws. This is coming up in
some seemingly unrelated code changes, perhaps due to access of stale
service objects, but I'm not sure because I can't reproduce locally. So
this is a shot in the dark to fix it.

Change-Id: Id29a62e1f537fa1b2016aac396773b728e238cda
2019-08-13 17:05:24 +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
Umherirrender
618a064c4c Add missing @covers to action related tests
Change-Id: I7653b5fa6f6a3c247f735ac22fda12e7c9549786
2019-02-01 22:13:32 +01: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
Kunal Mehta
38129123f2 tests: Add some more @covers tags
Change-Id: I84b66879773d97593152b683ff69d034ed67aa3d
2018-05-07 17:49:01 +00:00