ApiQueryRevisions::getRollbackToken - pass RevisionRecord
Not actually used, but need to deprecate passing Revision Bug: T249561 Change-Id: Ic4ce2fce64a2f3c8a0c70490599be2022b9f8903
This commit is contained in:
parent
9132b2e372
commit
4de1be2eb0
2 changed files with 27 additions and 3 deletions
|
|
@ -1184,6 +1184,9 @@ because of Phabricator reports.
|
|||
the second parameter, and the suppression option the third parameter.
|
||||
Previously, the third parameter was unused. Using the old signature is
|
||||
hard deprecated.
|
||||
* ApiQueryRevisions::getRollbackToken, which has been soft deprecated since
|
||||
1.24, accepted as its third parameter a Revision object. It now accepts
|
||||
a RevisionRecord, and passing a Revision is hard deprecated.
|
||||
* Passing Article to ParserCache::get() was deprecated
|
||||
* ParserOptions::newCanonical() with no first parameter, or null as the first
|
||||
parameter, which falls back to using global $wgUser, is hard deprecated.
|
||||
|
|
|
|||
|
|
@ -72,10 +72,15 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
|
|||
* @deprecated since 1.24
|
||||
* @param int $pageid
|
||||
* @param Title $title
|
||||
* @param Revision $rev
|
||||
* @param RevisionRecord|Revision $rev (passing a Revision hard deprecated since 1.35)
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function getRollbackToken( $pageid, $title, $rev ) {
|
||||
if ( $rev instanceof Revision ) {
|
||||
// Don't actually need to use the Revision(Record), just emit warnings
|
||||
wfDeprecated( __METHOD__ . ' with a Revision object', '1.35' );
|
||||
}
|
||||
|
||||
global $wgUser;
|
||||
if ( !MediaWikiServices::getInstance()->getPermissionManager()
|
||||
->userHasRight( $wgUser, 'rollback' ) ) {
|
||||
|
|
@ -420,10 +425,26 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
|
|||
|
||||
if ( $this->token !== null ) {
|
||||
$title = Title::newFromLinkTarget( $revision->getPageAsLinkTarget() );
|
||||
$revisionCompat = new Revision( $revision );
|
||||
$tokenFunctions = $this->getTokenFunctions();
|
||||
foreach ( $this->token as $t ) {
|
||||
$val = call_user_func( $tokenFunctions[$t], $title->getArticleID(), $title, $revisionCompat );
|
||||
if ( $t === 'rollback' ) {
|
||||
$val = call_user_func(
|
||||
$tokenFunctions[$t],
|
||||
$title->getArticleID(),
|
||||
$title,
|
||||
$revision
|
||||
);
|
||||
} else {
|
||||
// Token function added via APIQueryRevisionsTokens,
|
||||
// Hook is hard deprecated, so any use of
|
||||
// Revision objects is okay
|
||||
$val = call_user_func(
|
||||
$tokenFunctions[$t],
|
||||
$title->getArticleID(),
|
||||
$title,
|
||||
new Revision( $revision )
|
||||
);
|
||||
}
|
||||
if ( $val === false ) {
|
||||
$this->addWarning( [ 'apiwarn-tokennotallowed', $t ] );
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue