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 null;
}
- /**
- * Get the text of the current revision. No side-effects...
- *
- * @param int $audience One of:
- * Revision::FOR_PUBLIC to be displayed to all users
- * Revision::FOR_THIS_USER to be displayed to the given user
- * Revision::RAW get the text regardless of permissions
- * @param User $user User object to check for, only if FOR_THIS_USER is passed
- * to the $audience parameter
- * @return string|bool The text of the current revision
- * @deprecated since 1.21, getContent() should be used instead.
- */
- public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
- wfDeprecated( __METHOD__, '1.21' );
-
- $this->loadLastEdit();
- if ( $this->mLastRevision ) {
- return $this->mLastRevision->getText( $audience, $user );
- }
- return false;
- }
-
/**
* @return string MW timestamp of last article revision
*/
* @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 string|number|null|bool $sectionId Section identifier as a number or string
+ * @param string|int|null|bool $sectionId Section identifier as a number or string
* (e.g. 0, 1 or 'T-1'), null/false or an empty string for the whole page
* or 'new' for a new section.
* @param Content $sectionContent New content of the section.
}
/**
- * @param string|number|null|bool $sectionId Section identifier as a number or string
+ * @param string|int|null|bool $sectionId Section identifier as a number or string
* (e.g. 0, 1 or 'T-1'), null/false or an empty string for the whole page
* or 'new' for a new section.
* @param Content $sectionContent New content of the section.
* @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
return $options;
}
- /**
- * Prepare text which is about to be saved.
- * Returns a stdClass with source, pst and output members
- *
- * @param string $text
- * @param int|null $revid
- * @param User|null $user
- * @deprecated since 1.21: use prepareContentForEdit instead.
- * @return object
- */
- public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
- wfDeprecated( __METHOD__, '1.21' );
- $content = ContentHandler::makeContent( $text, $this->getTitle() );
- return $this->prepareContentForEdit( $content, $revid, $user );
- }
-
/**
* Prepare content which is about to be saved.
* Returns a stdClass with source, pst and output members
}
}
- Hooks::run( 'ArticleEditUpdates', [ &$this, &$editInfo, $options['changed'] ] );
+ // Avoid PHP 7.1 warning of passing $this by reference
+ $wikiPage = $this;
+
+ Hooks::run( 'ArticleEditUpdates', [ &$wikiPage, &$editInfo, $options['changed'] ] );
- if ( Hooks::run( 'ArticleEditUpdatesDeleteFromRecentchanges', [ &$this ] ) ) {
+ 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
return $result;
}
- /**
- * Return an applicable autosummary if one exists for the given edit.
- * @param string|null $oldtext The previous text of the page.
- * @param string|null $newtext The submitted text of the page.
- * @param int $flags Bitmask: a bitmask of flags submitted for the edit.
- * @return string An appropriate autosummary, or an empty string.
- *
- * @deprecated since 1.21, use ContentHandler::getAutosummary() instead
- */
- public static function getAutosummary( $oldtext, $newtext, $flags ) {
- // NOTE: stub for backwards-compatibility. assumes the given text is
- // wikitext. will break horribly if it isn't.
-
- wfDeprecated( __METHOD__, '1.21' );
-
- $handler = ContentHandler::getForModelID( CONTENT_MODEL_WIKITEXT );
- $oldContent = is_null( $oldtext ) ? null : $handler->unserializeContent( $oldtext );
- $newContent = is_null( $newtext ) ? null : $handler->unserializeContent( $newtext );
-
- return $handler->getAutosummary( $oldContent, $newContent, $flags );
- }
-
/**
* Auto-generates a deletion reason
*
public function isLocal() {
return true;
}
+
+ /**
+ * The display name for the site this content
+ * come from. If a subclass overrides isLocal(),
+ * this could return something other than the
+ * current site name
+ *
+ * @since 1.28
+ * @return string
+ */
+ public function getWikiDisplayName() {
+ global $wgSitename;
+ return $wgSitename;
+ }
+
+ /**
+ * Get the source URL for the content on this page,
+ * typically the canonical URL, but may be a remote
+ * link if the content comes from another site
+ *
+ * @since 1.28
+ * @return string
+ */
+ public function getSourceURL() {
+ return $this->getTitle()->getCanonicalURL();
+ }
}