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 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_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_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(String lhs, String rhs) {return String_.Eq(lhs, rhs);}
public static boolean eq_not(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.31
* @since 1.32 Renamed from MediaWiki\Storage\RevisionRecord * @since 1.32 Renamed from MediaWiki\Storage\RevisionRecord
*/ */
abstract class XomwRevisionRecord { public abstract class XomwRevisionRecord {
// RevisionRecord deletion constants // RevisionRecord deletion constants
public static final int DELETED_TEXT = 1; public static final int DELETED_TEXT = 1;
@ -232,20 +232,20 @@ abstract class XomwRevisionRecord {
// public function getInheritedSlots() { // public function getInheritedSlots() {
// return new RevisionSlots( this.mSlots->getInheritedSlots() ); // return new RevisionSlots( this.mSlots->getInheritedSlots() );
// } // }
//
// /** /**
// * Get revision ID. Depending on the concrete subclass, this may return null if * 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 * the revision ID is not known (e.g. because the revision does not yet exist
// * in the database). * in the database).
// * *
// * MCR migration note: this replaces Revision::getId * MCR migration note: this replaces Revision::getId
// * *
// * @return int|null * @return int|null
// */ */
// public function getId() { public int getId() {
// return this.mId; return this.mId;
// } }
//
// /** // /**
// * Get parent revision ID (the original previous page revision). // * Get parent revision ID (the original previous page revision).
// * If there is no parent revision, this returns 0. // * If there is no parent revision, this returns 0.

View File

@ -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;
} }

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 * @note Consider using a TitleValue Object instead. TitleValue is more lightweight
* and does not rely on global state or the database. * and does not rely on global state or the database.
*/ */
public class XomwTitleOld implements XomwLinkTarget { public class XomwTitleOld { // implements XomwLinkTarget
// /** @var HashBagOStuff */ // /** @var HashBagOStuff */
// static private $titleCache = null; // static private $titleCache = null;
// //

View File

@ -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,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 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.content; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*; package gplx.xowa.mediawiki.includes.content;
import gplx.xowa.mediawiki.includes.exception.*;
import gplx.xowa.mediawiki.includes.parsers.*; 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. * 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. * 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[] getTextForSearchIndex();
public abstract byte[] getWikitextForTransclusion(); public abstract String getWikitextForTransclusion();
public abstract byte[] getTextForSummary(int maxLength); 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 * @todo Used in WikiPage and MessageCache to get message text. Not so
* nice. What should we use instead?! * nice. What should we use instead?!
*/ */
byte[] getWikitextForTransclusion(); String getWikitextForTransclusion();
/** /**
* Returns a textual representation of the content suitable for use in edit * 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 * @since 1.27
*/ */
public interface XomwLinkTarget { public interface XomwLinkTarget {
//
// /** /**
// * Get the namespace index. * Get the namespace index.
// * @since 1.27 * @since 1.27
// * *
// * @return int Namespace index * @return int Namespace index
// */ */
// public int getNamespace(); public int getNamespace();
//
// /** /**
// * Convenience function to test if it is in the namespace * Convenience function to test if it is in the namespace
// * @since 1.27 * @since 1.27
// * *
// * @param int $ns * @param int $ns
// * @return bool * @return bool
// */ */
// public boolean inNamespace(int ns); public boolean inNamespace(int ns);
//
// /** /**
// * Get the link fragment (i.e. the bit after the #) in text form. * Get the link fragment (i.e. the bit after the #) in text form.
// * @since 1.27 * @since 1.27
// * *
// * @return string link fragment * @return string link fragment
// */ */
// public String getFragment(); public String getFragment();
//
// /** /**
// * Whether the link target has a fragment * Whether the link target has a fragment
// * @since 1.27 * @since 1.27
// * *
// * @return bool * @return bool
// */ */
// public boolean hasFragment(); public boolean hasFragment();
//
// /** /**
// * Get the main part with underscores. * Get the main part with underscores.
// * @since 1.27 * @since 1.27
// * *
// * @return string Main part of the link, with underscores (for use in href attributes) * @return string Main part of the link, with underscores (for use in href attributes)
// */ */
// public String getDBkey(); public String getDBkey();
//
// /** /**
// * Returns the link in text form, without namespace prefix or fragment. * Returns the link in text form, without namespace prefix or fragment.
// * This is computed from the DB key by replacing any underscores with spaces. * This is computed from the DB key by replacing any underscores with spaces.
// * @since 1.27 * @since 1.27
// * *
// * @return string * @return string
// */ */
// public String getText(); public String getText();
//
// /** /**
// * Creates a new LinkTarget for a different fragment of the same page. * 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 * It is expected that the same type of object will be returned, but the
// * only requirement is that it is a LinkTarget. * only requirement is that it is a LinkTarget.
// * @since 1.27 * @since 1.27
// * *
// * @param string $fragment The fragment name, or "" for the entire page. * @param string $fragment The fragment name, or "" for the entire page.
// * *
// * @return LinkTarget * @return LinkTarget
// */ */
// public XomwLinkTarget createFragmentTarget(String fragment); public XomwLinkTarget createFragmentTarget(String fragment);
//
// /** /**
// * Whether this LinkTarget has an interwiki component * Whether this LinkTarget has an interwiki component
// * @since 1.27 * @since 1.27
// * *
// * @return bool * @return bool
// */ */
// public boolean isExternal(); public boolean isExternal();
//
// /** /**
// * The interwiki component of this LinkTarget * The interwiki component of this LinkTarget
// * @since 1.27 * @since 1.27
// * *
// * @return string * @return string
// */ */
// public String getInterwiki(); public String getInterwiki();
//
// /** /**
// * Returns an informative human readable representation of the link target, * Returns an informative human readable representation of the link target,
// * for use in logging and debugging. There is no requirement for the return * for use in logging and debugging. There is no requirement for the return
// * value to have any relationship with the input of TitleParser. * value to have any relationship with the input of TitleParser.
// * @since 1.31 * @since 1.31
// * *
// * @return string * @return string
// */ */
// public String __toString(); 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.*; 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.btries.*;
import gplx.core.net.*; import gplx.core.net.*;
import gplx.xowa.mediawiki.includes.content.XomwContent;
import gplx.xowa.mediawiki.includes.xohtml.*; import gplx.xowa.mediawiki.includes.xohtml.*;
import gplx.xowa.mediawiki.includes.linkers.*; import gplx.xowa.mediawiki.includes.linkers.*;
import gplx.xowa.mediawiki.includes.parsers.tables.*; import gplx.xowa.mediawiki.includes.parsers.tables.*;
@ -4505,10 +4506,10 @@ Tfds.Write(nowiki, isHTML, forceRawInterwiki, isChildObj, isLocalObj, titleText,
* *
* @return array * @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; String text = XophpString_.False;
boolean skip = false; boolean skip = false;
XomwTitleOld finalTitle = title; XomwTitle finalTitle = title;
XophpArray deps = XophpArray.New(); XophpArray deps = XophpArray.New();
// Loop to fetch the article, with up to 1 redirect // 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("title", title)
.Add("page_id", title.getArticleID()) .Add("page_id", title.getArticleID())
.Add("rev_id", rev_id)); .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... // We fetched a rev from a different title; register it too...
// deps.Add(XophpArray.New() deps.Add(XophpArray.New()
// .Add("title", rev.getTitle()) .Add("title", rev.getTitle())
// .Add("page_id", rev.getPage()) .Add("page_id", rev.getPage())
// .Add("rev_id", rev_id)); .Add("rev_id", rev_id));
// } }
XomwContent content;
if (XophpObject_.is_true(rev)) { if (XophpObject_.is_true(rev)) {
// content = rev.getContent(); content = rev.getContent();
// text = content ? content.getWikitextForTransclusion() : null; text = XophpObject_.is_true(content) ? content.getWikitextForTransclusion() : null;
//
// Hooks::run('ParserFetchTemplate', // Hooks::run('ParserFetchTemplate',
// [ parser, title, rev, &text, &deps ]); // [ parser, title, rev, &text, &deps ]);
//
// if (text === false || text === null) { if (XophpString_.is_false(text) || XophpString_.is_null(text)) {
// text = false; text = XophpString_.False;
// break; break;
// } }
} else if (title.getNamespace() == NS_MEDIAWIKI) { } else if (title.getNamespace() == XomwDefines.NS_MEDIAWIKI) {
// message = wfMessage(MediaWikiServices::getInstance().getContentLanguage(). // message = wfMessage(MediaWikiServices::getInstance().getContentLanguage().
// lcfirst(title.getText())).inContentLanguage(); // lcfirst(title.getText())).inContentLanguage();
// if (!message.exists()) { // if (!message.exists()) {