1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Xomw: Add more implementation near statelessFetchTemplate [#632]

This commit is contained in:
gnosygnu 2020-04-27 08:39:30 -04:00
parent a4b5f5de5d
commit bd71db3ed6
10 changed files with 4825 additions and 5252 deletions

View File

@ -23,6 +23,7 @@ public class XophpString_ implements XophpCallbackOwner {
public static final String False = null;
public static boolean is_true (String s) {return s != null;} // handles code like "if ($var)" where var is an Object;
public static boolean is_false(String s) {return s == null;}
public static boolean is_null(String s) {return s == null;}
public static boolean eq(String lhs, String rhs) {return String_.Eq(lhs, rhs);}
public static boolean eq_not(String lhs, String rhs) {return !String_.Eq(lhs, rhs);}

View File

@ -14,7 +14,7 @@ import gplx.xowa.mediawiki.includes.XomwTitleOld;
* @since 1.31
* @since 1.32 Renamed from MediaWiki\Storage\RevisionRecord
*/
abstract class XomwRevisionRecord {
public abstract class XomwRevisionRecord {
// RevisionRecord deletion constants
public static final int DELETED_TEXT = 1;
@ -232,20 +232,20 @@ abstract class XomwRevisionRecord {
// public function getInheritedSlots() {
// return new RevisionSlots( this.mSlots->getInheritedSlots() );
// }
//
// /**
// * Get revision ID. Depending on the concrete subclass, this may return null if
// * the revision ID is not known (e.g. because the revision does not yet exist
// * in the database).
// *
// * MCR migration note: this replaces Revision::getId
// *
// * @return int|null
// */
// public function getId() {
// return this.mId;
// }
//
/**
* Get revision ID. Depending on the concrete subclass, this may return null if
* the revision ID is not known (e.g. because the revision does not yet exist
* in the database).
*
* MCR migration note: this replaces Revision::getId
*
* @return int|null
*/
public int getId() {
return this.mId;
}
// /**
// * Get parent revision ID (the original previous page revision).
// * If there is no parent revision, this returns 0.

View File

@ -1,6 +1,6 @@
/*
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,
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
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.*;
import gplx.xowa.mediawiki.includes.dao.*;
package gplx.xowa.mediawiki.includes;
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.linkers.XomwLinkTarget;
import gplx.xowa.mediawiki.includes.user.XomwUser;
// MW.SRC:1.33.1
/**
* @+deprecated since 1.31, use RevisionRecord, RevisionStore, and BlobStore instead.
*/
public class XomwRevision implements XomwIDBAccessObject {
//
// /** @var RevisionRecord */
// protected $mRecord;
//
// // Revision deletion constants
// static final DELETED_TEXT = RevisionRecord::DELETED_TEXT;
// static final DELETED_COMMENT = RevisionRecord::DELETED_COMMENT;
// static final DELETED_USER = RevisionRecord::DELETED_USER;
// static final DELETED_RESTRICTED = RevisionRecord::DELETED_RESTRICTED;
// static final SUPPRESSED_USER = RevisionRecord::SUPPRESSED_USER;
// static final SUPPRESSED_ALL = RevisionRecord::SUPPRESSED_ALL;
//
// // Audience options for accessors
// static final FOR_PUBLIC = RevisionRecord::FOR_PUBLIC;
// static final FOR_THIS_USER = RevisionRecord::FOR_THIS_USER;
// static final RAW = RevisionRecord::RAW;
/** @var RevisionRecord */
protected XomwRevisionRecord mRecord;
// Revision deletion constants
static final int DELETED_TEXT = XomwRevisionRecord.DELETED_TEXT;
static final int DELETED_COMMENT = XomwRevisionRecord.DELETED_COMMENT;
static final int DELETED_USER = XomwRevisionRecord.DELETED_USER;
static final int DELETED_RESTRICTED = XomwRevisionRecord.DELETED_RESTRICTED;
static final int SUPPRESSED_USER = XomwRevisionRecord.SUPPRESSED_USER;
static final int SUPPRESSED_ALL = XomwRevisionRecord.SUPPRESSED_ALL;
// Audience options for accessors
static final int FOR_PUBLIC = XomwRevisionRecord.FOR_PUBLIC;
static final int FOR_THIS_USER = XomwRevisionRecord.FOR_THIS_USER;
static final int RAW = XomwRevisionRecord.RAW;
//
// static final TEXT_CACHE_GROUP = SqlBlobStore::TEXT_CACHE_GROUP;
//
@ -46,10 +52,10 @@ public class XomwRevision implements XomwIDBAccessObject {
// */
// protected static function getRevisionStore($wiki = false) {
// if ($wiki) {
// return MediaWikiServices::getInstance()->getRevisionStoreFactory()
// ->getRevisionStore($wiki);
// return MediaWikiServices::getInstance().getRevisionStoreFactory()
// .getRevisionStore($wiki);
// } else {
// return MediaWikiServices::getInstance()->getRevisionStore();
// return MediaWikiServices::getInstance().getRevisionStore();
// }
// }
//
@ -57,14 +63,14 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return RevisionLookup
// */
// protected static function getRevisionLookup() {
// return MediaWikiServices::getInstance()->getRevisionLookup();
// return MediaWikiServices::getInstance().getRevisionLookup();
// }
//
// /**
// * @return RevisionFactory
// */
// 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) {
// $store = MediaWikiServices::getInstance()
// ->getBlobStoreFactory()
// ->newSqlBlobStore($wiki);
// .getBlobStoreFactory()
// .newSqlBlobStore($wiki);
//
// if (!$store instanceof SqlBlobStore) {
// 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, int flags) {
// $rec = self::getRevisionLookup()->getRevisionById($id, $flags);
// $rec = self::getRevisionLookup().getRevisionById($id, $flags);
// return $rec ? new Revision($rec, $flags) : 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, 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 null;
}
@ -142,7 +148,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return Revision|null
// */
// 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;
// }
//
@ -182,8 +188,8 @@ public class XomwRevision implements XomwIDBAccessObject {
// $title = $overrides['title'];
// }
// if ($title !== null) {
// if (isset($row->ar_namespace) && isset($row->ar_title)) {
// $title = Title::makeTitle($row->ar_namespace, $row->ar_title);
// 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'
@ -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);
// }
//
@ -209,9 +215,9 @@ public class XomwRevision implements XomwIDBAccessObject {
// */
// public static function newFromRow($row) {
// if (is_array($row)) {
// $rec = self::getRevisionFactory()->newMutableRevisionFromArray($row);
// $rec = self::getRevisionFactory().newMutableRevisionFromArray($row);
// } else {
// $rec = self::getRevisionFactory()->newRevisionFromRow($row);
// $rec = self::getRevisionFactory().newRevisionFromRow($row);
// }
//
// return new Revision($rec);
@ -229,7 +235,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// */
// public static function loadFromId($db, $id) {
// 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;
// }
//
@ -246,7 +252,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return Revision|null
// */
// 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;
// }
//
@ -263,7 +269,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return Revision|null
// */
// 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;
// }
//
@ -281,7 +287,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return Revision|null
// */
// 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;
// }
//
@ -334,7 +340,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// if ($wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW) {
// // If code is using this instead of self::getQueryInfo(), there's a
// // 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.
// throw new BadMethodCallException(
// 'Cannot use ' . __METHOD__
@ -345,7 +351,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// if (!($wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD)) {
// // If code is using this instead of self::getQueryInfo(), there's a
// // 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,
// // and may not exist at all.
// throw new BadMethodCallException(
@ -371,7 +377,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// 'rev_sha1',
// ];
//
// $fields += CommentStore::getStore()->getFields('rev_comment');
// $fields += CommentStore::getStore().getFields('rev_comment');
//
// if ($wgContentHandlerUseDB) {
// $fields[] = 'rev_content_format';
@ -394,7 +400,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// if ($wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW) {
// // If code is using this instead of self::getQueryInfo(), there's a
// // 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.
// throw new BadMethodCallException(
// 'Cannot use ' . __METHOD__
@ -405,7 +411,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// if (!($wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD)) {
// // If code is using this instead of self::getQueryInfo(), there's a
// // 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,
// // and may not exist at all.
// throw new BadMethodCallException(
@ -432,7 +438,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// 'ar_sha1',
// ];
//
// $fields += CommentStore::getStore()->getFields('ar_comment');
// $fields += CommentStore::getStore().getFields('ar_comment');
//
// if ($wgContentHandlerUseDB) {
// $fields[] = 'ar_content_format';
@ -492,12 +498,12 @@ public class XomwRevision implements XomwIDBAccessObject {
// * - '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()`
// * - 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 = []) {
// return self::getRevisionStore()->getQueryInfo($options);
// return self::getRevisionStore().getQueryInfo($options);
// }
//
// /**
@ -506,12 +512,12 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @since 1.31
// * @deprecated since 1.31, use RevisionStore::getArchiveQueryInfo() instead.
// * @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()`
// * - 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() {
// return self::getRevisionStore()->getArchiveQueryInfo();
// return self::getRevisionStore().getArchiveQueryInfo();
// }
//
// /**
@ -524,7 +530,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return array
// */
// 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;
//
// if ($row instanceof RevisionRecord) {
// $this->mRecord = $row;
// this.mRecord = $row;
// } elseif (is_array($row)) {
// // If no user is specified, fall back to using the global user Object, to stay
// // compatible with pre-1.31 behavior.
@ -546,16 +552,16 @@ public class XomwRevision implements XomwIDBAccessObject {
// $row['user'] = $wgUser;
// }
//
// $this->mRecord = self::getRevisionFactory()->newMutableRevisionFromArray(
// this.mRecord = self::getRevisionFactory().newMutableRevisionFromArray(
// $row,
// $queryFlags,
// $this->ensureTitle($row, $queryFlags, $title)
// this.ensureTitle($row, $queryFlags, $title)
// );
// } elseif (is_object($row)) {
// $this->mRecord = self::getRevisionFactory()->newRevisionFromRow(
// this.mRecord = self::getRevisionFactory().newRevisionFromRow(
// $row,
// $queryFlags,
// $this->ensureTitle($row, $queryFlags, $title)
// this.ensureTitle($row, $queryFlags, $title)
// );
// } else {
// 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;
// $revId = $row['id'] ?? 0;
// } else {
// $pageId = $row->rev_page ?? 0;
// $revId = $row->rev_id ?? 0;
// $pageId = $row.rev_page ?? 0;
// $revId = $row.rev_id ?? 0;
// }
//
// try {
// $title = self::getRevisionStore()->getTitle($pageId, $revId, $queryFlags);
// $title = self::getRevisionStore().getTitle($pageId, $revId, $queryFlags);
// } catch (RevisionAccessException $ex) {
// // construct a dummy title!
// wfLogWarning(__METHOD__ . ': ' . $ex->getMessage());
// wfLogWarning(__METHOD__ . ': ' . $ex.getMessage());
//
// // NOTE: this Title will only be used inside RevisionRecord
// $title = Title::makeTitleSafe(NS_SPECIAL, "Badtitle/ID=$pageId");
// $title->resetArticleID($pageId);
// $title.resetArticleID($pageId);
// }
//
// return $title;
@ -615,7 +621,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return RevisionRecord
// */
// public function getRevisionRecord() {
// return $this->mRecord;
// return this.mRecord;
// }
/**
@ -624,8 +630,7 @@ public class XomwRevision implements XomwIDBAccessObject {
* @return int|null
*/
public int getId() {
// return $this->mRecord->getId();
return -1;
return this.mRecord.getId();
}
//
// /**
@ -641,8 +646,8 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @throws MWException
// */
// public function setId($id) {
// if ($this->mRecord instanceof MutableRevisionRecord) {
// $this->mRecord->setId(intval($id));
// if (this.mRecord instanceof MutableRevisionRecord) {
// this.mRecord.setId(intval($id));
// } else {
// throw new MWException(__METHOD__ . ' is not supported on this instance');
// }
@ -663,9 +668,9 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @throws MWException
// */
// public function setUserIdAndName($id, $name) {
// if ($this->mRecord instanceof MutableRevisionRecord) {
// if (this.mRecord instanceof MutableRevisionRecord) {
// $user = User::newFromAnyId(intval($id), $name, null);
// $this->mRecord->setUser($user);
// this.mRecord.setUser($user);
// } else {
// throw new MWException(__METHOD__ . ' is not supported on this instance');
// }
@ -675,7 +680,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return SlotRecord
// */
// 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.
// *
// * @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
// * RevisionRecord::hasSameContent() to check if two revisions have the same content.
// *
// * @return int|null
// */
// public function getTextId() {
// $slot = $this->getMainSlotRaw();
// return $slot->hasAddress()
// ? self::getBlobStore()->getTextIdFromAddress($slot->getAddress())
// $slot = this.getMainSlotRaw();
// return $slot.hasAddress()
// ? self::getBlobStore().getTextIdFromAddress($slot.getAddress())
// : null;
// }
//
@ -704,7 +709,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * parent revision. Null indicates that the parent revision is not known.
// */
// public function getParentId() {
// return $this->mRecord->getParentId();
// return this.mRecord.getParentId();
// }
//
// /**
@ -714,7 +719,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// */
// public function getSize() {
// try {
// return $this->mRecord->getSize();
// return this.mRecord.getSize();
// } catch (RevisionAccessException $ex) {
// return null;
// }
@ -727,25 +732,26 @@ public class XomwRevision implements XomwIDBAccessObject {
// */
// public function getSha1() {
// try {
// return $this->mRecord->getSha1();
// return this.mRecord.getSha1();
// } catch (RevisionAccessException $ex) {
// return null;
// }
// }
//
// /**
// * Returns the title of the page associated with this entry.
// * Since 1.31, this will never return null.
// *
// * Will do a query, when title is not set and id is given.
// *
// * @return Title
// */
// public function getTitle() {
// $linkTarget = $this->mRecord->getPageAsLinkTarget();
/**
* Returns the title of the page associated with this entry.
* Since 1.31, this will never return null.
*
* Will do a query, when title is not set and id is given.
*
* @return Title
*/
public XomwTitle getTitle() {
// $linkTarget = this.mRecord.getPageAsLinkTarget();
// return Title::newFromLinkTarget($linkTarget);
// }
//
return null;
}
// /**
// * Set the title of the revision
// *
@ -754,24 +760,24 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @param Title $title
// */
// public function setTitle($title) {
// if (!$title->equals($this->getTitle())) {
// if (!$title.equals(this.getTitle())) {
// throw new InvalidArgumentException(
// $title->getPrefixedText()
// $title.getPrefixedText()
// . ' is not the same as '
// . $this->mRecord->getPageAsLinkTarget()->__toString()
// . this.mRecord.getPageAsLinkTarget().__toString()
// );
// }
// }
//
// /**
// * Get the page ID
// *
// * @return int|null
// */
// public function getPage() {
// return $this->mRecord->getPageId();
// }
//
/**
* Get the page ID
*
* @return int|null
*/
public int getPage() {
return this.mRecord.getPageId();
}
// /**
// * 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
@ -792,8 +798,8 @@ public class XomwRevision implements XomwIDBAccessObject {
// $user = $wgUser;
// }
//
// $user = $this->mRecord->getUser($audience, $user);
// return $user ? $user->getId() : 0;
// $user = this.mRecord.getUser($audience, $user);
// return $user ? $user.getId() : 0;
// }
//
// /**
@ -816,8 +822,8 @@ public class XomwRevision implements XomwIDBAccessObject {
// $user = $wgUser;
// }
//
// $user = $this->mRecord->getUser($audience, $user);
// return $user ? $user->getName() : '';
// $user = this.mRecord.getUser($audience, $user);
// return $user ? $user.getName() : '';
// }
//
// /**
@ -838,22 +844,22 @@ public class XomwRevision implements XomwIDBAccessObject {
// $user = $wgUser;
// }
//
// $comment = $this->mRecord->getComment($audience, $user);
// return $comment === null ? null : $comment->text;
// $comment = this.mRecord.getComment($audience, $user);
// return $comment === null ? null : $comment.text;
// }
//
// /**
// * @return boolean
// */
// public function isMinor() {
// return $this->mRecord->isMinor();
// return this.mRecord.isMinor();
// }
//
// /**
// * @return int Rcid of the unpatrolled row, zero if there isn't one
// */
// 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
// */
// 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
// */
// 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
// */
// public function getVisibility() {
// return $this->mRecord->getVisibility();
// return this.mRecord.getVisibility();
// }
//
// /**
// * Fetch revision content if it's available to the specified audience.
// * If the specified audience does not have the ability to view this
// * revision, or the content could not be loaded, null will be returned.
// *
// * @param int $audience One of:
// * Revision::FOR_PUBLIC to be displayed to all users
// * Revision::FOR_THIS_USER to be displayed to $user
// * Revision::RAW get the text regardless of permissions
// * @param User|null $user User Object to check for, only if FOR_THIS_USER is passed
// * to the $audience parameter
// * @since 1.21
// * @return Content|null
// */
// public function getContent($audience = self::FOR_PUBLIC, User $user = null) {
/**
* Fetch revision content if it's available to the specified audience.
* If the specified audience does not have the ability to view this
* revision, or the content could not be loaded, null will be returned.
*
* @param int $audience One of:
* Revision::FOR_PUBLIC to be displayed to all users
* Revision::FOR_THIS_USER to be displayed to $user
* Revision::RAW get the text regardless of permissions
* @param User|null $user User Object to check for, only if FOR_THIS_USER is passed
* to the $audience parameter
* @since 1.21
* @return Content|null
*/
public XomwContent getContent() {return getContent(FOR_PUBLIC, null);}
public XomwContent getContent(int audience, XomwUser user) {
// global $wgUser;
//
// if ($audience === self::FOR_THIS_USER && !$user) {
@ -909,13 +916,14 @@ public class XomwRevision implements XomwIDBAccessObject {
// }
//
// try {
// return $this->mRecord->getContent(SlotRecord::MAIN, $audience, $user);
// return this.mRecord.getContent(SlotRecord::MAIN, $audience, $user);
// }
// catch (RevisionAccessException $e) {
// return null;
// }
// }
//
return null;
}
// /**
// * Get original serialized data (without checking view restrictions)
// *
@ -925,8 +933,8 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return String
// */
// public function getSerializedData() {
// $slot = $this->getMainSlotRaw();
// return $slot->getContent()->serialize();
// $slot = this.getMainSlotRaw();
// return $slot.getContent().serialize();
// }
//
// /**
@ -942,7 +950,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * see the CONTENT_MODEL_XXX constants.
// */
// 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.
// */
// public function getContentFormat() {
// $format = $this->getMainSlotRaw()->getFormat();
// $format = this.getMainSlotRaw().getFormat();
//
// if ($format === null) {
// // if no format was stored along with the blob, fall back to default format
// $format = $this->getContentHandler()->getDefaultFormat();
// $format = this.getContentHandler().getDefaultFormat();
// }
//
// return $format;
@ -974,21 +982,21 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return ContentHandler
// */
// public function getContentHandler() {
// return ContentHandler::getForModelID($this->getContentModel());
// return ContentHandler::getForModelID(this.getContentModel());
// }
//
// /**
// * @return String
// */
// public function getTimestamp() {
// return $this->mRecord->getTimestamp();
// return this.mRecord.getTimestamp();
// }
//
// /**
// * @return boolean
// */
// 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
// */
// public function getPrevious() {
// $title = $this->getTitle();
// $rec = self::getRevisionLookup()->getPreviousRevision($this->mRecord, $title);
// $title = this.getTitle();
// $rec = self::getRevisionLookup().getPreviousRevision(this.mRecord, $title);
// return $rec ? new Revision($rec, self::READ_NORMAL, $title) : null;
// }
//
@ -1008,8 +1016,8 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return Revision|null
// */
// public function getNext() {
// $title = $this->getTitle();
// $rec = self::getRevisionLookup()->getNextRevision($this->mRecord, $title);
// $title = this.getTitle();
// $rec = self::getRevisionLookup().getNextRevision(this.mRecord, $title);
// return $rec ? new Revision($rec, self::READ_NORMAL, $title) : null;
// }
//
@ -1044,7 +1052,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// $textField = $prefix . 'text';
// $flagsField = $prefix . 'flags';
//
// if (isset($row->$textField)) {
// if (isset($row.$textField)) {
// if (!($wgMultiContentRevisionSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD)) {
// // 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
@ -1057,7 +1065,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// );
// }
//
// $text = $row->$textField;
// $text = $row.$textField;
// } else {
// // 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);
// $rev = $prefix === 'ar_'
// ? $store->newRevisionFromArchiveRow($row)
// : $store->newRevisionFromRow($row);
// ? $store.newRevisionFromArchiveRow($row)
// : $store.newRevisionFromRow($row);
//
// $content = $rev->getContent(SlotRecord::MAIN);
// return $content ? $content->serialize() : false;
// $content = $rev.getContent(SlotRecord::MAIN);
// return $content ? $content.serialize() : false;
// }
//
// if (isset($row->$flagsField)) {
// $flags = explode(',', $row->$flagsField);
// if (isset($row.$flagsField)) {
// $flags = explode(',', $row.$flagsField);
// } else {
// $flags = [];
// }
//
// $cacheKey = isset($row->old_id)
// ? SqlBlobStore::makeAddressFromTextId($row->old_id)
// $cacheKey = isset($row.old_id)
// ? SqlBlobStore::makeAddressFromTextId($row.old_id)
// : null;
//
// $revisionText = self::getBlobStore($wiki)->expandBlob($text, $flags, $cacheKey);
// $revisionText = self::getBlobStore($wiki).expandBlob($text, $flags, $cacheKey);
//
// if ($revisionText === false) {
// if (isset($row->old_id)) {
// wfLogWarning(__METHOD__ . ": Bad data in text row {$row->old_id}! ");
// if (isset($row.old_id)) {
// wfLogWarning(__METHOD__ . ": Bad data in text row {$row.old_id}! ");
// } else {
// wfLogWarning(__METHOD__ . ": Bad data in text row! ");
// }
@ -1111,7 +1119,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return String
// */
// 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 self::getBlobStore()->decompressData($text, $flags);
// return self::getBlobStore().decompressData($text, $flags);
// }
//
// /**
@ -1141,23 +1149,23 @@ public class XomwRevision implements XomwIDBAccessObject {
// public function insertOn($dbw) {
// 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.
//
// if ($this->mRecord->getUser(RevisionRecord::RAW) === null) {
// if ($this->mRecord instanceof MutableRevisionRecord) {
// $this->mRecord->setUser($wgUser);
// 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.');
// }
// }
//
// $rec = self::getRevisionStore()->insertRevisionOn($this->mRecord, $dbw);
// $rec = self::getRevisionStore().insertRevisionOn(this.mRecord, $dbw);
//
// $this->mRecord = $rec;
// Assert::postcondition($this->mRecord !== null, 'Failed to acquire a RevisionRecord');
// this.mRecord = $rec;
// 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;
// }
//
// $rec = self::getRevisionStore()->newNullRevision($dbw, $title, $comment, $minor, $user);
// $rec = self::getRevisionStore().newNullRevision($dbw, $title, $comment, $minor, $user);
//
// return $rec ? new Revision($rec) : null;
// }
@ -1213,7 +1221,7 @@ public class XomwRevision implements XomwIDBAccessObject {
// * @return boolean
// */
// 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
// */
// 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
// */
// 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
// */
// 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);
// }
//
// 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;
}
// $record = self::getRevisionLookup()->getKnownCurrentRevision($title, $revId);
// $record = self::getRevisionLookup().getKnownCurrentRevision($title, $revId);
// return $record ? new Revision($record) : false;
return null;
}

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ import gplx.xowa.mediawiki.includes.title.*;
* @note Consider using a TitleValue Object instead. TitleValue is more lightweight
* and does not rely on global state or the database.
*/
public class XomwTitleOld implements XomwLinkTarget {
public class XomwTitleOld { // implements XomwLinkTarget
// /** @var HashBagOStuff */
// static private $titleCache = null;
//

View File

@ -1,6 +1,6 @@
/*
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,
or alternatively under the terms of the Apache License Version 2.0.
@ -13,9 +13,14 @@ 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
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.content; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.xowa.mediawiki.includes.exception.*;
import gplx.xowa.mediawiki.includes.parsers.*;
package gplx.xowa.mediawiki.includes.content;
import gplx.Err_;
import gplx.xowa.mediawiki.includes.XomwMagicWord;
import gplx.xowa.mediawiki.includes.XomwTitleOld;
import gplx.xowa.mediawiki.includes.exception.XomwMWException;
import gplx.xowa.mediawiki.includes.parsers.XomwParserOptions;
import gplx.xowa.mediawiki.includes.parsers.XomwParserOutput;
/**
* A content Object represents page content, e.g. the text to show on a page.
* Content objects have no knowledge about how they relate to Wiki pages.
@ -530,7 +535,7 @@ public abstract class XomwAbstractContent implements XomwContent {
// }
public abstract byte[] getTextForSearchIndex();
public abstract byte[] getWikitextForTransclusion();
public abstract String getWikitextForTransclusion();
public abstract byte[] getTextForSummary(int maxLength);

View File

@ -52,7 +52,7 @@ public interface XomwContent {
* @todo Used in WikiPage and MessageCache to get message text. Not so
* nice. What should we use instead?!
*/
byte[] getWikitextForTransclusion();
String getWikitextForTransclusion();
/**
* Returns a textual representation of the content suitable for use in edit

View File

@ -20,93 +20,93 @@ package gplx.xowa.mediawiki.includes.linkers;
* @since 1.27
*/
public interface XomwLinkTarget {
//
// /**
// * Get the namespace index.
// * @since 1.27
// *
// * @return int Namespace index
// */
// public int getNamespace();
//
// /**
// * Convenience function to test if it is in the namespace
// * @since 1.27
// *
// * @param int $ns
// * @return bool
// */
// public boolean inNamespace(int ns);
//
// /**
// * Get the link fragment (i.e. the bit after the #) in text form.
// * @since 1.27
// *
// * @return string link fragment
// */
// public String getFragment();
//
// /**
// * Whether the link target has a fragment
// * @since 1.27
// *
// * @return bool
// */
// public boolean hasFragment();
//
// /**
// * Get the main part with underscores.
// * @since 1.27
// *
// * @return string Main part of the link, with underscores (for use in href attributes)
// */
// public String getDBkey();
//
// /**
// * Returns the link in text form, without namespace prefix or fragment.
// * This is computed from the DB key by replacing any underscores with spaces.
// * @since 1.27
// *
// * @return string
// */
// public String getText();
//
// /**
// * Creates a new LinkTarget for a different fragment of the same page.
// * It is expected that the same type of object will be returned, but the
// * only requirement is that it is a LinkTarget.
// * @since 1.27
// *
// * @param string $fragment The fragment name, or "" for the entire page.
// *
// * @return LinkTarget
// */
// public XomwLinkTarget createFragmentTarget(String fragment);
//
// /**
// * Whether this LinkTarget has an interwiki component
// * @since 1.27
// *
// * @return bool
// */
// public boolean isExternal();
//
// /**
// * The interwiki component of this LinkTarget
// * @since 1.27
// *
// * @return string
// */
// public String getInterwiki();
//
// /**
// * Returns an informative human readable representation of the link target,
// * for use in logging and debugging. There is no requirement for the return
// * value to have any relationship with the input of TitleParser.
// * @since 1.31
// *
// * @return string
// */
// public String __toString();
/**
* Get the namespace index.
* @since 1.27
*
* @return int Namespace index
*/
public int getNamespace();
/**
* Convenience function to test if it is in the namespace
* @since 1.27
*
* @param int $ns
* @return bool
*/
public boolean inNamespace(int ns);
/**
* Get the link fragment (i.e. the bit after the #) in text form.
* @since 1.27
*
* @return string link fragment
*/
public String getFragment();
/**
* Whether the link target has a fragment
* @since 1.27
*
* @return bool
*/
public boolean hasFragment();
/**
* Get the main part with underscores.
* @since 1.27
*
* @return string Main part of the link, with underscores (for use in href attributes)
*/
public String getDBkey();
/**
* Returns the link in text form, without namespace prefix or fragment.
* This is computed from the DB key by replacing any underscores with spaces.
* @since 1.27
*
* @return string
*/
public String getText();
/**
* Creates a new LinkTarget for a different fragment of the same page.
* It is expected that the same type of object will be returned, but the
* only requirement is that it is a LinkTarget.
* @since 1.27
*
* @param string $fragment The fragment name, or "" for the entire page.
*
* @return LinkTarget
*/
public XomwLinkTarget createFragmentTarget(String fragment);
/**
* Whether this LinkTarget has an interwiki component
* @since 1.27
*
* @return bool
*/
public boolean isExternal();
/**
* The interwiki component of this LinkTarget
* @since 1.27
*
* @return string
*/
public String getInterwiki();
/**
* Returns an informative human readable representation of the link target,
* for use in logging and debugging. There is no requirement for the return
* value to have any relationship with the input of TitleParser.
* @since 1.31
*
* @return string
*/
public String __toString();
}

View File

@ -16,6 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.mediawiki.includes.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.core.btries.*;
import gplx.core.net.*;
import gplx.xowa.mediawiki.includes.content.XomwContent;
import gplx.xowa.mediawiki.includes.xohtml.*;
import gplx.xowa.mediawiki.includes.linkers.*;
import gplx.xowa.mediawiki.includes.parsers.tables.*;
@ -4505,10 +4506,10 @@ Tfds.Write(nowiki, isHTML, forceRawInterwiki, isChildObj, isLocalObj, titleText,
*
* @return array
*/
public static XophpArray statelessFetchTemplate(XomwTitleOld title, XomwParser parser) { // $parser = false
public static XophpArray statelessFetchTemplate(XomwTitle title, XomwParser parser) { // $parser = false
String text = XophpString_.False;
boolean skip = false;
XomwTitleOld finalTitle = title;
XomwTitle finalTitle = title;
XophpArray deps = XophpArray.New();
// Loop to fetch the article, with up to 1 redirect
@ -4547,26 +4548,27 @@ Tfds.Write(nowiki, isHTML, forceRawInterwiki, isChildObj, isLocalObj, titleText,
.Add("title", title)
.Add("page_id", title.getArticleID())
.Add("rev_id", rev_id));
// if (rev && !title.equals(rev.getTitle())) {
if (XophpObject_.is_true(rev) && !title.equals(rev.getTitle())) {
// We fetched a rev from a different title; register it too...
// deps.Add(XophpArray.New()
// .Add("title", rev.getTitle())
// .Add("page_id", rev.getPage())
// .Add("rev_id", rev_id));
// }
deps.Add(XophpArray.New()
.Add("title", rev.getTitle())
.Add("page_id", rev.getPage())
.Add("rev_id", rev_id));
}
XomwContent content;
if (XophpObject_.is_true(rev)) {
// content = rev.getContent();
// text = content ? content.getWikitextForTransclusion() : null;
//
content = rev.getContent();
text = XophpObject_.is_true(content) ? content.getWikitextForTransclusion() : null;
// Hooks::run('ParserFetchTemplate',
// [ parser, title, rev, &text, &deps ]);
//
// if (text === false || text === null) {
// text = false;
// break;
// }
} else if (title.getNamespace() == NS_MEDIAWIKI) {
if (XophpString_.is_false(text) || XophpString_.is_null(text)) {
text = XophpString_.False;
break;
}
} else if (title.getNamespace() == XomwDefines.NS_MEDIAWIKI) {
// message = wfMessage(MediaWikiServices::getInstance().getContentLanguage().
// lcfirst(title.getText())).inContentLanguage();
// if (!message.exists()) {