|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
XOWA: the XOWA Offline Wiki Application
|
|
|
|
XOWA: the XOWA Offline Wiki Application
|
|
|
|
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
|
|
|
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
|
|
|
|
|
|
|
|
|
|
|
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
|
|
|
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
|
|
|
or alternatively under the terms of the Apache License Version 2.0.
|
|
|
|
or alternatively under the terms of the Apache License Version 2.0.
|
|
|
|
@@ -13,31 +13,37 @@ The terms of each license can be found in the source code repository:
|
|
|
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
|
|
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
|
|
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|
|
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
|
|
|
|
package gplx.xowa.mediawiki.includes;
|
|
|
|
import gplx.xowa.mediawiki.includes.dao.*;
|
|
|
|
import gplx.xowa.mediawiki.XophpInt_;
|
|
|
|
|
|
|
|
import gplx.xowa.mediawiki.XophpObject_;
|
|
|
|
|
|
|
|
import gplx.xowa.mediawiki.XophpType_;
|
|
|
|
|
|
|
|
import gplx.xowa.mediawiki.includes.Revision.XomwRevisionRecord;
|
|
|
|
|
|
|
|
import gplx.xowa.mediawiki.includes.content.XomwContent;
|
|
|
|
|
|
|
|
import gplx.xowa.mediawiki.includes.dao.XomwIDBAccessObject;
|
|
|
|
import gplx.xowa.mediawiki.includes.libs.rdbms.database.XomwIDatabase;
|
|
|
|
import gplx.xowa.mediawiki.includes.libs.rdbms.database.XomwIDatabase;
|
|
|
|
import gplx.xowa.mediawiki.includes.linkers.XomwLinkTarget;
|
|
|
|
import gplx.xowa.mediawiki.includes.linkers.XomwLinkTarget;
|
|
|
|
|
|
|
|
import gplx.xowa.mediawiki.includes.user.XomwUser;
|
|
|
|
// MW.SRC:1.33.1
|
|
|
|
// MW.SRC:1.33.1
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @+deprecated since 1.31, use RevisionRecord, RevisionStore, and BlobStore instead.
|
|
|
|
* @+deprecated since 1.31, use RevisionRecord, RevisionStore, and BlobStore instead.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
//
|
|
|
|
|
|
|
|
// /** @var RevisionRecord */
|
|
|
|
/** @var RevisionRecord */
|
|
|
|
// protected $mRecord;
|
|
|
|
protected XomwRevisionRecord mRecord;
|
|
|
|
//
|
|
|
|
|
|
|
|
// // Revision deletion constants
|
|
|
|
// Revision deletion constants
|
|
|
|
// static final DELETED_TEXT = RevisionRecord::DELETED_TEXT;
|
|
|
|
static final int DELETED_TEXT = XomwRevisionRecord.DELETED_TEXT;
|
|
|
|
// static final DELETED_COMMENT = RevisionRecord::DELETED_COMMENT;
|
|
|
|
static final int DELETED_COMMENT = XomwRevisionRecord.DELETED_COMMENT;
|
|
|
|
// static final DELETED_USER = RevisionRecord::DELETED_USER;
|
|
|
|
static final int DELETED_USER = XomwRevisionRecord.DELETED_USER;
|
|
|
|
// static final DELETED_RESTRICTED = RevisionRecord::DELETED_RESTRICTED;
|
|
|
|
static final int DELETED_RESTRICTED = XomwRevisionRecord.DELETED_RESTRICTED;
|
|
|
|
// static final SUPPRESSED_USER = RevisionRecord::SUPPRESSED_USER;
|
|
|
|
static final int SUPPRESSED_USER = XomwRevisionRecord.SUPPRESSED_USER;
|
|
|
|
// static final SUPPRESSED_ALL = RevisionRecord::SUPPRESSED_ALL;
|
|
|
|
static final int SUPPRESSED_ALL = XomwRevisionRecord.SUPPRESSED_ALL;
|
|
|
|
//
|
|
|
|
|
|
|
|
// // Audience options for accessors
|
|
|
|
// Audience options for accessors
|
|
|
|
// static final FOR_PUBLIC = RevisionRecord::FOR_PUBLIC;
|
|
|
|
static final int FOR_PUBLIC = XomwRevisionRecord.FOR_PUBLIC;
|
|
|
|
// static final FOR_THIS_USER = RevisionRecord::FOR_THIS_USER;
|
|
|
|
static final int FOR_THIS_USER = XomwRevisionRecord.FOR_THIS_USER;
|
|
|
|
// static final RAW = RevisionRecord::RAW;
|
|
|
|
static final int RAW = XomwRevisionRecord.RAW;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// static final TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP;
|
|
|
|
// static final TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -46,10 +52,10 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// protected static function getRevisionStore($wiki = false) {
|
|
|
|
// protected static function getRevisionStore($wiki = false) {
|
|
|
|
// if ($wiki) {
|
|
|
|
// if ($wiki) {
|
|
|
|
// return MediaWikiServices::getInstance()->getRevisionStoreFactory()
|
|
|
|
// return MediaWikiServices::getInstance().getRevisionStoreFactory()
|
|
|
|
// ->getRevisionStore($wiki);
|
|
|
|
// .getRevisionStore($wiki);
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// return MediaWikiServices::getInstance()->getRevisionStore();
|
|
|
|
// return MediaWikiServices::getInstance().getRevisionStore();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -57,14 +63,14 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return RevisionLookup
|
|
|
|
// * @return RevisionLookup
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// protected static function getRevisionLookup() {
|
|
|
|
// protected static function getRevisionLookup() {
|
|
|
|
// return MediaWikiServices::getInstance()->getRevisionLookup();
|
|
|
|
// return MediaWikiServices::getInstance().getRevisionLookup();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
// * @return RevisionFactory
|
|
|
|
// * @return RevisionFactory
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// protected static function getRevisionFactory() {
|
|
|
|
// protected static function getRevisionFactory() {
|
|
|
|
// return MediaWikiServices::getInstance()->getRevisionFactory();
|
|
|
|
// return MediaWikiServices::getInstance().getRevisionFactory();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -74,8 +80,8 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// protected static function getBlobStore($wiki = false) {
|
|
|
|
// protected static function getBlobStore($wiki = false) {
|
|
|
|
// $store = MediaWikiServices::getInstance()
|
|
|
|
// $store = MediaWikiServices::getInstance()
|
|
|
|
// ->getBlobStoreFactory()
|
|
|
|
// .getBlobStoreFactory()
|
|
|
|
// ->newSqlBlobStore($wiki);
|
|
|
|
// .newSqlBlobStore($wiki);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if (!$store instanceof SqlBlobStore) {
|
|
|
|
// if (!$store instanceof SqlBlobStore) {
|
|
|
|
// throw new RuntimeException(
|
|
|
|
// throw new RuntimeException(
|
|
|
|
@@ -101,7 +107,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static XomwRevision newFromId(int id) {return newFromId(id, 0);}
|
|
|
|
public static XomwRevision newFromId(int id) {return newFromId(id, 0);}
|
|
|
|
public static XomwRevision newFromId(int id, int flags) {
|
|
|
|
public static XomwRevision newFromId(int id, int flags) {
|
|
|
|
// $rec = self::getRevisionLookup()->getRevisionById($id, $flags);
|
|
|
|
// $rec = self::getRevisionLookup().getRevisionById($id, $flags);
|
|
|
|
// return $rec ? new Revision($rec, $flags) : null;
|
|
|
|
// return $rec ? new Revision($rec, $flags) : null;
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -122,7 +128,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static XomwRevision newFromTitle(XomwLinkTarget linkTarget) {return newFromTitle(linkTarget, 0, 0);}
|
|
|
|
public static XomwRevision newFromTitle(XomwLinkTarget linkTarget) {return newFromTitle(linkTarget, 0, 0);}
|
|
|
|
public static XomwRevision newFromTitle(XomwLinkTarget linkTarget, int id, int flags) {
|
|
|
|
public static XomwRevision newFromTitle(XomwLinkTarget linkTarget, int id, int flags) {
|
|
|
|
// $rec = self::getRevisionLookup()->getRevisionByTitle($linkTarget, $id, $flags);
|
|
|
|
// $rec = self::getRevisionLookup().getRevisionByTitle($linkTarget, $id, $flags);
|
|
|
|
// return $rec ? new Revision($rec, $flags) : null;
|
|
|
|
// return $rec ? new Revision($rec, $flags) : null;
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -142,7 +148,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return Revision|null
|
|
|
|
// * @return Revision|null
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function newFromPageId($pageId, $revId = 0, $flags = 0) {
|
|
|
|
// public static function newFromPageId($pageId, $revId = 0, $flags = 0) {
|
|
|
|
// $rec = self::getRevisionLookup()->getRevisionByPageId($pageId, $revId, $flags);
|
|
|
|
// $rec = self::getRevisionLookup().getRevisionByPageId($pageId, $revId, $flags);
|
|
|
|
// return $rec ? new Revision($rec, $flags) : null;
|
|
|
|
// return $rec ? new Revision($rec, $flags) : null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -182,8 +188,8 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// $title = $overrides['title'];
|
|
|
|
// $title = $overrides['title'];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if ($title !== null) {
|
|
|
|
// if ($title !== null) {
|
|
|
|
// if (isset($row->ar_namespace) && isset($row->ar_title)) {
|
|
|
|
// if (isset($row.ar_namespace) && isset($row.ar_title)) {
|
|
|
|
// $title = Title::makeTitle($row->ar_namespace, $row->ar_title);
|
|
|
|
// $title = Title::makeTitle($row.ar_namespace, $row.ar_title);
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// throw new InvalidArgumentException(
|
|
|
|
// throw new InvalidArgumentException(
|
|
|
|
// 'A Title or ar_namespace and ar_title must be given'
|
|
|
|
// 'A Title or ar_namespace and ar_title must be given'
|
|
|
|
@@ -191,7 +197,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $rec = self::getRevisionFactory()->newRevisionFromArchiveRow($row, 0, $title, $overrides);
|
|
|
|
// $rec = self::getRevisionFactory().newRevisionFromArchiveRow($row, 0, $title, $overrides);
|
|
|
|
// return new Revision($rec, self::READ_NORMAL, $title);
|
|
|
|
// return new Revision($rec, self::READ_NORMAL, $title);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -209,9 +215,9 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function newFromRow($row) {
|
|
|
|
// public static function newFromRow($row) {
|
|
|
|
// if (is_array($row)) {
|
|
|
|
// if (is_array($row)) {
|
|
|
|
// $rec = self::getRevisionFactory()->newMutableRevisionFromArray($row);
|
|
|
|
// $rec = self::getRevisionFactory().newMutableRevisionFromArray($row);
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// $rec = self::getRevisionFactory()->newRevisionFromRow($row);
|
|
|
|
// $rec = self::getRevisionFactory().newRevisionFromRow($row);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// return new Revision($rec);
|
|
|
|
// return new Revision($rec);
|
|
|
|
@@ -229,7 +235,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function loadFromId($db, $id) {
|
|
|
|
// public static function loadFromId($db, $id) {
|
|
|
|
// wfDeprecated(__METHOD__, '1.31'); // no known callers
|
|
|
|
// wfDeprecated(__METHOD__, '1.31'); // no known callers
|
|
|
|
// $rec = self::getRevisionStore()->loadRevisionFromId($db, $id);
|
|
|
|
// $rec = self::getRevisionStore().loadRevisionFromId($db, $id);
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -246,7 +252,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return Revision|null
|
|
|
|
// * @return Revision|null
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function loadFromPageId($db, $pageid, $id = 0) {
|
|
|
|
// public static function loadFromPageId($db, $pageid, $id = 0) {
|
|
|
|
// $rec = self::getRevisionStore()->loadRevisionFromPageId($db, $pageid, $id);
|
|
|
|
// $rec = self::getRevisionStore().loadRevisionFromPageId($db, $pageid, $id);
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -263,7 +269,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return Revision|null
|
|
|
|
// * @return Revision|null
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function loadFromTitle($db, $title, $id = 0) {
|
|
|
|
// public static function loadFromTitle($db, $title, $id = 0) {
|
|
|
|
// $rec = self::getRevisionStore()->loadRevisionFromTitle($db, $title, $id);
|
|
|
|
// $rec = self::getRevisionStore().loadRevisionFromTitle($db, $title, $id);
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -281,7 +287,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return Revision|null
|
|
|
|
// * @return Revision|null
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function loadFromTimestamp($db, $title, $timestamp) {
|
|
|
|
// public static function loadFromTimestamp($db, $title, $timestamp) {
|
|
|
|
// $rec = self::getRevisionStore()->loadRevisionFromTimestamp($db, $title, $timestamp);
|
|
|
|
// $rec = self::getRevisionStore().loadRevisionFromTimestamp($db, $title, $timestamp);
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -334,7 +340,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// if ($wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW) {
|
|
|
|
// if ($wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW) {
|
|
|
|
// // If code is using this instead of self::getQueryInfo(), there's a
|
|
|
|
// // If code is using this instead of self::getQueryInfo(), there's a
|
|
|
|
// // decent chance it's going to try to directly access
|
|
|
|
// // decent chance it's going to try to directly access
|
|
|
|
// // $row->rev_user or $row->rev_user_text and we can't give it
|
|
|
|
// // $row.rev_user or $row.rev_user_text and we can't give it
|
|
|
|
// // useful values here once those aren't being used anymore.
|
|
|
|
// // useful values here once those aren't being used anymore.
|
|
|
|
// throw new BadMethodCallException(
|
|
|
|
// throw new BadMethodCallException(
|
|
|
|
// 'Cannot use ' . __METHOD__
|
|
|
|
// 'Cannot use ' . __METHOD__
|
|
|
|
@@ -345,7 +351,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// if (!($wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD)) {
|
|
|
|
// if (!($wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD)) {
|
|
|
|
// // If code is using this instead of self::getQueryInfo(), there's a
|
|
|
|
// // If code is using this instead of self::getQueryInfo(), there's a
|
|
|
|
// // decent chance it's going to try to directly access
|
|
|
|
// // decent chance it's going to try to directly access
|
|
|
|
// // $row->rev_text_id or $row->rev_content_model and we can't give it
|
|
|
|
// // $row.rev_text_id or $row.rev_content_model and we can't give it
|
|
|
|
// // useful values here once those aren't being written anymore,
|
|
|
|
// // useful values here once those aren't being written anymore,
|
|
|
|
// // and may not exist at all.
|
|
|
|
// // and may not exist at all.
|
|
|
|
// throw new BadMethodCallException(
|
|
|
|
// throw new BadMethodCallException(
|
|
|
|
@@ -371,7 +377,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// 'rev_sha1',
|
|
|
|
// 'rev_sha1',
|
|
|
|
// ];
|
|
|
|
// ];
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $fields += CommentStore::getStore()->getFields('rev_comment');
|
|
|
|
// $fields += CommentStore::getStore().getFields('rev_comment');
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if ($wgContentHandlerUseDB) {
|
|
|
|
// if ($wgContentHandlerUseDB) {
|
|
|
|
// $fields[] = 'rev_content_format';
|
|
|
|
// $fields[] = 'rev_content_format';
|
|
|
|
@@ -394,7 +400,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// if ($wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW) {
|
|
|
|
// if ($wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW) {
|
|
|
|
// // If code is using this instead of self::getQueryInfo(), there's a
|
|
|
|
// // If code is using this instead of self::getQueryInfo(), there's a
|
|
|
|
// // decent chance it's going to try to directly access
|
|
|
|
// // decent chance it's going to try to directly access
|
|
|
|
// // $row->ar_user or $row->ar_user_text and we can't give it
|
|
|
|
// // $row.ar_user or $row.ar_user_text and we can't give it
|
|
|
|
// // useful values here once those aren't being used anymore.
|
|
|
|
// // useful values here once those aren't being used anymore.
|
|
|
|
// throw new BadMethodCallException(
|
|
|
|
// throw new BadMethodCallException(
|
|
|
|
// 'Cannot use ' . __METHOD__
|
|
|
|
// 'Cannot use ' . __METHOD__
|
|
|
|
@@ -405,7 +411,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// if (!($wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD)) {
|
|
|
|
// if (!($wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD)) {
|
|
|
|
// // If code is using this instead of self::getQueryInfo(), there's a
|
|
|
|
// // If code is using this instead of self::getQueryInfo(), there's a
|
|
|
|
// // decent chance it's going to try to directly access
|
|
|
|
// // decent chance it's going to try to directly access
|
|
|
|
// // $row->ar_text_id or $row->ar_content_model and we can't give it
|
|
|
|
// // $row.ar_text_id or $row.ar_content_model and we can't give it
|
|
|
|
// // useful values here once those aren't being written anymore,
|
|
|
|
// // useful values here once those aren't being written anymore,
|
|
|
|
// // and may not exist at all.
|
|
|
|
// // and may not exist at all.
|
|
|
|
// throw new BadMethodCallException(
|
|
|
|
// throw new BadMethodCallException(
|
|
|
|
@@ -432,7 +438,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// 'ar_sha1',
|
|
|
|
// 'ar_sha1',
|
|
|
|
// ];
|
|
|
|
// ];
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $fields += CommentStore::getStore()->getFields('ar_comment');
|
|
|
|
// $fields += CommentStore::getStore().getFields('ar_comment');
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if ($wgContentHandlerUseDB) {
|
|
|
|
// if ($wgContentHandlerUseDB) {
|
|
|
|
// $fields[] = 'ar_content_format';
|
|
|
|
// $fields[] = 'ar_content_format';
|
|
|
|
@@ -492,12 +498,12 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * - 'user': Join with the user table, and select the user name
|
|
|
|
// * - 'user': Join with the user table, and select the user name
|
|
|
|
// * - 'text': Join with the text table, and select fields to load page text
|
|
|
|
// * - 'text': Join with the text table, and select fields to load page text
|
|
|
|
// * @return array With three keys:
|
|
|
|
// * @return array With three keys:
|
|
|
|
// * - tables: (String[]) to include in the `$table` to `IDatabase->select()`
|
|
|
|
// * - tables: (String[]) to include in the `$table` to `IDatabase.select()`
|
|
|
|
// * - fields: (String[]) to include in the `$vars` to `IDatabase->select()`
|
|
|
|
// * - fields: (String[]) to include in the `$vars` to `IDatabase.select()`
|
|
|
|
// * - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
|
|
|
|
// * - joins: (array) to include in the `$join_conds` to `IDatabase.select()`
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function getQueryInfo($options = []) {
|
|
|
|
// public static function getQueryInfo($options = []) {
|
|
|
|
// return self::getRevisionStore()->getQueryInfo($options);
|
|
|
|
// return self::getRevisionStore().getQueryInfo($options);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -506,12 +512,12 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @since 1.31
|
|
|
|
// * @since 1.31
|
|
|
|
// * @deprecated since 1.31, use RevisionStore::getArchiveQueryInfo() instead.
|
|
|
|
// * @deprecated since 1.31, use RevisionStore::getArchiveQueryInfo() instead.
|
|
|
|
// * @return array With three keys:
|
|
|
|
// * @return array With three keys:
|
|
|
|
// * - tables: (String[]) to include in the `$table` to `IDatabase->select()`
|
|
|
|
// * - tables: (String[]) to include in the `$table` to `IDatabase.select()`
|
|
|
|
// * - fields: (String[]) to include in the `$vars` to `IDatabase->select()`
|
|
|
|
// * - fields: (String[]) to include in the `$vars` to `IDatabase.select()`
|
|
|
|
// * - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
|
|
|
|
// * - joins: (array) to include in the `$join_conds` to `IDatabase.select()`
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function getArchiveQueryInfo() {
|
|
|
|
// public static function getArchiveQueryInfo() {
|
|
|
|
// return self::getRevisionStore()->getArchiveQueryInfo();
|
|
|
|
// return self::getRevisionStore().getArchiveQueryInfo();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -524,7 +530,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return array
|
|
|
|
// * @return array
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function getParentLengths($db, array $revIds) {
|
|
|
|
// public static function getParentLengths($db, array $revIds) {
|
|
|
|
// return self::getRevisionStore()->listRevisionSizes($db, $revIds);
|
|
|
|
// return self::getRevisionStore().listRevisionSizes($db, $revIds);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -538,7 +544,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// global $wgUser;
|
|
|
|
// global $wgUser;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if ($row instanceof RevisionRecord) {
|
|
|
|
// if ($row instanceof RevisionRecord) {
|
|
|
|
// $this->mRecord = $row;
|
|
|
|
// this.mRecord = $row;
|
|
|
|
// } elseif (is_array($row)) {
|
|
|
|
// } elseif (is_array($row)) {
|
|
|
|
// // If no user is specified, fall back to using the global user Object, to stay
|
|
|
|
// // If no user is specified, fall back to using the global user Object, to stay
|
|
|
|
// // compatible with pre-1.31 behavior.
|
|
|
|
// // compatible with pre-1.31 behavior.
|
|
|
|
@@ -546,16 +552,16 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// $row['user'] = $wgUser;
|
|
|
|
// $row['user'] = $wgUser;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
|
|
|
|
// this.mRecord = self::getRevisionFactory().newMutableRevisionFromArray(
|
|
|
|
// $row,
|
|
|
|
// $row,
|
|
|
|
// $queryFlags,
|
|
|
|
// $queryFlags,
|
|
|
|
// $this->ensureTitle($row, $queryFlags, $title)
|
|
|
|
// this.ensureTitle($row, $queryFlags, $title)
|
|
|
|
// );
|
|
|
|
// );
|
|
|
|
// } elseif (is_object($row)) {
|
|
|
|
// } elseif (is_object($row)) {
|
|
|
|
// $this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
|
|
|
|
// this.mRecord = self::getRevisionFactory().newRevisionFromRow(
|
|
|
|
// $row,
|
|
|
|
// $row,
|
|
|
|
// $queryFlags,
|
|
|
|
// $queryFlags,
|
|
|
|
// $this->ensureTitle($row, $queryFlags, $title)
|
|
|
|
// this.ensureTitle($row, $queryFlags, $title)
|
|
|
|
// );
|
|
|
|
// );
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// throw new InvalidArgumentException(
|
|
|
|
// throw new InvalidArgumentException(
|
|
|
|
@@ -563,7 +569,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// );
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Assert::postcondition($this->mRecord !== null, 'Failed to construct a RevisionRecord');
|
|
|
|
// Assert::postcondition(this.mRecord !== null, 'Failed to construct a RevisionRecord');
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -593,19 +599,19 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// $pageId = $row['page'] ?? 0;
|
|
|
|
// $pageId = $row['page'] ?? 0;
|
|
|
|
// $revId = $row['id'] ?? 0;
|
|
|
|
// $revId = $row['id'] ?? 0;
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// $pageId = $row->rev_page ?? 0;
|
|
|
|
// $pageId = $row.rev_page ?? 0;
|
|
|
|
// $revId = $row->rev_id ?? 0;
|
|
|
|
// $revId = $row.rev_id ?? 0;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
// $title = self::getRevisionStore()->getTitle($pageId, $revId, $queryFlags);
|
|
|
|
// $title = self::getRevisionStore().getTitle($pageId, $revId, $queryFlags);
|
|
|
|
// } catch (RevisionAccessException $ex) {
|
|
|
|
// } catch (RevisionAccessException $ex) {
|
|
|
|
// // construct a dummy title!
|
|
|
|
// // construct a dummy title!
|
|
|
|
// wfLogWarning(__METHOD__ . ': ' . $ex->getMessage());
|
|
|
|
// wfLogWarning(__METHOD__ . ': ' . $ex.getMessage());
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// // NOTE: this Title will only be used inside RevisionRecord
|
|
|
|
// // NOTE: this Title will only be used inside RevisionRecord
|
|
|
|
// $title = Title::makeTitleSafe(NS_SPECIAL, "Badtitle/ID=$pageId");
|
|
|
|
// $title = Title::makeTitleSafe(NS_SPECIAL, "Badtitle/ID=$pageId");
|
|
|
|
// $title->resetArticleID($pageId);
|
|
|
|
// $title.resetArticleID($pageId);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// return $title;
|
|
|
|
// return $title;
|
|
|
|
@@ -615,7 +621,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return RevisionRecord
|
|
|
|
// * @return RevisionRecord
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getRevisionRecord() {
|
|
|
|
// public function getRevisionRecord() {
|
|
|
|
// return $this->mRecord;
|
|
|
|
// return this.mRecord;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@@ -624,8 +630,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
* @return int|null
|
|
|
|
* @return int|null
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public int getId() {
|
|
|
|
public int getId() {
|
|
|
|
// return $this->mRecord->getId();
|
|
|
|
return this.mRecord.getId();
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -641,8 +646,8 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @throws MWException
|
|
|
|
// * @throws MWException
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function setId($id) {
|
|
|
|
// public function setId($id) {
|
|
|
|
// if ($this->mRecord instanceof MutableRevisionRecord) {
|
|
|
|
// if (this.mRecord instanceof MutableRevisionRecord) {
|
|
|
|
// $this->mRecord->setId(intval($id));
|
|
|
|
// this.mRecord.setId(intval($id));
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// throw new MWException(__METHOD__ . ' is not supported on this instance');
|
|
|
|
// throw new MWException(__METHOD__ . ' is not supported on this instance');
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
@@ -663,9 +668,9 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @throws MWException
|
|
|
|
// * @throws MWException
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function setUserIdAndName($id, $name) {
|
|
|
|
// public function setUserIdAndName($id, $name) {
|
|
|
|
// if ($this->mRecord instanceof MutableRevisionRecord) {
|
|
|
|
// if (this.mRecord instanceof MutableRevisionRecord) {
|
|
|
|
// $user = User::newFromAnyId(intval($id), $name, null);
|
|
|
|
// $user = User::newFromAnyId(intval($id), $name, null);
|
|
|
|
// $this->mRecord->setUser($user);
|
|
|
|
// this.mRecord.setUser($user);
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// throw new MWException(__METHOD__ . ' is not supported on this instance');
|
|
|
|
// throw new MWException(__METHOD__ . ' is not supported on this instance');
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
@@ -675,7 +680,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return SlotRecord
|
|
|
|
// * @return SlotRecord
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// private function getMainSlotRaw() {
|
|
|
|
// private function getMainSlotRaw() {
|
|
|
|
// return $this->mRecord->getSlot(SlotRecord::MAIN, RevisionRecord::RAW);
|
|
|
|
// return this.mRecord.getSlot(SlotRecord::MAIN, RevisionRecord::RAW);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -684,16 +689,16 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// *
|
|
|
|
// *
|
|
|
|
// * If the content is stored elsewhere, this returns null.
|
|
|
|
// * If the content is stored elsewhere, this returns null.
|
|
|
|
// *
|
|
|
|
// *
|
|
|
|
// * @deprecated since 1.31, use RevisionRecord()->getSlot()->getContentAddress() to
|
|
|
|
// * @deprecated since 1.31, use RevisionRecord().getSlot().getContentAddress() to
|
|
|
|
// * get that actual address that can be used with BlobStore::getBlob(); or use
|
|
|
|
// * get that actual address that can be used with BlobStore::getBlob(); or use
|
|
|
|
// * RevisionRecord::hasSameContent() to check if two revisions have the same content.
|
|
|
|
// * RevisionRecord::hasSameContent() to check if two revisions have the same content.
|
|
|
|
// *
|
|
|
|
// *
|
|
|
|
// * @return int|null
|
|
|
|
// * @return int|null
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getTextId() {
|
|
|
|
// public function getTextId() {
|
|
|
|
// $slot = $this->getMainSlotRaw();
|
|
|
|
// $slot = this.getMainSlotRaw();
|
|
|
|
// return $slot->hasAddress()
|
|
|
|
// return $slot.hasAddress()
|
|
|
|
// ? self::getBlobStore()->getTextIdFromAddress($slot->getAddress())
|
|
|
|
// ? self::getBlobStore().getTextIdFromAddress($slot.getAddress())
|
|
|
|
// : null;
|
|
|
|
// : null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -704,7 +709,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * parent revision. Null indicates that the parent revision is not known.
|
|
|
|
// * parent revision. Null indicates that the parent revision is not known.
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getParentId() {
|
|
|
|
// public function getParentId() {
|
|
|
|
// return $this->mRecord->getParentId();
|
|
|
|
// return this.mRecord.getParentId();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -714,7 +719,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getSize() {
|
|
|
|
// public function getSize() {
|
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
// return $this->mRecord->getSize();
|
|
|
|
// return this.mRecord.getSize();
|
|
|
|
// } catch (RevisionAccessException $ex) {
|
|
|
|
// } catch (RevisionAccessException $ex) {
|
|
|
|
// return null;
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
@@ -727,25 +732,26 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getSha1() {
|
|
|
|
// public function getSha1() {
|
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
// return $this->mRecord->getSha1();
|
|
|
|
// return this.mRecord.getSha1();
|
|
|
|
// } catch (RevisionAccessException $ex) {
|
|
|
|
// } catch (RevisionAccessException $ex) {
|
|
|
|
// return null;
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
/**
|
|
|
|
// * Returns the title of the page associated with this entry.
|
|
|
|
* Returns the title of the page associated with this entry.
|
|
|
|
// * Since 1.31, this will never return null.
|
|
|
|
* Since 1.31, this will never return null.
|
|
|
|
// *
|
|
|
|
*
|
|
|
|
// * Will do a query, when title is not set and id is given.
|
|
|
|
* Will do a query, when title is not set and id is given.
|
|
|
|
// *
|
|
|
|
*
|
|
|
|
// * @return Title
|
|
|
|
* @return Title
|
|
|
|
// */
|
|
|
|
*/
|
|
|
|
// public function getTitle() {
|
|
|
|
public XomwTitle getTitle() {
|
|
|
|
// $linkTarget = $this->mRecord->getPageAsLinkTarget();
|
|
|
|
// $linkTarget = this.mRecord.getPageAsLinkTarget();
|
|
|
|
// return Title::newFromLinkTarget($linkTarget);
|
|
|
|
// return Title::newFromLinkTarget($linkTarget);
|
|
|
|
// }
|
|
|
|
return null;
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
// * Set the title of the revision
|
|
|
|
// * Set the title of the revision
|
|
|
|
// *
|
|
|
|
// *
|
|
|
|
@@ -754,24 +760,24 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @param Title $title
|
|
|
|
// * @param Title $title
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function setTitle($title) {
|
|
|
|
// public function setTitle($title) {
|
|
|
|
// if (!$title->equals($this->getTitle())) {
|
|
|
|
// if (!$title.equals(this.getTitle())) {
|
|
|
|
// throw new InvalidArgumentException(
|
|
|
|
// throw new InvalidArgumentException(
|
|
|
|
// $title->getPrefixedText()
|
|
|
|
// $title.getPrefixedText()
|
|
|
|
// . ' is not the same as '
|
|
|
|
// . ' is not the same as '
|
|
|
|
// . $this->mRecord->getPageAsLinkTarget()->__toString()
|
|
|
|
// . this.mRecord.getPageAsLinkTarget().__toString()
|
|
|
|
// );
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
|
|
|
|
// /**
|
|
|
|
/**
|
|
|
|
// * Get the page ID
|
|
|
|
* Get the page ID
|
|
|
|
// *
|
|
|
|
*
|
|
|
|
// * @return int|null
|
|
|
|
* @return int|null
|
|
|
|
// */
|
|
|
|
*/
|
|
|
|
// public function getPage() {
|
|
|
|
public int getPage() {
|
|
|
|
// return $this->mRecord->getPageId();
|
|
|
|
return this.mRecord.getPageId();
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
//
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
// * Fetch revision's user id if it's available to the specified audience.
|
|
|
|
// * Fetch revision's user id if it's available to the specified audience.
|
|
|
|
// * If the specified audience does not have access to it, zero will be
|
|
|
|
// * If the specified audience does not have access to it, zero will be
|
|
|
|
@@ -792,8 +798,8 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// $user = $wgUser;
|
|
|
|
// $user = $wgUser;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $user = $this->mRecord->getUser($audience, $user);
|
|
|
|
// $user = this.mRecord.getUser($audience, $user);
|
|
|
|
// return $user ? $user->getId() : 0;
|
|
|
|
// return $user ? $user.getId() : 0;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -816,8 +822,8 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// $user = $wgUser;
|
|
|
|
// $user = $wgUser;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $user = $this->mRecord->getUser($audience, $user);
|
|
|
|
// $user = this.mRecord.getUser($audience, $user);
|
|
|
|
// return $user ? $user->getName() : '';
|
|
|
|
// return $user ? $user.getName() : '';
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -838,22 +844,22 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// $user = $wgUser;
|
|
|
|
// $user = $wgUser;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $comment = $this->mRecord->getComment($audience, $user);
|
|
|
|
// $comment = this.mRecord.getComment($audience, $user);
|
|
|
|
// return $comment === null ? null : $comment->text;
|
|
|
|
// return $comment === null ? null : $comment.text;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
// * @return boolean
|
|
|
|
// * @return boolean
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function isMinor() {
|
|
|
|
// public function isMinor() {
|
|
|
|
// return $this->mRecord->isMinor();
|
|
|
|
// return this.mRecord.isMinor();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
// * @return int Rcid of the unpatrolled row, zero if there isn't one
|
|
|
|
// * @return int Rcid of the unpatrolled row, zero if there isn't one
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function isUnpatrolled() {
|
|
|
|
// public function isUnpatrolled() {
|
|
|
|
// return self::getRevisionStore()->getRcIdIfUnpatrolled($this->mRecord);
|
|
|
|
// return self::getRevisionStore().getRcIdIfUnpatrolled(this.mRecord);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -866,7 +872,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return RecentChange|null
|
|
|
|
// * @return RecentChange|null
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getRecentChange($flags = 0) {
|
|
|
|
// public function getRecentChange($flags = 0) {
|
|
|
|
// return self::getRevisionStore()->getRecentChange($this->mRecord, $flags);
|
|
|
|
// return self::getRevisionStore().getRecentChange(this.mRecord, $flags);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -875,7 +881,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return boolean
|
|
|
|
// * @return boolean
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function isDeleted($field) {
|
|
|
|
// public function isDeleted($field) {
|
|
|
|
// return $this->mRecord->isDeleted($field);
|
|
|
|
// return this.mRecord.isDeleted($field);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -884,24 +890,25 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return int
|
|
|
|
// * @return int
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getVisibility() {
|
|
|
|
// public function getVisibility() {
|
|
|
|
// return $this->mRecord->getVisibility();
|
|
|
|
// return this.mRecord.getVisibility();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
|
|
|
|
// /**
|
|
|
|
/**
|
|
|
|
// * Fetch revision content if it's available to the specified audience.
|
|
|
|
* Fetch revision content if it's available to the specified audience.
|
|
|
|
// * If the specified audience does not have the ability to view this
|
|
|
|
* If the specified audience does not have the ability to view this
|
|
|
|
// * revision, or the content could not be loaded, null will be returned.
|
|
|
|
* revision, or the content could not be loaded, null will be returned.
|
|
|
|
// *
|
|
|
|
*
|
|
|
|
// * @param int $audience One of:
|
|
|
|
* @param int $audience One of:
|
|
|
|
// * Revision::FOR_PUBLIC to be displayed to all users
|
|
|
|
* Revision::FOR_PUBLIC to be displayed to all users
|
|
|
|
// * Revision::FOR_THIS_USER to be displayed to $user
|
|
|
|
* Revision::FOR_THIS_USER to be displayed to $user
|
|
|
|
// * Revision::RAW get the text regardless of permissions
|
|
|
|
* Revision::RAW get the text regardless of permissions
|
|
|
|
// * @param User|null $user User Object to check for, only if FOR_THIS_USER is passed
|
|
|
|
* @param User|null $user User Object to check for, only if FOR_THIS_USER is passed
|
|
|
|
// * to the $audience parameter
|
|
|
|
* to the $audience parameter
|
|
|
|
// * @since 1.21
|
|
|
|
* @since 1.21
|
|
|
|
// * @return Content|null
|
|
|
|
* @return Content|null
|
|
|
|
// */
|
|
|
|
*/
|
|
|
|
// public function getContent($audience = self::FOR_PUBLIC, User $user = null) {
|
|
|
|
public XomwContent getContent() {return getContent(FOR_PUBLIC, null);}
|
|
|
|
|
|
|
|
public XomwContent getContent(int audience, XomwUser user) {
|
|
|
|
// global $wgUser;
|
|
|
|
// global $wgUser;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if ($audience === self::FOR_THIS_USER && !$user) {
|
|
|
|
// if ($audience === self::FOR_THIS_USER && !$user) {
|
|
|
|
@@ -909,13 +916,14 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
// return $this->mRecord->getContent(SlotRecord::MAIN, $audience, $user);
|
|
|
|
// return this.mRecord.getContent(SlotRecord::MAIN, $audience, $user);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// catch (RevisionAccessException $e) {
|
|
|
|
// catch (RevisionAccessException $e) {
|
|
|
|
// return null;
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return null;
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
// * Get original serialized data (without checking view restrictions)
|
|
|
|
// * Get original serialized data (without checking view restrictions)
|
|
|
|
// *
|
|
|
|
// *
|
|
|
|
@@ -925,8 +933,8 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return String
|
|
|
|
// * @return String
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getSerializedData() {
|
|
|
|
// public function getSerializedData() {
|
|
|
|
// $slot = $this->getMainSlotRaw();
|
|
|
|
// $slot = this.getMainSlotRaw();
|
|
|
|
// return $slot->getContent()->serialize();
|
|
|
|
// return $slot.getContent().serialize();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -942,7 +950,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * see the CONTENT_MODEL_XXX constants.
|
|
|
|
// * see the CONTENT_MODEL_XXX constants.
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getContentModel() {
|
|
|
|
// public function getContentModel() {
|
|
|
|
// return $this->getMainSlotRaw()->getModel();
|
|
|
|
// return this.getMainSlotRaw().getModel();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -957,11 +965,11 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * see the CONTENT_FORMAT_XXX constants.
|
|
|
|
// * see the CONTENT_FORMAT_XXX constants.
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getContentFormat() {
|
|
|
|
// public function getContentFormat() {
|
|
|
|
// $format = $this->getMainSlotRaw()->getFormat();
|
|
|
|
// $format = this.getMainSlotRaw().getFormat();
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if ($format === null) {
|
|
|
|
// if ($format === null) {
|
|
|
|
// // if no format was stored along with the blob, fall back to default format
|
|
|
|
// // if no format was stored along with the blob, fall back to default format
|
|
|
|
// $format = $this->getContentHandler()->getDefaultFormat();
|
|
|
|
// $format = this.getContentHandler().getDefaultFormat();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// return $format;
|
|
|
|
// return $format;
|
|
|
|
@@ -974,21 +982,21 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return ContentHandler
|
|
|
|
// * @return ContentHandler
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getContentHandler() {
|
|
|
|
// public function getContentHandler() {
|
|
|
|
// return ContentHandler::getForModelID($this->getContentModel());
|
|
|
|
// return ContentHandler::getForModelID(this.getContentModel());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
// * @return String
|
|
|
|
// * @return String
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getTimestamp() {
|
|
|
|
// public function getTimestamp() {
|
|
|
|
// return $this->mRecord->getTimestamp();
|
|
|
|
// return this.mRecord.getTimestamp();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
// * @return boolean
|
|
|
|
// * @return boolean
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function isCurrent() {
|
|
|
|
// public function isCurrent() {
|
|
|
|
// return ($this->mRecord instanceof RevisionStoreRecord) && $this->mRecord->isCurrent();
|
|
|
|
// return (this.mRecord instanceof RevisionStoreRecord) && this.mRecord.isCurrent();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -997,8 +1005,8 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return Revision|null
|
|
|
|
// * @return Revision|null
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getPrevious() {
|
|
|
|
// public function getPrevious() {
|
|
|
|
// $title = $this->getTitle();
|
|
|
|
// $title = this.getTitle();
|
|
|
|
// $rec = self::getRevisionLookup()->getPreviousRevision($this->mRecord, $title);
|
|
|
|
// $rec = self::getRevisionLookup().getPreviousRevision(this.mRecord, $title);
|
|
|
|
// return $rec ? new Revision($rec, self::READ_NORMAL, $title) : null;
|
|
|
|
// return $rec ? new Revision($rec, self::READ_NORMAL, $title) : null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -1008,8 +1016,8 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return Revision|null
|
|
|
|
// * @return Revision|null
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function getNext() {
|
|
|
|
// public function getNext() {
|
|
|
|
// $title = $this->getTitle();
|
|
|
|
// $title = this.getTitle();
|
|
|
|
// $rec = self::getRevisionLookup()->getNextRevision($this->mRecord, $title);
|
|
|
|
// $rec = self::getRevisionLookup().getNextRevision(this.mRecord, $title);
|
|
|
|
// return $rec ? new Revision($rec, self::READ_NORMAL, $title) : null;
|
|
|
|
// return $rec ? new Revision($rec, self::READ_NORMAL, $title) : null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -1044,7 +1052,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// $textField = $prefix . 'text';
|
|
|
|
// $textField = $prefix . 'text';
|
|
|
|
// $flagsField = $prefix . 'flags';
|
|
|
|
// $flagsField = $prefix . 'flags';
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if (isset($row->$textField)) {
|
|
|
|
// if (isset($row.$textField)) {
|
|
|
|
// if (!($wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD)) {
|
|
|
|
// if (!($wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD)) {
|
|
|
|
// // The text field was read, but it's no longer being populated!
|
|
|
|
// // The text field was read, but it's no longer being populated!
|
|
|
|
// // We could gloss over this by using the text when it's there and loading
|
|
|
|
// // We could gloss over this by using the text when it's there and loading
|
|
|
|
@@ -1057,7 +1065,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// );
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $text = $row->$textField;
|
|
|
|
// $text = $row.$textField;
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// // Missing text field, we are probably looking at the MCR-enabled DB schema.
|
|
|
|
// // Missing text field, we are probably looking at the MCR-enabled DB schema.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@@ -1069,28 +1077,28 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $store = self::getRevisionStore($wiki);
|
|
|
|
// $store = self::getRevisionStore($wiki);
|
|
|
|
// $rev = $prefix === 'ar_'
|
|
|
|
// $rev = $prefix === 'ar_'
|
|
|
|
// ? $store->newRevisionFromArchiveRow($row)
|
|
|
|
// ? $store.newRevisionFromArchiveRow($row)
|
|
|
|
// : $store->newRevisionFromRow($row);
|
|
|
|
// : $store.newRevisionFromRow($row);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $content = $rev->getContent(SlotRecord::MAIN);
|
|
|
|
// $content = $rev.getContent(SlotRecord::MAIN);
|
|
|
|
// return $content ? $content->serialize() : false;
|
|
|
|
// return $content ? $content.serialize() : false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if (isset($row->$flagsField)) {
|
|
|
|
// if (isset($row.$flagsField)) {
|
|
|
|
// $flags = explode(',', $row->$flagsField);
|
|
|
|
// $flags = explode(',', $row.$flagsField);
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// $flags = [];
|
|
|
|
// $flags = [];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $cacheKey = isset($row->old_id)
|
|
|
|
// $cacheKey = isset($row.old_id)
|
|
|
|
// ? SqlBlobStore::makeAddressFromTextId($row->old_id)
|
|
|
|
// ? SqlBlobStore::makeAddressFromTextId($row.old_id)
|
|
|
|
// : null;
|
|
|
|
// : null;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $revisionText = self::getBlobStore($wiki)->expandBlob($text, $flags, $cacheKey);
|
|
|
|
// $revisionText = self::getBlobStore($wiki).expandBlob($text, $flags, $cacheKey);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if ($revisionText === false) {
|
|
|
|
// if ($revisionText === false) {
|
|
|
|
// if (isset($row->old_id)) {
|
|
|
|
// if (isset($row.old_id)) {
|
|
|
|
// wfLogWarning(__METHOD__ . ": Bad data in text row {$row->old_id}! ");
|
|
|
|
// wfLogWarning(__METHOD__ . ": Bad data in text row {$row.old_id}! ");
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// wfLogWarning(__METHOD__ . ": Bad data in text row! ");
|
|
|
|
// wfLogWarning(__METHOD__ . ": Bad data in text row! ");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
@@ -1111,7 +1119,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return String
|
|
|
|
// * @return String
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public static function compressRevisionText(&$text) {
|
|
|
|
// public static function compressRevisionText(&$text) {
|
|
|
|
// return self::getBlobStore()->compressData($text);
|
|
|
|
// return self::getBlobStore().compressData($text);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -1127,7 +1135,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// return false;
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// return self::getBlobStore()->decompressData($text, $flags);
|
|
|
|
// return self::getBlobStore().decompressData($text, $flags);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -1141,23 +1149,23 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// public function insertOn($dbw) {
|
|
|
|
// public function insertOn($dbw) {
|
|
|
|
// global $wgUser;
|
|
|
|
// global $wgUser;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// // Note that $this->mRecord->getId() will typically return null here, but not always,
|
|
|
|
// // Note that this.mRecord.getId() will typically return null here, but not always,
|
|
|
|
// // e.g. not when restoring a revision.
|
|
|
|
// // e.g. not when restoring a revision.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if ($this->mRecord->getUser(RevisionRecord::RAW) === null) {
|
|
|
|
// if (this.mRecord.getUser(RevisionRecord::RAW) === null) {
|
|
|
|
// if ($this->mRecord instanceof MutableRevisionRecord) {
|
|
|
|
// if (this.mRecord instanceof MutableRevisionRecord) {
|
|
|
|
// $this->mRecord->setUser($wgUser);
|
|
|
|
// this.mRecord.setUser($wgUser);
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// throw new MWException('Cannot insert revision with no associated user.');
|
|
|
|
// throw new MWException('Cannot insert revision with no associated user.');
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $rec = self::getRevisionStore()->insertRevisionOn($this->mRecord, $dbw);
|
|
|
|
// $rec = self::getRevisionStore().insertRevisionOn(this.mRecord, $dbw);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $this->mRecord = $rec;
|
|
|
|
// this.mRecord = $rec;
|
|
|
|
// Assert::postcondition($this->mRecord !== null, 'Failed to acquire a RevisionRecord');
|
|
|
|
// Assert::postcondition(this.mRecord !== null, 'Failed to acquire a RevisionRecord');
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// return $rec->getId();
|
|
|
|
// return $rec.getId();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -1197,7 +1205,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// return null;
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $rec = self::getRevisionStore()->newNullRevision($dbw, $title, $comment, $minor, $user);
|
|
|
|
// $rec = self::getRevisionStore().newNullRevision($dbw, $title, $comment, $minor, $user);
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// return $rec ? new Revision($rec) : null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
@@ -1213,7 +1221,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return boolean
|
|
|
|
// * @return boolean
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// public function userCan($field, User $user = null) {
|
|
|
|
// public function userCan($field, User $user = null) {
|
|
|
|
// return self::userCanBitfield($this->getVisibility(), $field, $user);
|
|
|
|
// return self::userCanBitfield(this.getVisibility(), $field, $user);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -1251,7 +1259,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return String|boolean False if not found
|
|
|
|
// * @return String|boolean False if not found
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// static function getTimestampFromId($title, $id, $flags = 0) {
|
|
|
|
// static function getTimestampFromId($title, $id, $flags = 0) {
|
|
|
|
// return self::getRevisionStore()->getTimestampFromId($title, $id, $flags);
|
|
|
|
// return self::getRevisionStore().getTimestampFromId($title, $id, $flags);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -1262,7 +1270,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return int
|
|
|
|
// * @return int
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// static function countByPageId($db, $id) {
|
|
|
|
// static function countByPageId($db, $id) {
|
|
|
|
// return self::getRevisionStore()->countRevisionsByPageId($db, $id);
|
|
|
|
// return self::getRevisionStore().countRevisionsByPageId($db, $id);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -1273,7 +1281,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// * @return int
|
|
|
|
// * @return int
|
|
|
|
// */
|
|
|
|
// */
|
|
|
|
// static function countByTitle($db, $title) {
|
|
|
|
// static function countByTitle($db, $title) {
|
|
|
|
// return self::getRevisionStore()->countRevisionsByTitle($db, $title);
|
|
|
|
// return self::getRevisionStore().countRevisionsByTitle($db, $title);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// /**
|
|
|
|
@@ -1297,7 +1305,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
// $db = wfGetDB($db);
|
|
|
|
// $db = wfGetDB($db);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// return self::getRevisionStore()->userWasLastToEdit($db, $pageId, $userId, $since);
|
|
|
|
// return self::getRevisionStore().userWasLastToEdit($db, $pageId, $userId, $since);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@@ -1322,7 +1330,7 @@ public class XomwRevision implements XomwIDBAccessObject {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// $record = self::getRevisionLookup()->getKnownCurrentRevision($title, $revId);
|
|
|
|
// $record = self::getRevisionLookup().getKnownCurrentRevision($title, $revId);
|
|
|
|
// return $record ? new Revision($record) : false;
|
|
|
|
// return $record ? new Revision($record) : false;
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|