Commit graph

28 commits

Author SHA1 Message Date
Brad Jorsch
a2d2ccc8c5 ApiParse: Fix handling of pageid + redirects when passed a non-redirect
The setting of $pageParams in that code path was assuming the page was
specified by title, breaking when it was passed a pageid.

Bug: T241362
Change-Id: Ia5b34ee392c94e5ae7693e95b58806c1dac2b24e
2019-12-23 09:24:17 -05:00
Daimona Eaytoy
6365eaab8d Autofix 94 PHPUnit 8 compat issues
Done automatically using the master version of MW codesniffer and
running composer fix.

Bug: T192167
Change-Id: If6b40f515fde32ab5eff074a90e821c30c791827
2019-12-13 15:29:10 +01:00
Daimona Eaytoy
8545ce131a Kill the remaining usages of PHPUnit4And6Compat methods
Bug: T192167
Change-Id: I1ea19e9b53683b7d32ff9836990ee73ab3e11104
2019-10-06 10:12:54 +00:00
Daimona Eaytoy
ef5ab69629 Replace setExpectedException with two args
Find: ^(\t*)(\$this->)setExpectedException\(\s+(\\?[a-z\\]+::class),\s+('(?:[^'\\]|\\')+'|"(?:[^"\\]|\\")+")\s+\);

Replace: $1$2expectException( $3 );\n$1\$this->expectExceptionMessage( $4 );

+broke long lines manually.

Bug: T192167
Change-Id: I5557b4372625def55a53ac637c2f980f51f12933
2019-10-05 16:14:05 +00:00
Aryeh Gregor
7fb4a95563 Remove unneeded overrideMwServices/resetServices
Change-Id: If6cbdec05b8f310ef3a0b4649aaa16d9fb80a047
2019-08-29 14:26:18 +03:00
Vedmaka
dd6b94024c Re-apply: Factors out permissions check from User into PermissionManager service
Was reverted by I549810a4cd2e424cc4a438887d2f24614a24cc00 due to
T224607.

Original change by  Vedmaka Wakalaka was
Ia0d840b772ea5f20c9594ce151cc57adc270e48b.

Original commit message:

The following methods should are factored out of the User class into PermissionManager,
leaving only deprecated stubs:

- User::isAllowed -> PermissionManager::userHasRight
- User::getRights -> PermissionManager::getUserPermissions
- User::groupHasPermission -> PermissionManager::groupHasPermission
- User::getGroupPermissions -> PermissionManager::getGroupPermissions
 -User::getGroupsWithPermission -> PermissionManager::getGroupsWithPermission
- User::groupHasPermission -> PermissionManager::groupHasPermission
- User::isEveryoneAllowed -> PermissionManager::isEveryoneAllowed
- User::getAllRights -> PermissionManager::getAllPermissions

Depends-On: I7909e9bd6bbfbd708c0a00b861a9b22a38c6665d

Bug: T218558
Bug: T223294
Change-Id: I8899240378f636ea70f447616710516c0a3c5c31
2019-06-28 13:19:38 -07:00
Kosta Harlan
7f90d1e3a3 Revert "Factors out permissions check from User into PermissionManager service"
This reverts commit 7faa7a7420.

Reason for revert: T224607

Change-Id: I549810a4cd2e424cc4a438887d2f24614a24cc00
2019-05-30 13:51:37 +00:00
Vedmaka
7faa7a7420 Factors out permissions check from User into PermissionManager service
The following methods should are factored out of the User class into PermissionManager, leaving only deprecated stubs:

- User::isAllowed -> PermissionManager::userHasRight
- User::getRights -> PermissionManager::getUserPermissions
- User::groupHasPermission -> PermissionManager::groupHasPermission
- User::getGroupPermissions -> PermissionManager::getGroupPermissions
 -User::getGroupsWithPermission -> PermissionManager::getGroupsWithPermission
- User::groupHasPermission -> PermissionManager::groupHasPermission
- User::isEveryoneAllowed -> PermissionManager::isEveryoneAllowed
- User::getAllRights -> PermissionManager::getAllPermissions

Depends-On: I258f02e286b6ba0387e1bff540a744fafb03dc55
Depends-On: Ie4cedf457eaaa93ec3055c37539322855e02ce26
Depends-On: Id274f240d687efa61cb9f7a15033ae2a7a532083

Bug: T218558
Bug: T223294
Change-Id: Ia0d840b772ea5f20c9594ce151cc57adc270e48b
2019-05-29 17:41:07 +02:00
Aryeh Gregor
18ec468633 Don't pass Config to service constructors
We don't want to depend on the entire site configuration when we only
need a few specific settings.

This change additionally means that these services no longer see a live
version of the settings, but rather a copy. This means in tests you
really do have to call overrideMwServices() if you want services to pick
up your config changes.

ResourceLoader and SearchEngineConfig will need more work to port,
because they expose their member Config in a getter, and the getter is
actually used.

Parser and NamespaceInfo are also relatively complicated, so I split
them into separate patches.

Tested with 100% code coverage. \o/

Depends-On: If6534b18f6657ec1aba7327463f2661037f995b3
Change-Id: I1a3f358e8659b49de4502dc8216ecb6f35f4e02a
2019-05-02 11:33:56 +03:00
Timo Tijhof
c6f3440832 resourceloader: Remove addModuleScripts, and deprecate getModuleScripts.
The addModuleScripts() methods were deprecated in 1.31 and 1.32,
these are now removed.

The getModuleScripts() are now deprecated as well, always returning
an empty array. To be removed in 1.34.

Depends on commits for bundled/wmf-deployed extensions that
remove the last few remaining callers to the deprecated functions
in: 3D, Collection, Flow, GlobalUserPage, and Wikibase.

Bug: T188689
Depends-On: If9f0bc6aef85117587fa1929f34f8861c8d80314
Depends-On: Ia8d41b97fbf6822f5f8f7ac889408acce1ac9a3a
Depends-On: I503b919739ea474ff33726815b0da55e2f7e2724
Depends-On: I236ef637fd03b810a46eb361e25067a037e9d183
Depends-On: I62e17779753b977a452cc0c9694947941e999cc3
Change-Id: I5a19b8f164ccf666485d2971202194b747f882df
2019-03-05 16:54:08 +00:00
C. Scott Ananian
eb351597e4 Deprecate the 'disabletidy' parameter for ApiParse
This will be unsupported by future wikitext parsers, which always
construct well-formed HTML.

Bug: T198214
Change-Id: Ic189cd1b38bca5b9ec0ef9810555fe0cbd8b733d
2018-09-24 17:40:51 -04:00
daniel
0dc7ba02b4 Apply content wrapping in ParserOutput::getText()
Instead of applying wrapping the the parser and unwrapping in
ParserOutput::getText(), turn this around and apply wrapping in getText(),
and only if desired.

This avoids search&replace logic for unwrapping, and it also makes it a lot
easier to merge the output of multiple slots for MCR output.

This changes behavior in two hopefully irrelevant ways:
1) the limit report comments will be inside the wrapper div, instead of
following it.
2) if HTML with a wrapper div is explicitly injected into a ParserOutput
object, it will not be possible to unwrap the text.

Bug: T174035
Change-Id: I1641b7995af9bd297f1acd610d583fbf874f34e0
2018-08-29 16:46:25 +02:00
Timo Tijhof
05da60c447 API: Add ApiParseTest case for 'styles' in getDefaultModules
Follows-up a01d8be82c.

Bug: T140664
Change-Id: Ic4151a548884d10a2302af49d89e9e36fd6766fd
2018-05-04 01:03:47 +01:00
Aryeh Gregor
84db63aa6f Improve test coverage for ApiParse
Also removed a sketchy-looking usage of ?: with a string in
ApiParse.php.  In this case I think it was fine, because it would only
cause a bug if a page's display title was '0' but its actual title was
not '0', which is only possible if $wgRestrictDisplayTitle is false,
which is broken by design anyway and I don't think is worth testing.
But ?: used for something that should be interpreted as a string is
generally not a good idea.

One bug fixed: an error message that used an undefined variable.

Depends-On: Id0e6184aff8f9d7e8f32558e1de14faa0168cc1d
Change-Id: I0904bff0f9d80892d0db2ebb590c24fb862f2418
2018-04-12 15:59:54 +03:00
Thiemo Mättig
72fa7b9dfc Fix inconsistent capitalization of different method calls
Change-Id: I9f5b9e59e8cdadf65e80077fe2d3a9822b4592fe
2017-12-27 12:35:13 +01:00
Timo Tijhof
d5ed2785fb API: Include setupSkinUserCss in prop=modules for useskin mode
Follows-up 90c95fc7f2, which included result of Skin::getDefaultModules
in the prop=modules list. All hardcoded modules in OutputPage and Parser
were also subsequently moved into Skin::getDefaultModules.

However, a number of modules cannot be moved there because fundamentally
Skin::getDefaultModules can only load modules via OutputPage::addModules().

For style modules, addModuleStyles() must be used.

Fortunately, there is already a centralised place for that, namely
Skin::setupSkinUserCss(). Include that in the ApiParse return as well.
That should resolve the last bit of inconsistency between ApiParse
and OutputPage when it comes to the module queue.

Bug: T140664
Change-Id: I35e2e3bbdccdd1aa2a259b8e624daa80c609ba8c
2017-10-25 02:16:01 +01:00
Timo Tijhof
e8619ba749 API: Add tests for useskin parameter of ApiParse
Change-Id: If3dff7be5ccb6791f95d37c06998fcbadf1f469f
2017-10-25 02:07:59 +01:00
Brad Jorsch
1e2b3fb37f ApiParse: Clean up parsing code
Now that ParserOptions->isSafeToCache() exists, use it where necessary.
This also moves the use inside the makeParserOptions() method so other
callers can pick it up as well.

Then pass the flag as $forceParse into WikiPage::getParserOutput()
instead of duplicating the logic in several cases, and generally clean
up the logic in the module to let WikiPage decide when to use the cache
in more cases.

Change-Id: I0079e10a40997e4a3b59ac21ef6c92246a147736
2017-06-12 12:34:17 -04:00
Brad Jorsch
4e6810e4a2 API: i18n for warnings and errors
API warnings and error messages are currently hard-coded English
strings. This patch changes that.

With a few exceptions, this patch should be compatible with non-updated
extensions:
* The change to ApiBase::$messageMap will blow up anything trying to
  mess with it.
* The changes to the 'ApiCheckCanExecute' hook will cause a wrong
  (probably unparsed) error message to be emitted for extensions not
  already using an ApiMessage. Unless they're currently broken like
  Wikibase.

Bug: T37074
Bug: T47843
Depends-On: Ia2b66b57cd4eaddc30b3ffdd7b97d6ca3e02d898
Depends-On: I2e1bb975bb0045476c03ebe6cdec00259bae22ec
Depends-On: I53987bf87c48f6c00deec17a8e957d24fcc3eaa6
Depends-On: Ibf93a459eb62d30f7c70d20e91ec9faeb80d10ed
Depends-On: I3cf889811f44a15935e454dd42f081164d4a098c
Depends-On: Ieae527de86735ddcba34724730e8730fb277b99b
Depends-On: I535344c29d51521147c2a26c341dae38cec3e931
Change-Id: Iae0e2ce3bd42dd4776a9779664086119ac188412
2016-12-06 10:20:48 -05:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Siebrand Mazeland
80a8a8e85c Pass phpcs-strict on some test files (5/x)
Change-Id: I690645cd8a9b1165dcc8271b201c695ea9391226
2014-04-24 18:51:45 +02:00
addshore
dc18b813e8 Cleanup Api phpunit Tests
- Splits multiple classes into individual files
- Adds @covers tags
- Fixes scope

Change-Id: I7d2816d3574fa53a2aaa8e2a84b7a7ecdd245252
2013-10-24 19:17:01 +01:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Siebrand Mazeland
483e29277f Remove unused local variables in tests
Change-Id: I71318eb7d8c00bfc1ce6d2fc636b498f7a695f42
2013-04-26 09:48:46 +02:00
Siebrand Mazeland
419b02b6df Update formatting
3 of n.

Change-Id: I62ad009018c54da6cf081c334e44eb98a3c72695
2013-02-14 12:56:23 +01:00
Brad Jorsch
252ae6268b (bug 43762) Mark slow unit test as @group medium
All tests based on APITestCase can be slow. I've also seen more than one
Jenkins failure due to GlobalTest::testMerge timing out.

Also, added a meta-test on APITestCase to make sure that all its
subclasses are marked with @group medium or @group large, to prevent new
tests from re-causing the bug.

Change-Id: I48630736a3d06574876fd1fa3d90899cfbc48012
2013-01-18 14:07:49 -05:00
Brad Jorsch
3756f810bc (bug 41042) Regression: API action=parse with nonexistent page
Changeset Iec98e472 changed the behavior of action=parse&page=... when
passed a page that does not exist: previously, it would return a
"missingtitle" error instead of assuming an empty page. As some people
had been depending on this old behavior, restore the error checking.

Change-Id: I4c76ce458ceb01e233c6074cd9251879013ec143
2012-10-29 13:38:33 -04:00