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 );
* @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;
}
* @param array|null $tags Change tags to apply to this edit
* Callers are responsible for permission checks
* (with ChangeTags::canAddTagsAccompanyingChange)
+ * @param Int $undidRevId Id of revision that was undone or 0
*
* @throws MWException
* @return Status Possible errors:
*/
public function doEditContent(
Content $content, $summary, $flags = 0, $baseRevId = false,
- User $user = null, $serialFormat = null, $tags = []
+ User $user = null, $serialFormat = null, $tags = [], $undidRevId = 0
) {
global $wgUser, $wgUseAutomaticEditSummaries;
$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' );
'oldId' => $this->getLatest(),
'oldIsRedirect' => $this->isRedirect(),
'oldCountable' => $this->isCountable(),
- 'tags' => ( $tags !== null ) ? (array)$tags : []
+ 'tags' => ( $tags !== null ) ? (array)$tags : [],
+ 'undidRevId' => $undidRevId
];
// Actually create the revision and create/update the page
'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,
- null, null, &$flags, $revision, &$status, $meta['baseRevId'] ];
- ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params );
+ $params = [ &$wikiPage, &$user, $content, $summary, $flags & EDIT_MINOR,
+ null, null, &$flags, $revision, &$status, $meta['baseRevId'],
+ $meta['undidRevId'] ];
Hooks::run( 'PageContentSaveComplete', $params );
}
),
) {
// 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
}
}
- 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() );
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 );
$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();
}
__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;
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