From: RazeSoldier Date: Sun, 30 Jun 2019 18:56:29 +0000 (+0800) Subject: Drop APIEditBeforeSave hook X-Git-Tag: 1.34.0-rc.0~1223 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=b95a76ae9ecace5772989995a9a6d7e11fb1fdc6;p=lhc%2Fweb%2Fwiklou.git Drop APIEditBeforeSave hook Removed the source code and the test code. Bug: T220656 Change-Id: I3674da6d9c33c08ec2f1774cb793b3a952480571 --- diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index acd82d63be..aa61d3147e 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -252,6 +252,8 @@ because of Phabricator reports. protocol-relative URL, or full scheme URL), and will instead pass them to the client where they will likely 404. This usage was deprecated in 1.24. * Database::reportConnectionError, deprecated in 1.32, has been removed. +* APIEditBeforeSave hook, deprecated in 1.28, has been removed. Please see + EditFilterMergedContent hook for an alternative way to use this feature. * … === Deprecations in 1.34 === diff --git a/docs/hooks.txt b/docs/hooks.txt index 47505607f6..1e5072f003 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -347,19 +347,6 @@ from ApiBase::addDeprecation(). &$msgs: Message[] Messages to include in the help. Multiple messages will be joined with spaces. -'APIEditBeforeSave': DEPRECATED since 1.28! Use EditFilterMergedContent instead. -Before saving a page with api.php?action=edit, after -processing request parameters. Return false to let the request fail, returning -an error message or an tag if $resultArr was filled. -Unlike for example 'EditFilterMergedContent' this also being run on undo. -Since MediaWiki 1.25, 'EditFilterMergedContent' can also return error details -for the API and it's recommended to use it instead of this hook. -$editPage: the EditPage object -$text: the text passed to the API. Note that this includes only the single - section for section edit, and is not necessarily the final text in case of - automatically resolved edit conflicts. -&$resultArr: data in this array will be added to the API result - 'ApiFeedContributions::feedItem': Called to convert the result of ContribsPager into a FeedItem instance that ApiFeedContributions can consume. Implementors of this hook may cancel the hook to signal that the item is not viewable in the diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index d0a0523bf7..96aea040e5 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -367,21 +367,6 @@ class ApiEditPage extends ApiBase { $ep->importFormData( $req ); $content = $ep->textbox1; - // Run hooks - // Handle APIEditBeforeSave parameters - $r = []; - // Deprecated in favour of EditFilterMergedContent - if ( !Hooks::run( 'APIEditBeforeSave', [ $ep, $content, &$r ], '1.28' ) ) { - if ( count( $r ) ) { - $r['result'] = 'Failure'; - $apiResult->addValue( null, $this->getModuleName(), $r ); - - return; - } - - $this->dieWithError( 'hookaborted' ); - } - // Do the actual save $oldRevId = $articleObject->getRevIdFetched(); $result = null; diff --git a/tests/phpunit/includes/api/ApiEditPageTest.php b/tests/phpunit/includes/api/ApiEditPageTest.php index 3badd2859a..5e5fea321f 100644 --- a/tests/phpunit/includes/api/ApiEditPageTest.php +++ b/tests/phpunit/includes/api/ApiEditPageTest.php @@ -1383,57 +1383,6 @@ class ApiEditPageTest extends ApiTestCase { } } - public function testEditAbortedByHook() { - $name = 'Help:' . ucfirst( __FUNCTION__ ); - - $this->setExpectedException( ApiUsageException::class, - 'The modification you tried to make was aborted by an extension.' ); - - $this->hideDeprecated( 'APIEditBeforeSave hook (used in ' . - 'hook-APIEditBeforeSave-closure)' ); - - $this->setTemporaryHook( 'APIEditBeforeSave', - function () { - return false; - } - ); - - try { - $this->doApiRequestWithToken( [ - 'action' => 'edit', - 'title' => $name, - 'text' => 'Some text', - ] ); - } finally { - $this->assertFalse( Title::newFromText( $name )->exists() ); - } - } - - public function testEditAbortedByHookWithCustomOutput() { - $name = 'Help:' . ucfirst( __FUNCTION__ ); - - $this->hideDeprecated( 'APIEditBeforeSave hook (used in ' . - 'hook-APIEditBeforeSave-closure)' ); - - $this->setTemporaryHook( 'APIEditBeforeSave', - function ( $unused1, $unused2, &$r ) { - $r['msg'] = 'Some message'; - return false; - } ); - - $result = $this->doApiRequestWithToken( [ - 'action' => 'edit', - 'title' => $name, - 'text' => 'Some text', - ] ); - Wikimedia\restoreWarnings(); - - $this->assertSame( [ 'msg' => 'Some message', 'result' => 'Failure' ], - $result[0]['edit'] ); - - $this->assertFalse( Title::newFromText( $name )->exists() ); - } - public function testEditAbortedByEditPageHookWithResult() { $name = 'Help:' . ucfirst( __FUNCTION__ );