Drop APIEditBeforeSave hook
authorRazeSoldier <razesoldier@outlook.com>
Sun, 30 Jun 2019 18:56:29 +0000 (02:56 +0800)
committerRazeSoldier <razesoldier@outlook.com>
Mon, 1 Jul 2019 18:58:47 +0000 (02:58 +0800)
Removed the source code and the test code.

Bug: T220656
Change-Id: I3674da6d9c33c08ec2f1774cb793b3a952480571

RELEASE-NOTES-1.34
docs/hooks.txt
includes/api/ApiEditPage.php
tests/phpunit/includes/api/ApiEditPageTest.php

index acd82d6..aa61d31 100644 (file)
@@ -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 ===
index 4750560..1e5072f 100644 (file)
@@ -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 <edit result="Failure"> 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
index d0a0523..96aea04 100644 (file)
@@ -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;
index 3badd28..5e5fea3 100644 (file)
@@ -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__ );