Commit graph

69 commits

Author SHA1 Message Date
Func
4d1da6f7f8 phpunit: Update @covers annotations for namespaced classes
We renamed many classes to be namespaced, but the `@covers` and
`@coversDefaultClass` annotations weren't updated properly.

PHPUnit didn't support short cover annotations with `use` statements,
these didn't trigger any errors yet, because they are class alias.

This patch is populated by a modified version of PhpunitAnnotationsSniff.

Change-Id: I6c602290a30099239b17d2dc0d67b1488b4eaeeb
2023-05-27 17:43:12 +08:00
Amir Sarabadani
63df32a347 Start relying on IConnectionProvider instead of LB/LBF
Bug: T330641
Change-Id: I3f7567282327ac59728313ae5c813ddf64093de3
2023-04-11 17:36:37 -07:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
Amir Sarabadani
0f13e81a15 Reorg: Move five page-related classes to page/ out of includes/
These classes:
 - MergeHistory
 - MovePage
 - ProtectionForm
 - BadFileLookup (to MediaWiki\Page\File)
 - FileDeleteForm (to MediaWiki\Page\File)

Bug: T321882
Change-Id: Ibeb488ba322c62a34042a0307bbb5562773bcad1
2023-02-23 17:03:49 +01:00
wangombe
f79d0469e4 Include missing message parameter in message
Message parameter was visible to a user when moving a page. This is
undesirable as the console gives incomplete feedback. This patch
solves that by including the 'old name' of the page to be moved.

Bug: T322583
Change-Id: Ie155d5c3d588702ad169fba2563b3ee9f50dd292
2023-01-04 12:12:34 +03:00
DannyS712
0bb3d1fd8c MovePageTest simplifications and cleanup
Change-Id: I0f1638e2ceac4e1ec203815bbed564b48d6ce36a
2023-01-02 17:05:59 +00:00
daniel
166b569444 Make use of the new PageUpdateStatus
PageUpdateStatus provides clean access the the newly created
RevisionRecord.

Depends-On: Ia08c586198082ea47e8313d0d41835f9830fb29e
Change-Id: Id6963842321c4eaa3d7d029ad0b769f73433c103
2022-11-30 17:56:58 +00:00
Umherirrender
f1db4bed17 tests: Use MediaWikiIntegrationTestCase::editPage for edits
Change-Id: I1db7294635bb85e03841c4f7b100e2243ddf013b
2022-09-23 22:49:59 +02:00
Umherirrender
89b2d11a0d tests: Use Title::makeTitle instead of Title::newFromText
Avoid parsing known titles in tests to improve performance

Change-Id: Ie240eb42479d19714e64cc4606e26073fadc2e13
2022-09-23 21:53:11 +02:00
Amir Sarabadani
6c4194e23e schema: Drop tl_title and tl_namespace fields from templatelinks
The day has gone. Still keeping the code as the schema changes are not
done in production but the data migration has been finished.

Bug: T299417
Change-Id: I906e069a63d1dae14924c72318b22b16244371d6
2022-09-06 19:53:15 +02:00
Thiemo Kreuz
3703b30618 Tests: Use createNoOpMock() shortcut in a few more places
… instead of doing the same manually with anythingBut() and such.

Change-Id: Idb66040d1560a82df9a5bfa2a6c7e20a0649e49c
2022-07-18 21:25:31 +00:00
Derick Alangi
9899846d10
tests: Use overrideConfigValue(s) where necessary
The files in `tests/phpunit/includes/` directory are now all
covered. Will do sub-directories of `/includes/` next.

Change-Id: I8d5655ce267b6d32cf3c7ee40dc5d2992631b5a6
2022-07-16 23:45:52 +01: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
daniel
e239b02a5e Add convenience methods for asserting status.
This ensures that assertions work in a uniform way,
and provides meaningful messages in cause of failure.

Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
2022-03-16 22:44:25 +01: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
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