2004-12-19 12:21:29 +00:00
|
|
|
<?php
|
2012-05-11 08:34:29 +00:00
|
|
|
/**
|
|
|
|
|
* Representation of a page version.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
2017-02-10 18:09:05 +00:00
|
|
|
|
2020-01-10 00:00:51 +00:00
|
|
|
use MediaWiki\Linker\LinkTarget;
|
|
|
|
|
use MediaWiki\MediaWikiServices;
|
2018-09-20 17:29:04 +00:00
|
|
|
use MediaWiki\Revision\MutableRevisionRecord;
|
|
|
|
|
use MediaWiki\Revision\RevisionAccessException;
|
|
|
|
|
use MediaWiki\Revision\RevisionFactory;
|
|
|
|
|
use MediaWiki\Revision\RevisionLookup;
|
|
|
|
|
use MediaWiki\Revision\RevisionRecord;
|
|
|
|
|
use MediaWiki\Revision\RevisionStore;
|
|
|
|
|
use MediaWiki\Revision\SlotRecord;
|
2017-08-31 18:41:04 +00:00
|
|
|
use MediaWiki\Storage\SqlBlobStore;
|
2018-12-20 18:26:42 +00:00
|
|
|
use Wikimedia\Assert\Assert;
|
2017-02-10 18:09:05 +00:00
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
2004-12-19 12:21:29 +00:00
|
|
|
|
2005-01-27 19:51:47 +00:00
|
|
|
/**
|
2017-08-31 18:41:04 +00:00
|
|
|
* @deprecated since 1.31, use RevisionRecord, RevisionStore, and BlobStore instead.
|
2020-07-02 06:22:52 +00:00
|
|
|
* Hard deprecated since 1.35
|
2005-01-27 19:51:47 +00:00
|
|
|
*/
|
2012-05-23 01:27:29 +00:00
|
|
|
class Revision implements IDBAccessObject {
|
2017-08-31 18:41:04 +00:00
|
|
|
|
|
|
|
|
/** @var RevisionRecord */
|
2020-04-02 17:36:41 +00:00
|
|
|
private $mRecord;
|
2013-10-09 17:03:26 +00:00
|
|
|
|
2012-08-20 14:55:28 +00:00
|
|
|
// Revision deletion constants
|
2019-10-15 23:59:45 +00:00
|
|
|
public const DELETED_TEXT = RevisionRecord::DELETED_TEXT;
|
|
|
|
|
public const DELETED_COMMENT = RevisionRecord::DELETED_COMMENT;
|
|
|
|
|
public const DELETED_USER = RevisionRecord::DELETED_USER;
|
|
|
|
|
public const DELETED_RESTRICTED = RevisionRecord::DELETED_RESTRICTED;
|
|
|
|
|
public const SUPPRESSED_USER = RevisionRecord::SUPPRESSED_USER;
|
|
|
|
|
public const SUPPRESSED_ALL = RevisionRecord::SUPPRESSED_ALL;
|
2012-08-20 14:55:28 +00:00
|
|
|
|
2012-05-23 01:27:29 +00:00
|
|
|
// Audience options for accessors
|
2019-10-15 23:59:45 +00:00
|
|
|
public const FOR_PUBLIC = RevisionRecord::FOR_PUBLIC;
|
|
|
|
|
public const FOR_THIS_USER = RevisionRecord::FOR_THIS_USER;
|
|
|
|
|
public const RAW = RevisionRecord::RAW;
|
2017-08-31 18:41:04 +00:00
|
|
|
|
2019-10-15 23:59:45 +00:00
|
|
|
public const TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP;
|
2008-09-24 09:44:45 +00:00
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
/**
|
2019-11-08 19:58:41 +00:00
|
|
|
* @param string|false $wiki
|
2017-08-31 18:41:04 +00:00
|
|
|
* @return RevisionStore
|
|
|
|
|
*/
|
2020-04-02 17:36:41 +00:00
|
|
|
private static function getRevisionStore( $wiki = false ) {
|
2018-09-30 21:34:59 +00:00
|
|
|
if ( $wiki ) {
|
|
|
|
|
return MediaWikiServices::getInstance()->getRevisionStoreFactory()
|
|
|
|
|
->getRevisionStore( $wiki );
|
|
|
|
|
} else {
|
|
|
|
|
return MediaWikiServices::getInstance()->getRevisionStore();
|
|
|
|
|
}
|
2017-08-31 18:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
2018-01-09 08:53:38 +00:00
|
|
|
/**
|
|
|
|
|
* @return RevisionLookup
|
|
|
|
|
*/
|
2020-04-02 17:36:41 +00:00
|
|
|
private static function getRevisionLookup() {
|
2018-01-09 08:53:38 +00:00
|
|
|
return MediaWikiServices::getInstance()->getRevisionLookup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return RevisionFactory
|
|
|
|
|
*/
|
2020-04-02 17:36:41 +00:00
|
|
|
private static function getRevisionFactory() {
|
2018-01-09 08:53:38 +00:00
|
|
|
return MediaWikiServices::getInstance()->getRevisionFactory();
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
/**
|
2018-01-07 10:38:43 +00:00
|
|
|
* @param bool|string $wiki The ID of the target wiki database. Use false for the local wiki.
|
2017-12-23 17:14:28 +00:00
|
|
|
*
|
2017-08-31 18:41:04 +00:00
|
|
|
* @return SqlBlobStore
|
|
|
|
|
*/
|
2020-04-02 17:36:41 +00:00
|
|
|
private static function getBlobStore( $wiki = false ) {
|
2017-12-23 17:14:28 +00:00
|
|
|
$store = MediaWikiServices::getInstance()
|
|
|
|
|
->getBlobStoreFactory()
|
|
|
|
|
->newSqlBlobStore( $wiki );
|
2017-08-31 18:41:04 +00:00
|
|
|
|
|
|
|
|
if ( !$store instanceof SqlBlobStore ) {
|
|
|
|
|
throw new RuntimeException(
|
|
|
|
|
'The backwards compatibility code in Revision currently requires the BlobStore '
|
|
|
|
|
. 'service to be an SqlBlobStore instance, but it is a ' . get_class( $store )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $store;
|
|
|
|
|
}
|
2016-09-07 22:36:14 +00:00
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
|
|
|
|
* Load a page revision from a given revision ID number.
|
|
|
|
|
* Returns null if no such revision can be found.
|
|
|
|
|
*
|
2020-06-03 02:56:54 +00:00
|
|
|
* @deprecated since 1.31 together with the class. Hard deprecated since 1.35
|
|
|
|
|
*
|
2012-05-23 01:27:29 +00:00
|
|
|
* $flags include:
|
2012-08-20 14:55:28 +00:00
|
|
|
* Revision::READ_LATEST : Select the data from the master
|
|
|
|
|
* Revision::READ_LOCKING : Select & lock the data from the master
|
2012-05-23 01:27:29 +00:00
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $id
|
|
|
|
|
* @param int $flags (optional)
|
|
|
|
|
* @return Revision|null
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2017-12-28 18:34:17 +00:00
|
|
|
public static function newFromId( $id, $flags = 0 ) {
|
2020-06-03 02:56:54 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2018-01-09 08:53:38 +00:00
|
|
|
$rec = self::getRevisionLookup()->getRevisionById( $id, $flags );
|
2019-01-09 15:49:25 +00:00
|
|
|
return $rec ? new Revision( $rec, $flags ) : null;
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
|
|
|
|
* Load either the current, or a specified, revision
|
2016-02-03 15:49:29 +00:00
|
|
|
* that's attached to a given link target. If not attached
|
|
|
|
|
* to that link target, will return null.
|
2004-12-19 12:21:29 +00:00
|
|
|
*
|
2020-04-15 21:50:29 +00:00
|
|
|
* @deprecated since 1.31 together with the class. Hard deprecated since 1.35
|
|
|
|
|
*
|
2012-05-23 01:27:29 +00:00
|
|
|
* $flags include:
|
2012-08-20 14:55:28 +00:00
|
|
|
* Revision::READ_LATEST : Select the data from the master
|
|
|
|
|
* Revision::READ_LOCKING : Select & lock the data from the master
|
2012-05-23 01:27:29 +00:00
|
|
|
*
|
2016-02-03 15:49:29 +00:00
|
|
|
* @param LinkTarget $linkTarget
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $id (optional)
|
|
|
|
|
* @param int $flags Bitfield (optional)
|
|
|
|
|
* @return Revision|null
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2016-02-03 15:49:29 +00:00
|
|
|
public static function newFromTitle( LinkTarget $linkTarget, $id = 0, $flags = 0 ) {
|
2020-04-15 21:50:29 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2018-01-09 08:53:38 +00:00
|
|
|
$rec = self::getRevisionLookup()->getRevisionByTitle( $linkTarget, $id, $flags );
|
2019-01-09 15:49:25 +00:00
|
|
|
return $rec ? new Revision( $rec, $flags ) : null;
|
2005-03-18 04:32:55 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2011-07-01 23:33:34 +00:00
|
|
|
/**
|
|
|
|
|
* Load either the current, or a specified, revision
|
|
|
|
|
* that's attached to a given page ID.
|
|
|
|
|
* Returns null if no such revision can be found.
|
|
|
|
|
*
|
2012-05-23 01:27:29 +00:00
|
|
|
* $flags include:
|
2012-11-08 06:04:02 +00:00
|
|
|
* Revision::READ_LATEST : Select the data from the master (since 1.20)
|
2012-08-20 14:55:28 +00:00
|
|
|
* Revision::READ_LOCKING : Select & lock the data from the master
|
2012-05-23 01:27:29 +00:00
|
|
|
*
|
2020-03-04 02:43:46 +00:00
|
|
|
* @deprecated since 1.31 together with the class. Hard deprecated since 1.35
|
|
|
|
|
*
|
2014-05-05 19:45:53 +00:00
|
|
|
* @param int $pageId
|
|
|
|
|
* @param int $revId (optional)
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $flags Bitfield (optional)
|
|
|
|
|
* @return Revision|null
|
2011-07-01 23:33:34 +00:00
|
|
|
*/
|
2012-09-26 20:40:18 +00:00
|
|
|
public static function newFromPageId( $pageId, $revId = 0, $flags = 0 ) {
|
2020-03-04 02:43:46 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2018-01-09 08:53:38 +00:00
|
|
|
$rec = self::getRevisionLookup()->getRevisionByPageId( $pageId, $revId, $flags );
|
2019-01-09 15:49:25 +00:00
|
|
|
return $rec ? new Revision( $rec, $flags ) : null;
|
2011-07-01 23:33:34 +00:00
|
|
|
}
|
|
|
|
|
|
In Special:RevisionDelete:
* Refactored to remove massive duplication
* Removed page parameter and associated contextPage member variable, doesn't seem to do anything.
* Put ID lists into a single ids parameter and member variable instead of having one for each type.
* Fixed inappropriate call of Title::newFromUrl(), always wrong
* Don't pretend to use the return value from functions that don't return anything, this reduces readability.
* Use the table names for deleteKey/typeName values, they look more like English
* Use protected not private
* Remove requirement for log type to be specified in the target
* Use POST for RevisionDelete entry forms, to avoid URL size limits and issues with non-PATH_INFO URLs
* Don't purge all pages that use the given file
* LocalFile::purgeCache() already calls purgeHistory,() no need to do it again. But do call purgeDescription().
* Removed token from unhide=1 links, unnecessary
* Tokens are necessary on file streaming links, added them
* Fixed private data leakage due to incorrect use of LocalRepo::newFromArchiveName(). Non-existent placeholder file was returned which meant that $oimage->userCan(File::DELETED_FILE) was always true. Pass the archive name to tryShowFile() instead of the storage key.
* Using ls_field='oi_timestamp' is not correct, oi_timestamp refers to the timestamp of the revision in question, whereas the key that is stored is the timestamp of the previous revision (i.e. the timestamp in oi_archive_name). oi_archive_name would be more correct, although only half the field is used.
Elsewhere:
* Added missing message filehist-missing
* Fixed double asterisk in Status::getWikiText()
* Fixed escaping of the target parameter to Special:RevisionDelete from ImagePage
* Deleted FileStore.php. Deprecated in filerepo refactor except for get()/export() but somehow resurrected by RevisionDelete. Hopefully this will be the end of it. New interfaces will be added for wfStreamFile() in a later commit.
* Added convenience function File::getStorageKey(), factored out of Special:Undelete
* Added convenience function Revision::newFromArchiveRow(), factored out of Special:Undelete and Special:RevisionDelete
* Fixed notice in Special:Upload, uninitialised $pageText
FIXME: current revision can be suppressed on undeletion causing an unauthenticated unsuppress. Comments indicate this is a known issue. I fixed the parser cache pollution in this case but not the rest.
2009-06-01 11:37:06 +00:00
|
|
|
/**
|
|
|
|
|
* Make a fake revision object from an archive table row. This is queried
|
|
|
|
|
* for permissions or even inserted (as in Special:Undelete)
|
2011-05-28 19:00:01 +00:00
|
|
|
*
|
2020-04-01 17:47:23 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2020-11-12 22:22:22 +00:00
|
|
|
* @param stdClass $row
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param array $overrides
|
2011-05-29 14:25:20 +00:00
|
|
|
*
|
2012-10-07 23:35:26 +00:00
|
|
|
* @throws MWException
|
2011-05-28 19:00:01 +00:00
|
|
|
* @return Revision
|
In Special:RevisionDelete:
* Refactored to remove massive duplication
* Removed page parameter and associated contextPage member variable, doesn't seem to do anything.
* Put ID lists into a single ids parameter and member variable instead of having one for each type.
* Fixed inappropriate call of Title::newFromUrl(), always wrong
* Don't pretend to use the return value from functions that don't return anything, this reduces readability.
* Use the table names for deleteKey/typeName values, they look more like English
* Use protected not private
* Remove requirement for log type to be specified in the target
* Use POST for RevisionDelete entry forms, to avoid URL size limits and issues with non-PATH_INFO URLs
* Don't purge all pages that use the given file
* LocalFile::purgeCache() already calls purgeHistory,() no need to do it again. But do call purgeDescription().
* Removed token from unhide=1 links, unnecessary
* Tokens are necessary on file streaming links, added them
* Fixed private data leakage due to incorrect use of LocalRepo::newFromArchiveName(). Non-existent placeholder file was returned which meant that $oimage->userCan(File::DELETED_FILE) was always true. Pass the archive name to tryShowFile() instead of the storage key.
* Using ls_field='oi_timestamp' is not correct, oi_timestamp refers to the timestamp of the revision in question, whereas the key that is stored is the timestamp of the previous revision (i.e. the timestamp in oi_archive_name). oi_archive_name would be more correct, although only half the field is used.
Elsewhere:
* Added missing message filehist-missing
* Fixed double asterisk in Status::getWikiText()
* Fixed escaping of the target parameter to Special:RevisionDelete from ImagePage
* Deleted FileStore.php. Deprecated in filerepo refactor except for get()/export() but somehow resurrected by RevisionDelete. Hopefully this will be the end of it. New interfaces will be added for wfStreamFile() in a later commit.
* Added convenience function File::getStorageKey(), factored out of Special:Undelete
* Added convenience function Revision::newFromArchiveRow(), factored out of Special:Undelete and Special:RevisionDelete
* Fixed notice in Special:Upload, uninitialised $pageText
FIXME: current revision can be suppressed on undeletion causing an unauthenticated unsuppress. Comments indicate this is a known issue. I fixed the parser cache pollution in this case but not the rest.
2009-06-01 11:37:06 +00:00
|
|
|
*/
|
2017-12-28 18:57:13 +00:00
|
|
|
public static function newFromArchiveRow( $row, $overrides = [] ) {
|
2020-04-01 17:47:23 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
|
|
|
|
|
2017-12-22 16:39:00 +00:00
|
|
|
/**
|
|
|
|
|
* MCR Migration: https://phabricator.wikimedia.org/T183564
|
|
|
|
|
* This method used to overwrite attributes, then passed to Revision::__construct
|
|
|
|
|
* RevisionStore::newRevisionFromArchiveRow instead overrides row field names
|
|
|
|
|
* So do a conversion here.
|
|
|
|
|
*/
|
|
|
|
|
if ( array_key_exists( 'page', $overrides ) ) {
|
|
|
|
|
$overrides['page_id'] = $overrides['page'];
|
|
|
|
|
unset( $overrides['page'] );
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-28 18:57:13 +00:00
|
|
|
/**
|
|
|
|
|
* We require a Title for both the Revision object and the RevisionRecord.
|
|
|
|
|
* Below is duplicated logic from RevisionStore::newRevisionFromArchiveRow
|
|
|
|
|
* to fetch a title in order pass it into the Revision object.
|
|
|
|
|
*/
|
|
|
|
|
$title = null;
|
|
|
|
|
if ( isset( $overrides['title'] ) ) {
|
|
|
|
|
if ( !( $overrides['title'] instanceof Title ) ) {
|
|
|
|
|
throw new MWException( 'title field override must contain a Title object.' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$title = $overrides['title'];
|
|
|
|
|
}
|
|
|
|
|
if ( $title !== null ) {
|
|
|
|
|
if ( isset( $row->ar_namespace ) && isset( $row->ar_title ) ) {
|
|
|
|
|
$title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
|
|
|
|
|
} else {
|
|
|
|
|
throw new InvalidArgumentException(
|
|
|
|
|
'A Title or ar_namespace and ar_title must be given'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-09 08:53:38 +00:00
|
|
|
$rec = self::getRevisionFactory()->newRevisionFromArchiveRow( $row, 0, $title, $overrides );
|
2017-12-22 14:25:12 +00:00
|
|
|
return new Revision( $rec, self::READ_NORMAL, $title );
|
In Special:RevisionDelete:
* Refactored to remove massive duplication
* Removed page parameter and associated contextPage member variable, doesn't seem to do anything.
* Put ID lists into a single ids parameter and member variable instead of having one for each type.
* Fixed inappropriate call of Title::newFromUrl(), always wrong
* Don't pretend to use the return value from functions that don't return anything, this reduces readability.
* Use the table names for deleteKey/typeName values, they look more like English
* Use protected not private
* Remove requirement for log type to be specified in the target
* Use POST for RevisionDelete entry forms, to avoid URL size limits and issues with non-PATH_INFO URLs
* Don't purge all pages that use the given file
* LocalFile::purgeCache() already calls purgeHistory,() no need to do it again. But do call purgeDescription().
* Removed token from unhide=1 links, unnecessary
* Tokens are necessary on file streaming links, added them
* Fixed private data leakage due to incorrect use of LocalRepo::newFromArchiveName(). Non-existent placeholder file was returned which meant that $oimage->userCan(File::DELETED_FILE) was always true. Pass the archive name to tryShowFile() instead of the storage key.
* Using ls_field='oi_timestamp' is not correct, oi_timestamp refers to the timestamp of the revision in question, whereas the key that is stored is the timestamp of the previous revision (i.e. the timestamp in oi_archive_name). oi_archive_name would be more correct, although only half the field is used.
Elsewhere:
* Added missing message filehist-missing
* Fixed double asterisk in Status::getWikiText()
* Fixed escaping of the target parameter to Special:RevisionDelete from ImagePage
* Deleted FileStore.php. Deprecated in filerepo refactor except for get()/export() but somehow resurrected by RevisionDelete. Hopefully this will be the end of it. New interfaces will be added for wfStreamFile() in a later commit.
* Added convenience function File::getStorageKey(), factored out of Special:Undelete
* Added convenience function Revision::newFromArchiveRow(), factored out of Special:Undelete and Special:RevisionDelete
* Fixed notice in Special:Upload, uninitialised $pageText
FIXME: current revision can be suppressed on undeletion causing an unauthenticated unsuppress. Comments indicate this is a known issue. I fixed the parser cache pollution in this case but not the rest.
2009-06-01 11:37:06 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-04 23:25:34 +00:00
|
|
|
/**
|
2011-08-05 12:29:39 +00:00
|
|
|
* @since 1.19
|
2011-08-05 16:05:41 +00:00
|
|
|
*
|
2017-08-31 18:41:04 +00:00
|
|
|
* MCR migration note: replaced by RevisionStore::newRevisionFromRow(). Note that
|
|
|
|
|
* newFromRow() also accepts arrays, while newRevisionFromRow() does not. Instead,
|
2017-12-27 15:46:03 +00:00
|
|
|
* a MutableRevisionRecord should be constructed directly.
|
|
|
|
|
* RevisionStore::newMutableRevisionFromArray() can be used as a temporary replacement,
|
|
|
|
|
* but should be avoided.
|
2017-08-31 18:41:04 +00:00
|
|
|
*
|
2020-03-06 06:16:49 +00:00
|
|
|
* @deprecated since 1.31 together with the Revision class. Hard deprecated since 1.35
|
2020-11-12 22:22:22 +00:00
|
|
|
* @param stdClass|array $row
|
2011-08-04 23:25:34 +00:00
|
|
|
* @return Revision
|
|
|
|
|
*/
|
|
|
|
|
public static function newFromRow( $row ) {
|
2020-03-06 06:16:49 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( is_array( $row ) ) {
|
2018-01-09 08:53:38 +00:00
|
|
|
$rec = self::getRevisionFactory()->newMutableRevisionFromArray( $row );
|
2017-08-31 18:41:04 +00:00
|
|
|
} else {
|
2018-01-09 08:53:38 +00:00
|
|
|
$rec = self::getRevisionFactory()->newRevisionFromRow( $row );
|
2017-08-31 18:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Revision( $rec );
|
2011-08-04 23:25:34 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-18 04:32:55 +00:00
|
|
|
/**
|
|
|
|
|
* Load either the current, or a specified, revision
|
|
|
|
|
* that's attached to a given page. If not attached
|
|
|
|
|
* to that page, will return null.
|
|
|
|
|
*
|
2017-08-31 18:41:04 +00:00
|
|
|
* @deprecated since 1.31, use RevisionStore::getRevisionByPageId() instead.
|
2020-03-04 01:02:30 +00:00
|
|
|
* Hard deprecated since 1.35
|
2017-08-31 18:41:04 +00:00
|
|
|
*
|
2015-10-04 09:07:25 +00:00
|
|
|
* @param IDatabase $db
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $pageid
|
|
|
|
|
* @param int $id
|
|
|
|
|
* @return Revision|null
|
2005-03-18 04:32:55 +00:00
|
|
|
*/
|
2007-01-22 23:50:42 +00:00
|
|
|
public static function loadFromPageId( $db, $pageid, $id = 0 ) {
|
2020-03-04 01:02:30 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
$rec = self::getRevisionStore()->loadRevisionFromPageId( $db, $pageid, $id );
|
2019-01-09 15:49:25 +00:00
|
|
|
return $rec ? new Revision( $rec ) : null;
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2005-06-28 23:19:56 +00:00
|
|
|
/**
|
|
|
|
|
* Load either the current, or a specified, revision
|
|
|
|
|
* that's attached to a given page. If not attached
|
|
|
|
|
* to that page, will return null.
|
|
|
|
|
*
|
2017-08-31 18:41:04 +00:00
|
|
|
* @deprecated since 1.31, use RevisionStore::getRevisionByTitle() instead.
|
2020-02-29 00:22:03 +00:00
|
|
|
* Hard deprecated in 1.35
|
2017-08-31 18:41:04 +00:00
|
|
|
*
|
2015-10-04 09:07:25 +00:00
|
|
|
* @param IDatabase $db
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param Title $title
|
|
|
|
|
* @param int $id
|
|
|
|
|
* @return Revision|null
|
2005-06-28 23:19:56 +00:00
|
|
|
*/
|
2008-05-23 07:33:35 +00:00
|
|
|
public static function loadFromTitle( $db, $title, $id = 0 ) {
|
2020-02-29 00:22:03 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
$rec = self::getRevisionStore()->loadRevisionFromTitle( $db, $title, $id );
|
2019-01-09 15:49:25 +00:00
|
|
|
return $rec ? new Revision( $rec ) : null;
|
2005-06-28 23:19:56 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2005-04-26 09:52:11 +00:00
|
|
|
/**
|
|
|
|
|
* Load the revision for the given title with the given timestamp.
|
|
|
|
|
* WARNING: Timestamps may in some circumstances not be unique,
|
|
|
|
|
* so this isn't the best key to use.
|
|
|
|
|
*
|
2017-12-27 15:46:03 +00:00
|
|
|
* @deprecated since 1.31, use RevisionStore::getRevisionByTimestamp()
|
2020-03-04 01:39:36 +00:00
|
|
|
* or RevisionStore::loadRevisionFromTimestamp() instead. Hard deprecated since 1.35
|
2017-08-31 18:41:04 +00:00
|
|
|
*
|
2015-10-04 09:07:25 +00:00
|
|
|
* @param IDatabase $db
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param Title $title
|
|
|
|
|
* @param string $timestamp
|
|
|
|
|
* @return Revision|null
|
2005-04-26 09:52:11 +00:00
|
|
|
*/
|
2008-05-23 07:33:35 +00:00
|
|
|
public static function loadFromTimestamp( $db, $title, $timestamp ) {
|
2020-03-04 01:39:36 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
$rec = self::getRevisionStore()->loadRevisionFromTimestamp( $db, $title, $timestamp );
|
2019-01-09 15:49:25 +00:00
|
|
|
return $rec ? new Revision( $rec ) : null;
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2017-10-06 17:03:55 +00:00
|
|
|
/**
|
|
|
|
|
* Return the tables, fields, and join conditions to be selected to create
|
|
|
|
|
* a new revision object.
|
|
|
|
|
* @since 1.31
|
2020-03-26 22:40:22 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard), use RevisionStore::getQueryInfo() instead.
|
2017-10-06 17:03:55 +00:00
|
|
|
* @param array $options Any combination of the following strings
|
|
|
|
|
* - 'page': Join with the page table, and select fields to identify the page
|
|
|
|
|
* - 'user': Join with the user table, and select the user name
|
|
|
|
|
* - 'text': Join with the text table, and select fields to load page text
|
|
|
|
|
* @return array With three keys:
|
|
|
|
|
* - tables: (string[]) to include in the `$table` to `IDatabase->select()`
|
|
|
|
|
* - fields: (string[]) to include in the `$vars` to `IDatabase->select()`
|
|
|
|
|
* - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
|
|
|
|
|
*/
|
|
|
|
|
public static function getQueryInfo( $options = [] ) {
|
2020-03-26 22:40:22 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return self::getRevisionStore()->getQueryInfo( $options );
|
2017-10-06 17:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the tables, fields, and join conditions to be selected to create
|
|
|
|
|
* a new archived revision object.
|
|
|
|
|
* @since 1.31
|
2020-03-26 22:40:22 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard), use RevisionStore::getArchiveQueryInfo()
|
|
|
|
|
* instead.
|
2017-10-06 17:03:55 +00:00
|
|
|
* @return array With three keys:
|
|
|
|
|
* - tables: (string[]) to include in the `$table` to `IDatabase->select()`
|
|
|
|
|
* - fields: (string[]) to include in the `$vars` to `IDatabase->select()`
|
|
|
|
|
* - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
|
|
|
|
|
*/
|
|
|
|
|
public static function getArchiveQueryInfo() {
|
2020-03-26 22:40:22 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return self::getRevisionStore()->getArchiveQueryInfo();
|
2017-10-06 17:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-16 07:47:11 +00:00
|
|
|
/**
|
|
|
|
|
* Do a batched query to get the parent revision lengths
|
2017-12-27 15:46:03 +00:00
|
|
|
*
|
|
|
|
|
* @deprecated in 1.31, use RevisionStore::getRevisionSizes instead.
|
2020-03-07 02:10:00 +00:00
|
|
|
* Hard deprecated since 1.35.
|
2017-12-27 15:46:03 +00:00
|
|
|
*
|
2015-10-04 09:07:25 +00:00
|
|
|
* @param IDatabase $db
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param array $revIds
|
2012-06-16 07:47:11 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public static function getParentLengths( $db, array $revIds ) {
|
2020-03-07 02:10:00 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
|
|
|
|
return self::getRevisionStore()->getRevisionSizes( $revIds );
|
2012-06-16 07:47:11 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
2020-11-12 22:22:22 +00:00
|
|
|
* @param stdClass|array|RevisionRecord $row Either a database row or an array
|
2017-08-31 18:41:04 +00:00
|
|
|
* @param int $queryFlags
|
|
|
|
|
* @param Title|null $title
|
|
|
|
|
*
|
2020-06-21 02:22:18 +00:00
|
|
|
* Since 1.35, constructing with anything other than a RevisionRecord is hard deprecated
|
|
|
|
|
* (since 1.31 the entire class is deprecated)
|
|
|
|
|
*
|
2020-06-26 12:14:23 +00:00
|
|
|
* @internal
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2019-11-30 22:32:44 +00:00
|
|
|
public function __construct( $row, $queryFlags = 0, Title $title = null ) {
|
2020-07-02 06:22:52 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
|
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
global $wgUser;
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( $row instanceof RevisionRecord ) {
|
|
|
|
|
$this->mRecord = $row;
|
|
|
|
|
} elseif ( is_array( $row ) ) {
|
2017-12-27 15:46:03 +00:00
|
|
|
// If no user is specified, fall back to using the global user object, to stay
|
|
|
|
|
// compatible with pre-1.31 behavior.
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( !isset( $row['user'] ) && !isset( $row['user_text'] ) ) {
|
|
|
|
|
$row['user'] = $wgUser;
|
|
|
|
|
}
|
2017-12-19 10:42:34 +00:00
|
|
|
|
2018-01-09 08:53:38 +00:00
|
|
|
$this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
|
2017-08-31 18:41:04 +00:00
|
|
|
$row,
|
|
|
|
|
$queryFlags,
|
2018-01-11 15:43:18 +00:00
|
|
|
$this->ensureTitle( $row, $queryFlags, $title )
|
2017-08-31 18:41:04 +00:00
|
|
|
);
|
|
|
|
|
} elseif ( is_object( $row ) ) {
|
2018-01-09 08:53:38 +00:00
|
|
|
$this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
|
2017-08-31 18:41:04 +00:00
|
|
|
$row,
|
|
|
|
|
$queryFlags,
|
2018-01-11 15:43:18 +00:00
|
|
|
$this->ensureTitle( $row, $queryFlags, $title )
|
2017-08-31 18:41:04 +00:00
|
|
|
);
|
2017-12-19 10:42:34 +00:00
|
|
|
} else {
|
2017-08-31 18:41:04 +00:00
|
|
|
throw new InvalidArgumentException(
|
|
|
|
|
'$row must be a row object, an associative array, or a RevisionRecord'
|
|
|
|
|
);
|
2017-12-19 10:42:34 +00:00
|
|
|
}
|
2018-12-20 18:26:42 +00:00
|
|
|
|
|
|
|
|
Assert::postcondition( $this->mRecord !== null, 'Failed to construct a RevisionRecord' );
|
2017-10-11 12:57:47 +00:00
|
|
|
}
|
2012-04-30 16:23:17 +00:00
|
|
|
|
2018-01-11 15:43:18 +00:00
|
|
|
/**
|
|
|
|
|
* Make sure we have *some* Title object for use by the constructor.
|
|
|
|
|
* For B/C, the constructor shouldn't fail even for a bad page ID or bad revision ID.
|
|
|
|
|
*
|
2020-11-12 22:22:22 +00:00
|
|
|
* @param array|stdClass $row
|
2018-01-11 15:43:18 +00:00
|
|
|
* @param int $queryFlags
|
|
|
|
|
* @param Title|null $title
|
|
|
|
|
*
|
2021-01-11 22:36:33 +00:00
|
|
|
* @throws RevisionAccessException if title can not be found
|
2018-01-11 15:43:18 +00:00
|
|
|
* @return Title $title if not null, or a Title constructed from information in $row.
|
|
|
|
|
*/
|
|
|
|
|
private function ensureTitle( $row, $queryFlags, $title = null ) {
|
|
|
|
|
if ( $title ) {
|
|
|
|
|
return $title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( is_array( $row ) ) {
|
|
|
|
|
if ( isset( $row['title'] ) ) {
|
|
|
|
|
if ( !( $row['title'] instanceof Title ) ) {
|
|
|
|
|
throw new MWException( 'title field must contain a Title object.' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $row['title'];
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-06 22:17:58 +00:00
|
|
|
$pageId = $row['page'] ?? 0;
|
|
|
|
|
$revId = $row['id'] ?? 0;
|
2018-01-11 15:43:18 +00:00
|
|
|
} else {
|
2017-10-06 22:17:58 +00:00
|
|
|
$pageId = $row->rev_page ?? 0;
|
|
|
|
|
$revId = $row->rev_id ?? 0;
|
2018-01-11 15:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-11 22:36:33 +00:00
|
|
|
return self::getRevisionStore()->getTitle( $pageId, $revId, $queryFlags );
|
2018-01-11 15:43:18 +00:00
|
|
|
}
|
|
|
|
|
|
2017-10-11 12:57:47 +00:00
|
|
|
/**
|
2020-07-02 06:22:52 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
2017-08-31 18:41:04 +00:00
|
|
|
* @return RevisionRecord
|
2017-10-11 12:57:47 +00:00
|
|
|
*/
|
2017-08-31 18:41:04 +00:00
|
|
|
public function getRevisionRecord() {
|
2020-07-02 06:22:52 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return $this->mRecord;
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
2008-04-07 23:53:57 +00:00
|
|
|
* Get revision ID
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-07-02 06:22:52 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return int|null
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function getId() {
|
2020-07-02 06:22:52 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return $this->mRecord->getId();
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2012-01-21 07:59:25 +00:00
|
|
|
/**
|
|
|
|
|
* Set the revision ID
|
|
|
|
|
*
|
2017-08-31 18:41:04 +00:00
|
|
|
* This should only be used for proposed revisions that turn out to be null edits.
|
|
|
|
|
*
|
|
|
|
|
* @note Only supported on Revisions that were constructed based on associative arrays,
|
|
|
|
|
* since they are mutable.
|
2016-06-10 06:22:45 +00:00
|
|
|
*
|
2020-04-11 10:21:10 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
2012-01-21 07:59:25 +00:00
|
|
|
* @since 1.19
|
2017-08-31 18:41:04 +00:00
|
|
|
* @param int|string $id
|
|
|
|
|
* @throws MWException
|
2012-01-21 07:59:25 +00:00
|
|
|
*/
|
|
|
|
|
public function setId( $id ) {
|
2020-04-11 10:21:10 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( $this->mRecord instanceof MutableRevisionRecord ) {
|
|
|
|
|
$this->mRecord->setId( intval( $id ) );
|
|
|
|
|
} else {
|
|
|
|
|
throw new MWException( __METHOD__ . ' is not supported on this instance' );
|
|
|
|
|
}
|
2016-06-10 06:22:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This should only be used for proposed revisions that turn out to be null edits
|
|
|
|
|
*
|
2017-08-31 18:41:04 +00:00
|
|
|
* @note Only supported on Revisions that were constructed based on associative arrays,
|
|
|
|
|
* since they are mutable.
|
|
|
|
|
*
|
2016-06-10 06:22:45 +00:00
|
|
|
* @since 1.28
|
2020-03-30 00:20:45 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard), please reuse old Revision object
|
2017-08-20 11:20:59 +00:00
|
|
|
* @param int $id User ID
|
2016-06-10 06:22:45 +00:00
|
|
|
* @param string $name User name
|
2017-08-31 18:41:04 +00:00
|
|
|
* @throws MWException
|
2016-06-10 06:22:45 +00:00
|
|
|
*/
|
|
|
|
|
public function setUserIdAndName( $id, $name ) {
|
2020-03-30 00:20:45 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( $this->mRecord instanceof MutableRevisionRecord ) {
|
2017-09-12 17:12:29 +00:00
|
|
|
$user = User::newFromAnyId( intval( $id ), $name, null );
|
2017-08-31 18:41:04 +00:00
|
|
|
$this->mRecord->setUser( $user );
|
|
|
|
|
} else {
|
|
|
|
|
throw new MWException( __METHOD__ . ' is not supported on this instance' );
|
|
|
|
|
}
|
2012-01-21 07:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-28 10:47:12 +00:00
|
|
|
/**
|
2019-12-17 16:20:32 +00:00
|
|
|
* @return SlotRecord|null
|
2017-08-31 18:41:04 +00:00
|
|
|
*/
|
|
|
|
|
private function getMainSlotRaw() {
|
2019-12-17 16:20:32 +00:00
|
|
|
if ( !$this->mRecord->hasSlot( SlotRecord::MAIN ) ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-24 21:10:08 +00:00
|
|
|
return $this->mRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW );
|
2017-08-31 18:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the ID of the row of the text table that contains the content of the
|
|
|
|
|
* revision's main slot, if that content is stored in the text table.
|
|
|
|
|
*
|
|
|
|
|
* If the content is stored elsewhere, this returns null.
|
|
|
|
|
*
|
2020-03-30 17:52:30 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard), use
|
|
|
|
|
* RevisionRecord()->getSlot()->getContentAddress() to
|
2017-08-31 18:41:04 +00:00
|
|
|
* get that actual address that can be used with BlobStore::getBlob(); or use
|
|
|
|
|
* RevisionRecord::hasSameContent() to check if two revisions have the same content.
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return int|null
|
2005-03-28 10:47:12 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function getTextId() {
|
2020-03-30 17:52:30 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
$slot = $this->getMainSlotRaw();
|
2019-12-17 16:20:32 +00:00
|
|
|
return $slot && $slot->hasAddress()
|
2017-08-31 18:41:04 +00:00
|
|
|
? self::getBlobStore()->getTextIdFromAddress( $slot->getAddress() )
|
|
|
|
|
: null;
|
2005-03-28 10:47:12 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-07 23:53:57 +00:00
|
|
|
/**
|
|
|
|
|
* Get parent revision ID (the original previous page revision)
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-05-27 22:49:07 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2017-08-31 18:41:04 +00:00
|
|
|
* @return int|null The ID of the parent revision. 0 indicates that there is no
|
|
|
|
|
* parent revision. Null indicates that the parent revision is not known.
|
2008-04-07 23:53:57 +00:00
|
|
|
*/
|
|
|
|
|
public function getParentId() {
|
2020-05-27 22:49:07 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return $this->mRecord->getParentId();
|
2008-04-07 23:53:57 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2007-03-08 03:07:58 +00:00
|
|
|
/**
|
|
|
|
|
* Returns the length of the text in this revision, or null if unknown.
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-06-10 05:16:47 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2018-01-11 12:40:53 +00:00
|
|
|
* @return int|null
|
2007-03-08 03:07:58 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function getSize() {
|
2020-06-10 05:16:47 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2018-01-11 12:40:53 +00:00
|
|
|
try {
|
|
|
|
|
return $this->mRecord->getSize();
|
|
|
|
|
} catch ( RevisionAccessException $ex ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2007-03-08 03:07:58 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-27 18:44:10 +00:00
|
|
|
/**
|
2017-08-31 18:41:04 +00:00
|
|
|
* Returns the base36 sha1 of the content in this revision, or null if unknown.
|
2011-10-27 18:44:10 +00:00
|
|
|
*
|
2020-04-29 05:37:47 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2018-01-11 12:40:53 +00:00
|
|
|
* @return string|null
|
2011-10-27 18:44:10 +00:00
|
|
|
*/
|
|
|
|
|
public function getSha1() {
|
2020-04-29 05:37:47 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2018-01-11 12:40:53 +00:00
|
|
|
try {
|
|
|
|
|
return $this->mRecord->getSha1();
|
|
|
|
|
} catch ( RevisionAccessException $ex ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2011-10-27 18:44:10 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
2017-08-31 18:41:04 +00:00
|
|
|
* Returns the title of the page associated with this entry.
|
|
|
|
|
* Since 1.31, this will never return null.
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-07-02 06:22:52 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2012-06-05 22:58:54 +00:00
|
|
|
* Will do a query, when title is not set and id is given.
|
|
|
|
|
*
|
2017-08-31 18:41:04 +00:00
|
|
|
* @return Title
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function getTitle() {
|
2020-07-02 06:22:52 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2021-01-11 22:36:33 +00:00
|
|
|
return Title::castFromPageIdentity( $this->mRecord->getPage() );
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2006-06-11 04:48:27 +00:00
|
|
|
/**
|
|
|
|
|
* Set the title of the revision
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2018-07-26 16:31:49 +00:00
|
|
|
* @deprecated since 1.31, this is now a noop. Pass the Title to the constructor instead.
|
2020-03-25 20:48:59 +00:00
|
|
|
* hard deprecated since 1.35
|
2017-08-31 18:41:04 +00:00
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param Title $title
|
2006-06-11 04:48:27 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function setTitle( $title ) {
|
2020-03-25 20:48:59 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( !$title->equals( $this->getTitle() ) ) {
|
|
|
|
|
throw new InvalidArgumentException(
|
|
|
|
|
$title->getPrefixedText()
|
|
|
|
|
. ' is not the same as '
|
|
|
|
|
. $this->mRecord->getPageAsLinkTarget()->__toString()
|
|
|
|
|
);
|
|
|
|
|
}
|
2006-06-11 04:48:27 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-12 12:50:43 +00:00
|
|
|
/**
|
2008-04-07 23:53:57 +00:00
|
|
|
* Get the page ID
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-06-10 03:50:26 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return int|null
|
2005-03-12 12:50:43 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function getPage() {
|
2020-06-10 03:50:26 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return $this->mRecord->getPageId();
|
2005-03-12 12:50:43 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
2008-09-24 09:44:45 +00:00
|
|
|
* Fetch revision's user id if it's available to the specified audience.
|
2011-05-25 15:39:47 +00:00
|
|
|
* If the specified audience does not have access to it, zero will be
|
2008-09-24 09:44:45 +00:00
|
|
|
* returned.
|
|
|
|
|
*
|
2020-07-02 06:22:52 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @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 ID regardless of permissions
|
2017-08-07 14:55:20 +00:00
|
|
|
* @param User|null $user User object to check for, only if FOR_THIS_USER is passed
|
2020-03-26 03:12:58 +00:00
|
|
|
* to the $audience parameter (not passing for FOR_THIS_USER is deprecated since 1.35)
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return int
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2011-10-12 15:09:04 +00:00
|
|
|
public function getUser( $audience = self::FOR_PUBLIC, User $user = null ) {
|
2020-07-02 06:22:52 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( $audience === self::FOR_THIS_USER && !$user ) {
|
2020-03-26 03:12:58 +00:00
|
|
|
global $wgUser;
|
2017-08-31 18:41:04 +00:00
|
|
|
$user = $wgUser;
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2017-08-31 18:41:04 +00:00
|
|
|
|
|
|
|
|
$user = $this->mRecord->getUser( $audience, $user );
|
|
|
|
|
return $user ? $user->getId() : 0;
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
2008-09-24 09:44:45 +00:00
|
|
|
* Fetch revision's username if it's available to the specified audience.
|
2011-05-25 15:39:47 +00:00
|
|
|
* If the specified audience does not have access to the username, an
|
2008-09-24 09:44:45 +00:00
|
|
|
* empty string will be returned.
|
|
|
|
|
*
|
2020-05-26 22:01:54 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @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
|
2017-08-07 14:55:20 +00:00
|
|
|
* @param User|null $user User object to check for, only if FOR_THIS_USER is passed
|
2020-03-26 03:12:58 +00:00
|
|
|
* to the $audience parameter (not passing for FOR_THIS_USER is deprecated since 1.35)
|
2004-12-19 12:21:29 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2011-10-12 15:09:04 +00:00
|
|
|
public function getUserText( $audience = self::FOR_PUBLIC, User $user = null ) {
|
2020-05-26 22:01:54 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( $audience === self::FOR_THIS_USER && !$user ) {
|
2020-03-26 03:12:58 +00:00
|
|
|
global $wgUser;
|
2017-08-31 18:41:04 +00:00
|
|
|
$user = $wgUser;
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2017-08-31 18:41:04 +00:00
|
|
|
|
|
|
|
|
$user = $this->mRecord->getUser( $audience, $user );
|
|
|
|
|
return $user ? $user->getName() : '';
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2019-01-15 15:04:58 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
2020-06-10 03:50:26 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @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
|
2017-08-07 14:55:20 +00:00
|
|
|
* @param User|null $user User object to check for, only if FOR_THIS_USER is passed
|
2020-03-26 03:12:58 +00:00
|
|
|
* to the $audience parameter (not passing for FOR_THIS_USER is deprecated since 1.35)
|
2019-01-15 13:30:45 +00:00
|
|
|
*
|
|
|
|
|
* @return string|null Returns null if the specified audience does not have access to the
|
|
|
|
|
* comment.
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2019-11-30 22:32:44 +00:00
|
|
|
public function getComment( $audience = self::FOR_PUBLIC, User $user = null ) {
|
2020-06-10 03:50:26 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( $audience === self::FOR_THIS_USER && !$user ) {
|
2020-03-26 03:12:58 +00:00
|
|
|
global $wgUser;
|
2017-08-31 18:41:04 +00:00
|
|
|
$user = $wgUser;
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2017-08-31 18:41:04 +00:00
|
|
|
|
|
|
|
|
$comment = $this->mRecord->getComment( $audience, $user );
|
|
|
|
|
return $comment === null ? null : $comment->text;
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
2020-05-26 22:01:54 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return bool
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function isMinor() {
|
2020-05-26 22:01:54 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return $this->mRecord->isMinor();
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2011-05-25 15:39:47 +00:00
|
|
|
|
2009-01-15 17:53:19 +00:00
|
|
|
/**
|
2020-03-27 19:20:38 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return int Rcid of the unpatrolled row, zero if there isn't one
|
2009-01-15 17:53:19 +00:00
|
|
|
*/
|
|
|
|
|
public function isUnpatrolled() {
|
2020-03-27 19:20:38 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-12-27 15:46:03 +00:00
|
|
|
return self::getRevisionStore()->getRcIdIfUnpatrolled( $this->mRecord );
|
2013-06-09 00:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the RC object belonging to the current revision, if there's one
|
|
|
|
|
*
|
2020-03-30 17:52:30 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2015-09-28 18:34:05 +00:00
|
|
|
* @param int $flags (optional) $flags include:
|
|
|
|
|
* Revision::READ_LATEST : Select the data from the master
|
|
|
|
|
*
|
2013-06-09 00:44:01 +00:00
|
|
|
* @since 1.22
|
|
|
|
|
* @return RecentChange|null
|
|
|
|
|
*/
|
2015-09-28 18:34:05 +00:00
|
|
|
public function getRecentChange( $flags = 0 ) {
|
2020-03-30 17:52:30 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return self::getRevisionStore()->getRecentChange( $this->mRecord, $flags );
|
2009-01-15 17:53:19 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2005-03-31 11:40:05 +00:00
|
|
|
/**
|
2014-07-24 17:42:24 +00:00
|
|
|
* @param int $field One of DELETED_* bitfield constants
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-06-03 00:21:00 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return bool
|
2005-03-31 11:40:05 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function isDeleted( $field ) {
|
2020-06-03 00:21:00 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return $this->mRecord->isDeleted( $field );
|
2005-03-31 11:40:05 +00:00
|
|
|
}
|
2009-10-19 11:15:51 +00:00
|
|
|
|
2008-10-19 05:47:23 +00:00
|
|
|
/**
|
|
|
|
|
* Get the deletion bitfield of the revision
|
2011-08-03 00:19:27 +00:00
|
|
|
*
|
2020-05-27 22:49:07 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2011-08-03 00:19:27 +00:00
|
|
|
* @return int
|
2010-02-07 17:03:51 +00:00
|
|
|
*/
|
2008-10-19 05:47:23 +00:00
|
|
|
public function getVisibility() {
|
2020-05-27 22:49:07 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return $this->mRecord->getVisibility();
|
2008-10-19 05:47:23 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2012-04-30 16:23:17 +00:00
|
|
|
/**
|
|
|
|
|
* Fetch revision content if it's available to the specified audience.
|
|
|
|
|
* If the specified audience does not have the ability to view this
|
2017-08-31 18:41:04 +00:00
|
|
|
* revision, or the content could not be loaded, null will be returned.
|
2012-04-30 16:23:17 +00:00
|
|
|
*
|
2020-06-08 02:38:00 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $audience One of:
|
|
|
|
|
* Revision::FOR_PUBLIC to be displayed to all users
|
2017-08-31 18:41:04 +00:00
|
|
|
* Revision::FOR_THIS_USER to be displayed to $user
|
2014-04-23 09:25:56 +00:00
|
|
|
* Revision::RAW get the text regardless of permissions
|
2018-06-26 21:14:43 +00:00
|
|
|
* @param User|null $user User object to check for, only if FOR_THIS_USER is passed
|
2014-04-23 09:25:56 +00:00
|
|
|
* to the $audience parameter
|
2012-10-05 13:03:24 +00:00
|
|
|
* @since 1.21
|
2012-10-17 22:04:22 +00:00
|
|
|
* @return Content|null
|
2012-04-30 16:23:17 +00:00
|
|
|
*/
|
|
|
|
|
public function getContent( $audience = self::FOR_PUBLIC, User $user = null ) {
|
2020-06-08 02:38:00 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
|
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
global $wgUser;
|
|
|
|
|
|
|
|
|
|
if ( $audience === self::FOR_THIS_USER && !$user ) {
|
|
|
|
|
$user = $wgUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2018-09-24 21:10:08 +00:00
|
|
|
return $this->mRecord->getContent( SlotRecord::MAIN, $audience, $user );
|
2017-08-31 18:41:04 +00:00
|
|
|
}
|
|
|
|
|
catch ( RevisionAccessException $e ) {
|
2012-04-30 16:23:17 +00:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-05 11:53:21 +00:00
|
|
|
|
2012-06-07 15:23:05 +00:00
|
|
|
/**
|
2016-09-07 01:34:43 +00:00
|
|
|
* Get original serialized data (without checking view restrictions)
|
2012-06-07 15:23:05 +00:00
|
|
|
*
|
2012-10-05 13:03:24 +00:00
|
|
|
* @since 1.21
|
2020-03-31 16:26:16 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard), use BlobStore::getBlob instead.
|
2017-08-31 18:41:04 +00:00
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return string
|
2012-06-07 15:23:05 +00:00
|
|
|
*/
|
|
|
|
|
public function getSerializedData() {
|
2020-03-31 16:26:16 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
$slot = $this->getMainSlotRaw();
|
2019-12-17 16:20:32 +00:00
|
|
|
return $slot ? $slot->getContent()->serialize() : '';
|
2012-06-07 15:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-21 09:49:01 +00:00
|
|
|
/**
|
2017-08-31 18:41:04 +00:00
|
|
|
* Returns the content model for the main slot of this revision.
|
2012-05-13 22:02:29 +00:00
|
|
|
*
|
2015-07-02 07:40:40 +00:00
|
|
|
* If no content model was stored in the database, the default content model for the title is
|
2012-05-13 22:02:29 +00:00
|
|
|
* used to determine the content model to use. If no title is know, CONTENT_MODEL_WIKITEXT
|
|
|
|
|
* is used as a last resort.
|
|
|
|
|
*
|
2020-06-03 23:01:21 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
2017-08-31 18:41:04 +00:00
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return string The content model id associated with this revision,
|
2013-12-07 20:58:53 +00:00
|
|
|
* see the CONTENT_MODEL_XXX constants.
|
2016-12-08 16:23:46 +00:00
|
|
|
*/
|
2012-05-13 22:02:29 +00:00
|
|
|
public function getContentModel() {
|
2020-06-03 23:01:21 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
|
|
|
|
|
2019-12-17 16:20:32 +00:00
|
|
|
$slot = $this->getMainSlotRaw();
|
|
|
|
|
|
|
|
|
|
if ( $slot ) {
|
|
|
|
|
return $slot->getModel();
|
|
|
|
|
} else {
|
|
|
|
|
$slotRoleRegistry = MediaWikiServices::getInstance()->getSlotRoleRegistry();
|
|
|
|
|
$slotRoleHandler = $slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
|
|
|
|
|
return $slotRoleHandler->getDefaultModel( $this->getTitle() );
|
|
|
|
|
}
|
2012-04-30 16:23:17 +00:00
|
|
|
}
|
2012-03-05 11:53:21 +00:00
|
|
|
|
2012-05-13 22:02:29 +00:00
|
|
|
/**
|
2017-08-31 18:41:04 +00:00
|
|
|
* Returns the content format for the main slot of this revision.
|
2012-05-13 22:02:29 +00:00
|
|
|
*
|
|
|
|
|
* If no content format was stored in the database, the default format for this
|
|
|
|
|
* revision's content model is returned.
|
|
|
|
|
*
|
2020-06-03 23:01:21 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
2017-08-31 18:41:04 +00:00
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return string The content format id associated with this revision,
|
2013-12-07 20:58:53 +00:00
|
|
|
* see the CONTENT_FORMAT_XXX constants.
|
2016-12-08 16:23:46 +00:00
|
|
|
*/
|
2012-04-30 16:23:17 +00:00
|
|
|
public function getContentFormat() {
|
2020-06-03 23:01:21 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
|
|
|
|
|
2019-12-17 16:20:32 +00:00
|
|
|
$slot = $this->getMainSlotRaw();
|
|
|
|
|
$format = $slot ? $this->getMainSlotRaw()->getFormat() : null;
|
2012-05-13 22:02:29 +00:00
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( $format === null ) {
|
|
|
|
|
// if no format was stored along with the blob, fall back to default format
|
|
|
|
|
$format = $this->getContentHandler()->getDefaultFormat();
|
2012-04-30 16:23:17 +00:00
|
|
|
}
|
2012-03-05 11:53:21 +00:00
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
return $format;
|
2012-04-30 16:23:17 +00:00
|
|
|
}
|
2012-03-05 11:53:21 +00:00
|
|
|
|
2012-04-23 09:30:24 +00:00
|
|
|
/**
|
2012-05-13 22:02:29 +00:00
|
|
|
* Returns the content handler appropriate for this revision's content model.
|
|
|
|
|
*
|
2020-06-03 23:01:21 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2012-10-17 22:04:22 +00:00
|
|
|
* @throws MWException
|
2012-05-02 10:54:27 +00:00
|
|
|
* @return ContentHandler
|
2012-04-23 09:30:24 +00:00
|
|
|
*/
|
2012-04-30 16:23:17 +00:00
|
|
|
public function getContentHandler() {
|
2020-06-03 23:01:21 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
|
|
|
|
|
2020-01-18 20:25:04 +00:00
|
|
|
return MediaWikiServices::getInstance()
|
|
|
|
|
->getContentHandlerFactory()
|
|
|
|
|
->getContentHandler( $this->getContentModel() );
|
2012-04-30 16:23:17 +00:00
|
|
|
}
|
2012-03-05 11:53:21 +00:00
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
2020-06-10 16:52:09 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return string
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function getTimestamp() {
|
2020-06-10 16:52:09 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return $this->mRecord->getTimestamp();
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
2020-05-26 22:01:54 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return bool
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function isCurrent() {
|
2020-05-26 22:01:54 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2020-04-12 21:51:21 +00:00
|
|
|
return $this->mRecord->isCurrent();
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
/**
|
2008-04-07 23:53:57 +00:00
|
|
|
* Get previous revision for this title
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-06-03 00:21:00 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2013-03-06 01:17:31 +00:00
|
|
|
* @return Revision|null
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function getPrevious() {
|
2020-06-03 00:21:00 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2019-04-29 14:24:58 +00:00
|
|
|
$rec = self::getRevisionLookup()->getPreviousRevision( $this->mRecord );
|
|
|
|
|
return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-02-07 17:03:51 +00:00
|
|
|
* Get next revision for this title
|
|
|
|
|
*
|
2020-04-27 04:10:02 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard), use RevisionLookup::getNextRevision instead
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return Revision|null
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public function getNext() {
|
2020-04-27 04:10:02 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2019-04-29 14:24:58 +00:00
|
|
|
$rec = self::getRevisionLookup()->getNextRevision( $this->mRecord );
|
|
|
|
|
return $rec ? new Revision( $rec, self::READ_NORMAL, $this->getTitle() ) : null;
|
2008-04-07 23:53:57 +00:00
|
|
|
}
|
2004-12-19 12:21:29 +00:00
|
|
|
|
|
|
|
|
/**
|
2014-04-30 18:53:31 +00:00
|
|
|
* Get revision text associated with an old or archive row
|
2017-03-09 04:32:04 +00:00
|
|
|
*
|
2018-09-30 21:34:59 +00:00
|
|
|
* If the text field is not included, this uses RevisionStore to load the appropriate slot
|
|
|
|
|
* and return its serialized content. This is the default backwards-compatibility behavior
|
|
|
|
|
* when reading from the MCR aware database schema is enabled. For this to work, either
|
|
|
|
|
* the revision ID or the page ID must be included in the row.
|
|
|
|
|
*
|
|
|
|
|
* When using the old text field, the flags field must also be set. Including the old_id
|
2017-03-09 04:32:04 +00:00
|
|
|
* field will activate cache usage as long as the $wiki parameter is not set.
|
2014-04-30 18:53:31 +00:00
|
|
|
*
|
2018-09-30 21:34:59 +00:00
|
|
|
* @deprecated since 1.32, use RevisionStore::newRevisionFromRow instead.
|
|
|
|
|
*
|
|
|
|
|
* @param stdClass $row The text data. If a falsy value is passed instead, false is returned.
|
2014-04-30 18:53:31 +00:00
|
|
|
* @param string $prefix Table prefix (default 'old_')
|
|
|
|
|
* @param string|bool $wiki The name of the wiki to load the revision text from
|
2018-08-09 08:21:56 +00:00
|
|
|
* (same as the wiki $row was loaded from) or false to indicate the local
|
2014-04-30 18:53:31 +00:00
|
|
|
* wiki (this is the default). Otherwise, it must be a symbolic wiki database
|
|
|
|
|
* identifier as understood by the LoadBalancer class.
|
2016-12-08 05:04:53 +00:00
|
|
|
* @return string|false Text the text requested or false on failure
|
2014-04-30 18:53:31 +00:00
|
|
|
*/
|
2012-12-11 11:57:37 +00:00
|
|
|
public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
|
2019-09-30 17:11:03 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.32' );
|
2018-09-30 21:34:59 +00:00
|
|
|
|
|
|
|
|
if ( !$row ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-19 12:21:29 +00:00
|
|
|
$textField = $prefix . 'text';
|
|
|
|
|
|
2018-09-30 21:34:59 +00:00
|
|
|
if ( isset( $row->$textField ) ) {
|
2019-12-17 16:20:32 +00:00
|
|
|
throw new LogicException(
|
|
|
|
|
'Cannot use ' . __METHOD__ . ' with the ' . $textField . ' field since 1.35.'
|
|
|
|
|
);
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
|
|
|
|
|
2019-12-17 16:20:32 +00:00
|
|
|
// Missing text field, we are probably looking at the MCR-enabled DB schema.
|
|
|
|
|
$store = self::getRevisionStore( $wiki );
|
|
|
|
|
$rev = $prefix === 'ar_'
|
|
|
|
|
? $store->newRevisionFromArchiveRow( $row )
|
|
|
|
|
: $store->newRevisionFromRow( $row );
|
2018-06-19 11:37:35 +00:00
|
|
|
|
2019-12-17 16:20:32 +00:00
|
|
|
$content = $rev->getContent( SlotRecord::MAIN );
|
|
|
|
|
return $content ? $content->serialize() : false;
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If $wgCompressRevisions is enabled, we will compress data.
|
|
|
|
|
* The input string is modified in place.
|
|
|
|
|
* Return value is the flags field: contains 'gzip' if the
|
|
|
|
|
* data is compressed, and 'utf-8' if we're saving in UTF-8
|
|
|
|
|
* mode.
|
|
|
|
|
*
|
2020-06-04 01:29:48 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2020-03-05 15:05:35 +00:00
|
|
|
* @param string &$text
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return string
|
2004-12-19 12:21:29 +00:00
|
|
|
*/
|
2008-04-07 23:53:57 +00:00
|
|
|
public static function compressRevisionText( &$text ) {
|
2020-06-04 01:29:48 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return self::getBlobStore()->compressData( $text );
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2013-08-07 16:14:18 +00:00
|
|
|
/**
|
|
|
|
|
* Re-converts revision text according to it's flags.
|
|
|
|
|
*
|
2020-06-04 01:29:48 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2020-03-05 15:05:35 +00:00
|
|
|
* @param string|false $text
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param array $flags Compression flags
|
|
|
|
|
* @return string|bool Decompressed text, or false on failure
|
2013-08-07 16:14:18 +00:00
|
|
|
*/
|
|
|
|
|
public static function decompressRevisionText( $text, $flags ) {
|
2020-06-04 01:29:48 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2018-01-12 15:03:47 +00:00
|
|
|
if ( $text === false ) {
|
|
|
|
|
// Text failed to be fetched; nothing to do
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
return self::getBlobStore()->decompressData( $text, $flags );
|
2013-08-07 16:14:18 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-11 06:00:05 +00:00
|
|
|
/**
|
|
|
|
|
* Insert a new revision into the database, returning the new revision ID
|
|
|
|
|
* number on success and dies horribly on failure.
|
|
|
|
|
*
|
2020-05-21 03:19:19 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2015-10-04 09:07:25 +00:00
|
|
|
* @param IDatabase $dbw (master connection)
|
2012-10-07 23:35:26 +00:00
|
|
|
* @throws MWException
|
2017-04-21 16:17:59 +00:00
|
|
|
* @return int The revision ID
|
2005-03-11 06:00:05 +00:00
|
|
|
*/
|
2008-05-23 07:33:35 +00:00
|
|
|
public function insertOn( $dbw ) {
|
2020-05-21 03:19:19 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
|
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
global $wgUser;
|
2016-01-19 23:30:32 +00:00
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
// Note that $this->mRecord->getId() will typically return null here, but not always,
|
|
|
|
|
// e.g. not when restoring a revision.
|
2012-06-25 21:30:51 +00:00
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( $this->mRecord->getUser( RevisionRecord::RAW ) === null ) {
|
|
|
|
|
if ( $this->mRecord instanceof MutableRevisionRecord ) {
|
|
|
|
|
$this->mRecord->setUser( $wgUser );
|
|
|
|
|
} else {
|
|
|
|
|
throw new MWException( 'Cannot insert revision with no associated user.' );
|
2012-09-18 15:43:20 +00:00
|
|
|
}
|
2012-06-25 21:30:51 +00:00
|
|
|
}
|
2012-06-07 15:35:37 +00:00
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
$rec = self::getRevisionStore()->insertRevisionOn( $this->mRecord, $dbw );
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
$this->mRecord = $rec;
|
2018-12-20 18:26:42 +00:00
|
|
|
Assert::postcondition( $this->mRecord !== null, 'Failed to acquire a RevisionRecord' );
|
2015-03-31 17:28:45 +00:00
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
return $rec->getId();
|
2012-06-07 15:35:37 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-27 18:44:10 +00:00
|
|
|
/**
|
|
|
|
|
* Get the base 36 SHA-1 value for a string of text
|
2020-03-25 21:09:42 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param string $text
|
|
|
|
|
* @return string
|
2011-10-27 18:44:10 +00:00
|
|
|
*/
|
|
|
|
|
public static function base36Sha1( $text ) {
|
2020-03-25 21:09:42 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return SlotRecord::base36Sha1( $text );
|
2005-03-18 04:32:55 +00:00
|
|
|
}
|
2005-03-28 10:47:12 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new null-revision for insertion into a page's
|
|
|
|
|
* history. This will not re-save the text, but simply refer
|
|
|
|
|
* to the text from the previous version.
|
|
|
|
|
*
|
|
|
|
|
* Such revisions can for instance identify page rename
|
|
|
|
|
* operations and other such meta-modifications.
|
|
|
|
|
*
|
2020-04-11 05:08:23 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2015-10-04 09:07:25 +00:00
|
|
|
* @param IDatabase $dbw
|
2014-07-24 09:30:25 +00:00
|
|
|
* @param int $pageId ID number of the page to read from
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param string $summary Revision's summary
|
|
|
|
|
* @param bool $minor Whether the revision should be considered as minor
|
2020-04-11 05:08:23 +00:00
|
|
|
* @param User|null $user User object to use or null for $wgUser
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return Revision|null Revision or null on error
|
2005-03-28 10:47:12 +00:00
|
|
|
*/
|
2014-04-28 16:59:20 +00:00
|
|
|
public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
|
2020-04-11 05:08:23 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.35' );
|
|
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( !$user ) {
|
2020-01-13 02:30:26 +00:00
|
|
|
global $wgUser;
|
2017-08-31 18:41:04 +00:00
|
|
|
$user = $wgUser;
|
2012-05-02 10:54:27 +00:00
|
|
|
}
|
|
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
$comment = CommentStoreComment::newUnsavedComment( $summary, null );
|
2015-08-01 00:00:48 +00:00
|
|
|
|
2019-07-04 21:24:34 +00:00
|
|
|
$title = Title::newFromID( $pageId, Title::READ_LATEST );
|
2018-01-11 09:22:16 +00:00
|
|
|
if ( $title === null ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
$rec = self::getRevisionStore()->newNullRevision( $dbw, $title, $comment, $minor, $user );
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2018-10-04 10:49:50 +00:00
|
|
|
return $rec ? new Revision( $rec ) : null;
|
2005-03-28 10:47:12 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
/**
|
|
|
|
|
* Determine if the current user is allowed to view a particular
|
|
|
|
|
* field of this revision, if it's marked as deleted.
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-03-11 01:41:49 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $field One of self::DELETED_TEXT,
|
2010-02-07 17:03:51 +00:00
|
|
|
* self::DELETED_COMMENT,
|
|
|
|
|
* self::DELETED_USER
|
2020-02-23 21:48:54 +00:00
|
|
|
* @param User|null $user User object to check, or null to use $wgUser (deprecated since 1.35)
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return bool
|
2006-03-16 19:04:25 +00:00
|
|
|
*/
|
2011-10-12 15:09:04 +00:00
|
|
|
public function userCan( $field, User $user = null ) {
|
2020-03-11 01:41:49 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2020-02-23 21:48:54 +00:00
|
|
|
if ( !$user ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
$user = $wgUser;
|
|
|
|
|
}
|
2020-05-27 22:49:07 +00:00
|
|
|
return RevisionRecord::userCanBitfield( $this->mRecord->getVisibility(), $field, $user );
|
2009-10-15 11:31:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the current user is allowed to view a particular
|
|
|
|
|
* field of this revision, if it's marked as deleted. This is used
|
|
|
|
|
* by various classes to avoid duplication.
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $bitfield Current field
|
|
|
|
|
* @param int $field One of self::DELETED_TEXT = File::DELETED_FILE,
|
2010-02-07 17:03:51 +00:00
|
|
|
* self::DELETED_COMMENT = File::DELETED_COMMENT,
|
|
|
|
|
* self::DELETED_USER = File::DELETED_USER
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param User|null $user User object to check, or null to use $wgUser
|
2014-08-18 18:11:34 +00:00
|
|
|
* @param Title|null $title A Title object to check for per-page restrictions on,
|
|
|
|
|
* instead of just plain userrights
|
2014-04-23 09:25:56 +00:00
|
|
|
* @return bool
|
2009-10-15 11:31:33 +00:00
|
|
|
*/
|
2014-08-25 17:16:36 +00:00
|
|
|
public static function userCanBitfield( $bitfield, $field, User $user = null,
|
2014-08-18 18:11:34 +00:00
|
|
|
Title $title = null
|
|
|
|
|
) {
|
2020-02-23 21:48:54 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
if ( !$user ) {
|
2020-02-23 21:48:54 +00:00
|
|
|
global $wgUser;
|
2017-08-31 18:41:04 +00:00
|
|
|
$user = $wgUser;
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2017-08-31 18:41:04 +00:00
|
|
|
|
|
|
|
|
return RevisionRecord::userCanBitfield( $bitfield, $field, $user, $title );
|
2006-03-16 19:04:25 +00:00
|
|
|
}
|
2005-08-02 13:35:19 +00:00
|
|
|
|
2006-06-23 06:31:46 +00:00
|
|
|
/**
|
|
|
|
|
* Get rev_timestamp from rev_id, without loading the rest of the row
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-03-04 02:21:43 +00:00
|
|
|
* @deprecated since 1.35
|
|
|
|
|
*
|
Don't require Title for getTimestampFromId
3e36ba655e3a added an option for passing a page ID to this method of
Revision, and e03787afd91c switched it to a Title and made it mandatory.
This behavior propagated to the method in RevisionStore. As far as I
can tell, the parameter does not help anything, but it can add a
database query to get the page ID if it's not cached, and impedes
conversion to LinkTarget. I can't figure out any reason to not
completely drop it. I've noted it as deprecated but still supported it
for now for compatibility -- I found one extension that does pass it.
(It's ignored, though, which theoretically would be a behavior change if
someone was passing a Title that didn't match the revision ID.)
While I was at it, I added the method to RevisionLookup, although it's
only used in later patches. Properly I should move that piece to a later
patch, but it didn't seem worth the effort.
I didn't change the Revision method, because the whole Revision class is
deprecated anyway.
Change-Id: I26ef5f2bf828f0f450633b7237d26d888e2c8773
2019-04-29 14:32:22 +00:00
|
|
|
* @param Title $title (ignored since 1.34)
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $id
|
2017-02-19 05:03:13 +00:00
|
|
|
* @param int $flags
|
2015-03-11 03:33:52 +00:00
|
|
|
* @return string|bool False if not found
|
2006-06-23 06:31:46 +00:00
|
|
|
*/
|
2019-11-30 22:32:44 +00:00
|
|
|
public static function getTimestampFromId( $title, $id, $flags = 0 ) {
|
2020-03-04 02:21:43 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.35' );
|
Don't require Title for getTimestampFromId
3e36ba655e3a added an option for passing a page ID to this method of
Revision, and e03787afd91c switched it to a Title and made it mandatory.
This behavior propagated to the method in RevisionStore. As far as I
can tell, the parameter does not help anything, but it can add a
database query to get the page ID if it's not cached, and impedes
conversion to LinkTarget. I can't figure out any reason to not
completely drop it. I've noted it as deprecated but still supported it
for now for compatibility -- I found one extension that does pass it.
(It's ignored, though, which theoretically would be a behavior change if
someone was passing a Title that didn't match the revision ID.)
While I was at it, I added the method to RevisionLookup, although it's
only used in later patches. Properly I should move that piece to a later
patch, but it didn't seem worth the effort.
I didn't change the Revision method, because the whole Revision class is
deprecated anyway.
Change-Id: I26ef5f2bf828f0f450633b7237d26d888e2c8773
2019-04-29 14:32:22 +00:00
|
|
|
return self::getRevisionStore()->getTimestampFromId( $id, $flags );
|
2006-06-23 06:31:46 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-07 23:53:57 +00:00
|
|
|
/**
|
|
|
|
|
* Get count of revisions per page...not very efficient
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-02-29 00:35:51 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2015-10-04 09:07:25 +00:00
|
|
|
* @param IDatabase $db
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $id Page id
|
|
|
|
|
* @return int
|
2008-04-07 23:53:57 +00:00
|
|
|
*/
|
2019-11-30 22:32:44 +00:00
|
|
|
public static function countByPageId( $db, $id ) {
|
2020-02-29 00:35:51 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return self::getRevisionStore()->countRevisionsByPageId( $db, $id );
|
2006-06-27 21:48:43 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-07 23:53:57 +00:00
|
|
|
/**
|
|
|
|
|
* Get count of revisions per page...not very efficient
|
2010-02-07 17:03:51 +00:00
|
|
|
*
|
2020-02-29 00:38:52 +00:00
|
|
|
* @deprecated since 1.31 (soft), 1.35 (hard)
|
|
|
|
|
*
|
2015-10-04 09:07:25 +00:00
|
|
|
* @param IDatabase $db
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param Title $title
|
|
|
|
|
* @return int
|
2008-04-07 23:53:57 +00:00
|
|
|
*/
|
2019-11-30 22:32:44 +00:00
|
|
|
public static function countByTitle( $db, $title ) {
|
2020-02-29 00:38:52 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
return self::getRevisionStore()->countRevisionsByTitle( $db, $title );
|
2006-06-27 21:48:43 +00:00
|
|
|
}
|
2012-08-30 17:17:14 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if no edits were made by other users since
|
|
|
|
|
* the time a user started editing the page. Limit to
|
|
|
|
|
* 50 revisions for the sake of performance.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.20
|
2020-03-25 21:19:44 +00:00
|
|
|
* @deprecated since 1.24 (soft), 1.35 (hard)
|
2012-08-30 17:17:14 +00:00
|
|
|
*
|
2015-10-04 09:07:25 +00:00
|
|
|
* @param IDatabase|int $db The Database to perform the check on. May be given as a
|
2013-12-07 20:58:53 +00:00
|
|
|
* Database object or a database identifier usable with wfGetDB.
|
2014-04-23 09:25:56 +00:00
|
|
|
* @param int $pageId The ID of the page in question
|
|
|
|
|
* @param int $userId The ID of the user in question
|
|
|
|
|
* @param string $since Look at edits since this time
|
2012-08-30 17:17:14 +00:00
|
|
|
*
|
|
|
|
|
* @return bool True if the given user was the only one to edit since the given timestamp
|
|
|
|
|
*/
|
|
|
|
|
public static function userWasLastToEdit( $db, $pageId, $userId, $since ) {
|
2020-03-25 21:19:44 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.24' );
|
2012-08-30 17:17:14 +00:00
|
|
|
if ( is_int( $db ) ) {
|
|
|
|
|
$db = wfGetDB( $db );
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-31 18:41:04 +00:00
|
|
|
return self::getRevisionStore()->userWasLastToEdit( $db, $pageId, $userId, $since );
|
2012-08-30 17:17:14 +00:00
|
|
|
}
|
2016-09-02 07:30:26 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Load a revision based on a known page ID and current revision ID from the DB
|
|
|
|
|
*
|
|
|
|
|
* This method allows for the use of caching, though accessing anything that normally
|
|
|
|
|
* requires permission checks (aside from the text) will trigger a small DB lookup.
|
2017-08-31 18:41:04 +00:00
|
|
|
* The title will also be loaded if $pageIdOrTitle is an integer ID.
|
2016-09-02 07:30:26 +00:00
|
|
|
*
|
2017-08-31 18:41:04 +00:00
|
|
|
* @param IDatabase $db ignored!
|
|
|
|
|
* @param int|Title $pageIdOrTitle Page ID or Title object
|
|
|
|
|
* @param int $revId Known current revision of this page. Determined automatically if not given.
|
2016-09-02 07:30:26 +00:00
|
|
|
* @return Revision|bool Returns false if missing
|
|
|
|
|
* @since 1.28
|
2020-02-29 03:49:41 +00:00
|
|
|
* @deprecated since 1.31 and hard deprecated since 1.35
|
2016-09-02 07:30:26 +00:00
|
|
|
*/
|
2017-08-31 18:41:04 +00:00
|
|
|
public static function newKnownCurrent( IDatabase $db, $pageIdOrTitle, $revId = 0 ) {
|
2020-02-29 03:49:41 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.31' );
|
2017-08-31 18:41:04 +00:00
|
|
|
$title = $pageIdOrTitle instanceof Title
|
|
|
|
|
? $pageIdOrTitle
|
|
|
|
|
: Title::newFromID( $pageIdOrTitle );
|
2016-09-02 07:30:26 +00:00
|
|
|
|
2017-12-27 14:17:04 +00:00
|
|
|
if ( !$title ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-09 08:53:38 +00:00
|
|
|
$record = self::getRevisionLookup()->getKnownCurrentRevision( $title, $revId );
|
2017-08-31 18:41:04 +00:00
|
|
|
return $record ? new Revision( $record ) : false;
|
2016-09-02 07:30:26 +00:00
|
|
|
}
|
2004-12-19 12:21:29 +00:00
|
|
|
}
|