wiki.techinc.nl/tests/phpunit/includes/api
Máté Szabó f15e0a62f9 ApiQueryRevisionsBase: Fix 'rvdiffto' parameter handling on PHP 8.0
The legacy 'rvdiffto' API parameter allows consumers to supply a
revision ID or the special strings 'cur', 'prev', 'next' to
revision-related API modules. This will then be resolved to a revision
and the diff of returned revisions against this revision will be
attached to the response.

On PHP 8.0, this parameter is broken as 'cur', 'prev', 'next' no longer
get resolved to the appropriate revision ID but rather are treated as
invalid literal revision IDs. This is because given an associative array
`$params = [ 'diffto' => 'prev' ];`, the expression `$params['diffto']
!= 0` is false on PHP < 8.0 but true on PHP >= 8.0.[1]

Fix it by also checking whether the parameter value is numeric before
treating it as a revision ID, and add a test case for this logic. To
facilitate testing, convert the counter used by ApiQueryRevisionsBase to
count the number of uncached diffs served in the current response to an
instance variable; it is currently a static variable which persists
across test boundaries.

Change-Id: Ifbe14cd2880c98dddc5577d226bef5878bdd657f

---
[1] https://onlinephp.io/c/81e7b

Bug: T322335
Change-Id: Id5032932842c94f4d3ca3707fbc733f5b9704151
2022-11-03 15:49:04 +01:00
..
format Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
query ApiQueryRevisionsBase: Fix 'rvdiffto' parameter handling on PHP 8.0 2022-11-03 15:49:04 +01:00
Validator Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
ApiBaseTest.php Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
ApiBlockInfoTraitTest.php phpunit: use ->getServiceContainer() in integration tests 2022-01-27 22:04:16 +01:00
ApiBlockTest.php tests: Use overrideConfig(Value|Values) where needed 2022-07-12 22:24:50 +00:00
ApiChangeContentModelTest.php tests: Use Title::makeTitle instead of Title::newFromText 2022-09-23 21:53:11 +02:00
ApiCheckTokenTest.php Add tests for ApiCheckToken 2018-01-01 02:06:59 +02:00
ApiClearHasMsgTest.php phpunit: use ->getServiceContainer() in integration tests 2022-01-27 22:04:16 +01:00
ApiComparePagesTest.php tests: Use Title::makeTitle instead of Title::newFromText 2022-09-23 21:53:11 +02:00
ApiContinuationManagerTest.php Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
ApiCSPReportTest.php Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
ApiDeleteTest.php tests: Use overrideConfig(Value|Values) where needed 2022-07-12 22:24:50 +00:00
ApiDisabledTest.php Replace setExpectedException with two args 2019-10-05 16:14:05 +00:00
ApiEditPageTest.php Use short array destructuring instead of list() 2022-10-21 15:33:37 +11:00
ApiErrorFormatterTest.php phpunit: use ->getServiceContainer() in integration tests 2022-01-27 22:04:16 +01:00
ApiLoginTest.php Use short array destructuring instead of list() 2022-10-21 15:33:37 +11:00
ApiLogoutTest.php Remove or replace usages of "sanity" 2021-11-21 19:35:49 +00:00
ApiMainTest.php Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
ApiMessageTest.php Message: Remove deprecated format property 2021-09-03 09:21:12 -07:00
ApiMoveTest.php tests: Use overrideConfig(Value|Values) where needed 2022-07-12 22:24:50 +00:00
ApiOpenSearchTest.php Use short array destructuring instead of list() 2022-10-21 15:33:37 +11:00
ApiOptionsTest.php Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
ApiPageSetTest.php Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
ApiParseTest.php tests: Upgrade PHPUnit from 8.5+ to 9.5+ 2022-10-08 02:03:55 +02:00
ApiProtectTest.php tests: Use overrideConfig(Value|Values) where needed 2022-07-12 22:24:50 +00:00
ApiPurgeTest.php Use short array destructuring instead of list() 2022-10-21 15:33:37 +11:00
ApiResultTest.php tests: Use Title::makeTitle instead of Title::newFromText 2022-09-23 21:53:11 +02:00
ApiRevisionDeleteTest.php ManualLogEntry::getComment() should always return string 2022-07-09 18:58:19 -04:00
ApiRollbackTest.php tests: Use overrideConfig(Value|Values) where needed 2022-07-12 22:24:50 +00:00
ApiSetNotificationTimestampIntegrationTest.php API: Fix result of action=setnotificationtimestamp for non-watched title 2022-04-25 17:35:22 +00:00
ApiStashEditTest.php build: Updating dependencies 2022-10-07 21:09:37 +03:00
ApiTestCase.php Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
ApiTestContext.php Revert "Reorg: Move some of request related classes to MediaWiki/Request" 2022-10-27 13:14:16 +00:00
ApiUnblockTest.php phpunit: use ->getServiceContainer() in integration tests 2022-01-27 22:04:16 +01:00
ApiUndeleteTest.php tests: Use overrideConfig(Value|Values) where needed 2022-07-12 22:24:50 +00:00
ApiUploadTest.php Revert "Reorg: Move some of request related classes to MediaWiki/Request" 2022-10-27 13:14:16 +00:00
ApiUploadTestCase.php Reorg: Move some of request related classes to MediaWiki/Request 2022-10-28 10:15:31 +00:00
ApiUsageExceptionTest.php Misc cleanup to api integration tests 2021-01-21 06:32:58 +00:00
ApiUserrightsTest.php tests: Migrate setMwGlobals() to overrideConfigValue(s)() 2022-07-19 15:42:15 +01:00
ApiWatchTest.php tests: Migrate setMwGlobals() to overrideConfigValue(s)() 2022-07-19 15:42:15 +01:00
generateRandomImages.php Replace some more isset() with shorter ?? syntax 2021-11-02 10:39:38 +01:00
MockApi.php API: i18n for warnings and errors 2016-12-06 10:20:48 -05:00
MockApiQueryBase.php Replace some oldskool @see with @inheritDoc 2019-11-08 18:00:27 +00:00
RandomImageGenerator.php RandomImageGenerator::getImageSpec: Don't pass a float to mt_rand(), for PHP 8.1 2022-10-24 09:38:52 -04:00