X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=blobdiff_plain;f=includes%2Fpage%2FWikiPage.php;h=920ba8780614f846ff924eaa4bba67e5ab1c136c;hb=99800a9e0360e1a24c061d908dbe111bf687963f;hp=45540b5819cb035132ca7880f8a9b2f82663dd1a;hpb=24dc5218b18bfa065a101057523f39a9c046d046;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 45540b5819..920ba87806 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -316,7 +316,10 @@ class WikiPage implements Page, IDBAccessObject { protected function pageData( $dbr, $conditions, $options = [] ) { $fields = self::selectFields(); - Hooks::run( 'ArticlePageDataBefore', [ &$this, &$fields ] ); + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; + + Hooks::run( 'ArticlePageDataBefore', [ &$wikiPage, &$fields ] ); $row = $dbr->selectRow( 'page', $fields, $conditions, __METHOD__, $options ); @@ -1121,7 +1124,10 @@ class WikiPage implements Page, IDBAccessObject { * @return bool */ public function doPurge( $flags = self::PURGE_ALL ) { - if ( !Hooks::run( 'ArticlePurge', [ &$this ] ) ) { + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; + + if ( !Hooks::run( 'ArticlePurge', [ &$wikiPage ] ) ) { return false; } @@ -1649,14 +1655,15 @@ class WikiPage implements Page, IDBAccessObject { $user = $user ?: $wgUser; $flags = $this->checkFlags( $flags ); + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; + // Trigger pre-save hook (using provided edit summary) $hookStatus = Status::newGood( [] ); - $hook_args = [ &$this, &$user, &$content, &$summary, + $hook_args = [ &$wikiPage, &$user, &$content, &$summary, $flags & EDIT_MINOR, null, null, &$flags, &$hookStatus ]; // Check if the hook rejected the attempted save - if ( !Hooks::run( 'PageContentSave', $hook_args ) - || !ContentHandler::runLegacyHooks( 'ArticleSave', $hook_args, '1.21' ) - ) { + if ( !Hooks::run( 'PageContentSave', $hook_args ) ) { if ( $hookStatus->isOK() ) { // Hook returned false but didn't call fatal(); use generic message $hookStatus->fatal( 'edit-hook-aborted' ); @@ -1878,11 +1885,12 @@ class WikiPage implements Page, IDBAccessObject { 'oldrevision' => $meta['oldRevision'] ] ); + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; // Trigger post-save hook - $params = [ &$this, &$user, $content, $summary, $flags & EDIT_MINOR, + $params = [ &$wikiPage, &$user, $content, $summary, $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $meta['baseRevId'], $meta['undidRevId'] ]; - ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params ); Hooks::run( 'PageContentSaveComplete', $params ); } ), @@ -1999,16 +2007,15 @@ class WikiPage implements Page, IDBAccessObject { ) { // Update links, etc. $this->doEditUpdates( $revision, $user, [ 'created' => true ] ); + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; // Trigger post-create hook - $params = [ &$this, &$user, $content, $summary, + $params = [ &$wikiPage, &$user, $content, $summary, $flags & EDIT_MINOR, null, null, &$flags, $revision ]; - ContentHandler::runLegacyHooks( 'ArticleInsertComplete', $params, '1.21' ); Hooks::run( 'PageContentInsertComplete', $params ); // Trigger post-save hook $params = array_merge( $params, [ &$status, $meta['baseRevId'] ] ); - ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params, '1.21' ); Hooks::run( 'PageContentSaveComplete', $params ); - } ), DeferredUpdates::PRESEND @@ -2277,9 +2284,12 @@ class WikiPage implements Page, IDBAccessObject { } } - Hooks::run( 'ArticleEditUpdates', [ &$this, &$editInfo, $options['changed'] ] ); + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; - if ( Hooks::run( 'ArticleEditUpdatesDeleteFromRecentchanges', [ &$this ] ) ) { + Hooks::run( 'ArticleEditUpdates', [ &$wikiPage, &$editInfo, $options['changed'] ] ); + + if ( Hooks::run( 'ArticleEditUpdatesDeleteFromRecentchanges', [ &$wikiPage ] ) ) { // Flush old entries from the `recentchanges` table if ( mt_rand( 0, 9 ) == 0 ) { JobQueueGroup::singleton()->lazyPush( RecentChangesUpdateJob::newPurgeJob() ); @@ -2323,9 +2333,12 @@ class WikiPage implements Page, IDBAccessObject { if ( !$recipient ) { wfDebug( __METHOD__ . ": invalid username\n" ); } else { + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; + // Allow extensions to prevent user notification // when a new message is added to their talk page - if ( Hooks::run( 'ArticleEditUpdateNewTalk', [ &$this, $recipient ] ) ) { + if ( Hooks::run( 'ArticleEditUpdateNewTalk', [ &$wikiPage, $recipient ] ) ) { if ( User::isIP( $shortTitle ) ) { // An anonymous user $recipient->setNewtalk( true, $revision ); @@ -2454,7 +2467,10 @@ class WikiPage implements Page, IDBAccessObject { $nullRevision = null; if ( $id ) { // Protection of existing page - if ( !Hooks::run( 'ArticleProtect', [ &$this, &$user, $limit, $reason ] ) ) { + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; + + if ( !Hooks::run( 'ArticleProtect', [ &$wikiPage, &$user, $limit, $reason ] ) ) { return Status::newGood(); } @@ -2541,9 +2557,12 @@ class WikiPage implements Page, IDBAccessObject { __METHOD__ ); + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; + Hooks::run( 'NewRevisionFromEditComplete', [ $this, $nullRevision, $latest, $user ] ); - Hooks::run( 'ArticleProtectComplete', [ &$this, &$user, $limit, $reason ] ); + Hooks::run( 'ArticleProtectComplete', [ &$wikiPage, &$user, $limit, $reason ] ); } else { // Protection of non-existing page (also known as "title protection") // Cascade protection is meaningless in this case $cascade = false; @@ -2823,9 +2842,12 @@ class WikiPage implements Page, IDBAccessObject { return $status; } + // Avoid PHP 7.1 warning of passing $this by reference + $wikiPage = $this; + $user = is_null( $user ) ? $wgUser : $user; if ( !Hooks::run( 'ArticleDelete', - [ &$this, &$user, &$reason, &$error, &$status, $suppress ] + [ &$wikiPage, &$user, &$reason, &$error, &$status, $suppress ] ) ) { if ( $status->isOK() ) { // Hook aborted but didn't set a fatal status