本文整理汇总了PHP中Revision::getRevisionText方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::getRevisionText方法的具体用法?PHP Revision::getRevisionText怎么用?PHP Revision::getRevisionText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::getRevisionText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doGetText
/**
* May throw a database error if, say, the server dies during query.
* @param Database $db
* @param int $id The old_id
* @return string
*/
private function doGetText($db, $id)
{
$id = intval($id);
$row = $db->selectRow('text', ['old_text', 'old_flags'], ['old_id' => $id], __METHOD__);
$text = Revision::getRevisionText($row);
if ($text === false) {
return false;
}
return $text;
}
示例2: doGetText
/**
* May throw a database error if, say, the server dies during query.
*/
function doGetText($db, $id)
{
$id = intval($id);
$row = $db->selectRow('text', array('old_text', 'old_flags'), array('old_id' => $id), 'TextPassDumper::getText');
$text = Revision::getRevisionText($row);
if ($text === false) {
return false;
}
return $text;
}
示例3: efMessageCommonsGetMsg
function efMessageCommonsGetMsg($msg)
{
global $egMessageCommonsDatabase, $egMessageCommonsPrefix;
$title = Title::makeTitle(NS_MEDIAWIKI, $msg);
$dbr = wfGetDB(DB_SLAVE);
$row = $dbr->selectRow(array("`{$egMessageCommonsDatabase}`.`{$egMessageCommonsPrefix}page`", "`{$egMessageCommonsDatabase}`.`{$egMessageCommonsPrefix}revision`", "`{$egMessageCommonsDatabase}`.`{$egMessageCommonsPrefix}text`"), array('*'), array('page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), 'page_latest = rev_id', 'old_id = rev_text_id'));
if (!$row) {
return null;
}
return Revision::getRevisionText($row);
}
示例4: getContents
/**
* Fetches contents for pagenames in given namespace without side effects.
*
* @param string|string[] $titles Database page names.
* @param int $namespace The number of the namespace.
* @return array ( string => array ( string, string ) ) Tuples of page
* text and last author indexed by page name.
*/
public static function getContents($titles, $namespace)
{
$dbr = wfGetDB(DB_SLAVE);
$rows = $dbr->select(array('page', 'revision', 'text'), array('page_title', 'old_text', 'old_flags', 'rev_user_text'), array('page_namespace' => $namespace, 'page_latest=rev_id', 'rev_text_id=old_id', 'page_title' => $titles), __METHOD__);
$titles = array();
foreach ($rows as $row) {
$titles[$row->page_title] = array(Revision::getRevisionText($row), $row->rev_user_text);
}
$rows->free();
return $titles;
}
示例5: populateSearchIndex
/**
* Populates the search index with content from all pages
*/
protected function populateSearchIndex()
{
$res = $this->db->select('page', 'MAX(page_id) AS count');
$s = $this->db->fetchObject($res);
$count = $s->count;
$this->output("Rebuilding index fields for {$count} pages...\n");
$n = 0;
while ($n < $count) {
$this->output($n . "\n");
$end = $n + self::RTI_CHUNK_SIZE - 1;
$res = $this->db->select(array('page', 'revision', 'text'), array('page_id', 'page_namespace', 'page_title', 'old_flags', 'old_text'), array("page_id BETWEEN {$n} AND {$end}", 'page_latest = rev_id', 'rev_text_id = old_id'), __METHOD__);
foreach ($res as $s) {
$revtext = Revision::getRevisionText($s);
$u = new SearchUpdate($s->page_id, $s->page_title, $revtext);
$u->doUpdate();
}
$this->db->freeResult($res);
$n += self::RTI_CHUNK_SIZE;
}
}
示例6: execute
public function execute()
{
global $wgTranslateMessageNamespaces;
$namespace = $this->getOption('namespace', $wgTranslateMessageNamespaces);
if (is_string($namespace)) {
if (!MWNamespace::exists($namespace)) {
$namespace = MWNamespace::getCanonicalIndex($namespace);
if ($namespace === null) {
$this->error('Bad namespace', true);
}
}
}
$db = wfGetDB(DB_MASTER);
$tables = array('page', 'text', 'revision');
$fields = array('page_id', 'page_title', 'page_namespace', 'rev_id', 'old_text', 'old_flags');
$conds = array('page_latest = rev_id', 'old_id = rev_text_id', 'page_namespace' => $namespace);
$limit = 100;
$offset = 0;
while (true) {
$inserts = array();
$this->output('.', 0);
$options = array('LIMIT' => $limit, 'OFFSET' => $offset);
$res = $db->select($tables, $fields, $conds, __METHOD__, $options);
if (!$res->numRows()) {
break;
}
foreach ($res as $r) {
$text = Revision::getRevisionText($r);
if (strpos($text, TRANSLATE_FUZZY) !== false) {
$inserts[] = array('rt_page' => $r->page_id, 'rt_revision' => $r->rev_id, 'rt_type' => RevTag::getType('fuzzy'));
}
}
$offset += $limit;
$db->replace('revtag', 'rt_type_page_revision', $inserts, __METHOD__);
}
}
示例7: loadFromDB
/**
* Loads all or main part of cacheable messages from the database
*/
function loadFromDB()
{
global $wgAllMessagesEn, $wgLang;
$fname = 'MessageCache::loadFromDB';
$dbr =& wfGetDB(DB_SLAVE);
if (!$dbr) {
throw new MWException('Invalid database object');
}
$conditions = array('page_is_redirect' => 0, 'page_namespace' => NS_MEDIAWIKI);
$res = $dbr->select(array('page', 'revision', 'text'), array('page_title', 'old_text', 'old_flags'), 'page_is_redirect=0 AND page_namespace=' . NS_MEDIAWIKI . ' AND page_latest=rev_id AND rev_text_id=old_id', $fname);
$this->mCache = array();
for ($row = $dbr->fetchObject($res); $row; $row = $dbr->fetchObject($res)) {
$this->mCache[$row->page_title] = Revision::getRevisionText($row);
}
# Negative caching
# Go through the language array and the extension array and make a note of
# any keys missing from the cache
foreach ($wgAllMessagesEn as $key => $value) {
$uckey = $wgLang->ucfirst($key);
if (!array_key_exists($uckey, $this->mCache)) {
$this->mCache[$uckey] = false;
}
}
# Make sure all extension messages are available
wfLoadAllExtensions();
# Add them to the cache
foreach ($this->mExtensionMessages as $key => $value) {
$uckey = $wgLang->ucfirst($key);
if (!array_key_exists($uckey, $this->mCache) && (isset($this->mExtensionMessages[$key][$wgLang->getCode()]) || isset($this->mExtensionMessages[$key]['en']))) {
$this->mCache[$uckey] = false;
}
}
$dbr->freeResult($res);
}
示例8: array
*/
$result = $dbw->select('archive', array('ar_rev_id', 'ar_text', 'ar_comment', 'ar_user', 'ar_user_text', 'ar_timestamp', 'ar_minor_edit', 'ar_flags', 'ar_text_id', 'ar_page_id', 'ar_len'), array('ar_namespace' => $page->getNamespace(), 'ar_title' => $page->getDBkey(), $oldones), __METHOD__, array('ORDER BY' => 'ar_timestamp'));
$revision = null;
$restored = 0;
while ($row = $dbw->fetchObject($result)) {
if ($row->ar_text_id) {
// Revision was deleted in 1.5+; text is in
// the regular text table, use the reference.
// Specify null here so the so the text is
// dereferenced for page length info if needed.
$revText = null;
} else {
// Revision was deleted in 1.4 or earlier.
// Text is squashed into the archive row, and
// a new text table entry will be created for it.
$revText = Revision::getRevisionText($row, 'ar_');
}
$revision = new Revision(array('page' => $pageId, 'id' => $row->ar_rev_id, 'text' => $revText, 'comment' => $row->ar_comment, 'user' => $row->ar_user, 'user_text' => $row->ar_user_text, 'timestamp' => $row->ar_timestamp, 'minor_edit' => $row->ar_minor_edit, 'text_id' => $row->ar_text_id, 'len' => $row->ar_len));
$revision->insertOn($dbw);
$restored++;
}
// Was anything restored at all?
if ($restored == 0) {
print "Nothing was restored\n";
exit(1);
}
if ($revision) {
// Attach the latest revision to the page...
$wasnew = $article->updateIfNewerOn($dbw, $revision, $previousRevId);
if ($newid || $wasnew) {
// Update site stats, link tables, etc
示例9: execute
//.........这里部分代码省略.........
$this->addTables('archive');
$this->addFields(array('ar_title', 'ar_namespace', 'ar_timestamp'));
if ($fld_revid) {
$this->addFields('ar_rev_id');
}
if ($fld_user) {
$this->addFields('ar_user_text');
}
if ($fld_comment) {
$this->addFields('ar_comment');
}
if ($fld_minor) {
$this->addFields('ar_minor_edit');
}
if ($fld_len) {
$this->addFields('ar_len');
}
if ($fld_content) {
$this->addTables('text');
$this->addFields(array('ar_text', 'ar_text_id', 'old_text', 'old_flags'));
$this->addWhere('ar_text_id = old_id');
// This also means stricter restrictions
if (!$wgUser->isAllowed('undelete')) {
$this->dieUsage('You don\'t have permission to view deleted revision content', 'permissiondenied');
}
}
// Check limits
$userMax = $fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1;
$botMax = $fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2;
if ($limit == 'max') {
$limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
$this->getResult()->addValue('limits', 'limit', $limit);
}
$this->validateLimit('limit', $params['limit'], 1, $userMax, $botMax);
if ($fld_token) {
// Undelete tokens are identical for all pages, so we cache one here
$token = $wgUser->editToken();
}
// We need a custom WHERE clause that matches all titles.
if (count($titles) > 0) {
$lb = new LinkBatch($titles);
$where = $lb->constructSet('ar', $db);
$this->addWhere($where);
}
$this->addOption('LIMIT', $params['limit'] + 1);
$this->addWhereRange('ar_timestamp', $params['dir'], $params['start'], $params['end']);
if (isset($params['namespace'])) {
$this->addWhereFld('ar_namespace', $params['namespace']);
}
$res = $this->select(__METHOD__);
$pages = array();
$count = 0;
// First populate the $pages array
while ($row = $db->fetchObject($res)) {
if ($count++ == $params['limit']) {
// We've had enough
$this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->ar_timestamp));
break;
}
$rev = array();
$rev['timestamp'] = wfTimestamp(TS_ISO_8601, $row->ar_timestamp);
if ($fld_revid) {
$rev['revid'] = $row->ar_rev_id;
}
if ($fld_user) {
$rev['user'] = $row->ar_user_text;
}
if ($fld_comment) {
$rev['comment'] = $row->ar_comment;
}
if ($fld_minor) {
if ($row->ar_minor_edit == 1) {
$rev['minor'] = '';
}
}
if ($fld_len) {
$rev['len'] = $row->ar_len;
}
if ($fld_content) {
ApiResult::setContent($rev, Revision::getRevisionText($row));
}
$t = Title::makeTitle($row->ar_namespace, $row->ar_title);
if (!isset($pages[$t->getPrefixedText()])) {
$pages[$t->getPrefixedText()] = array('title' => $t->getPrefixedText(), 'ns' => intval($row->ar_namespace), 'revisions' => array($rev));
if ($fld_token) {
$pages[$t->getPrefixedText()]['token'] = $token;
}
} else {
$pages[$t->getPrefixedText()]['revisions'][] = $rev;
}
}
$db->freeResult($res);
// We don't want entire pagenames as keys, so let's make this array indexed
foreach ($pages as $page) {
$result->setIndexedTagName($page['revisions'], 'rev');
$data[] = $page;
}
$result->setIndexedTagName($data, 'page');
$result->addValue('query', $this->getModuleName(), $data);
}
示例10: writeRevision
/**
* Dumps a "<revision>" section on the output stream, with
* data filled in from the given database row.
*
* @param $row object
* @return string
* @access private
*/
function writeRevision($row)
{
wfProfileIn(__METHOD__);
$out = " <revision>\n";
$out .= " " . Xml::element('id', null, strval($row->rev_id)) . "\n";
if ($row->rev_parent_id) {
$out .= " " . Xml::element('parentid', null, strval($row->rev_parent_id)) . "\n";
}
$out .= $this->writeTimestamp($row->rev_timestamp);
if ($row->rev_deleted & Revision::DELETED_USER) {
$out .= " " . Xml::element('contributor', array('deleted' => 'deleted')) . "\n";
} else {
$out .= $this->writeContributor($row->rev_user, $row->rev_user_text);
}
if ($row->rev_minor_edit) {
$out .= " <minor/>\n";
}
if ($row->rev_deleted & Revision::DELETED_COMMENT) {
$out .= " " . Xml::element('comment', array('deleted' => 'deleted')) . "\n";
} elseif ($row->rev_comment != '') {
$out .= " " . Xml::elementClean('comment', array(), strval($row->rev_comment)) . "\n";
}
if ($row->rev_sha1 && !($row->rev_deleted & Revision::DELETED_TEXT)) {
$out .= " " . Xml::element('sha1', null, strval($row->rev_sha1)) . "\n";
} else {
$out .= " <sha1/>\n";
}
$text = '';
if ($row->rev_deleted & Revision::DELETED_TEXT) {
$out .= " " . Xml::element('text', array('deleted' => 'deleted')) . "\n";
} elseif (isset($row->old_text)) {
// Raw text from the database may have invalid chars
$text = strval(Revision::getRevisionText($row));
$out .= " " . Xml::elementClean('text', array('xml:space' => 'preserve', 'bytes' => intval($row->rev_len)), strval($text)) . "\n";
} else {
// Stub output
$out .= " " . Xml::element('text', array('id' => $row->rev_text_id, 'bytes' => intval($row->rev_len)), "") . "\n";
}
wfRunHooks('XmlDumpWriterWriteRevision', array(&$this, &$out, $row, $text));
$out .= " </revision>\n";
wfProfileOut(__METHOD__);
return $out;
}
示例11: filterChanged
/**
* Filters list of keys according to whether the current translation
* differs from the commited translation.
* @param string[] $keys List of keys to filter.
* @param bool $condition True to filter changed translations, false
* to filter unchanged translations.
* @return string[] Filtered keys.
*/
protected function filterChanged(array $keys, $condition)
{
$this->loadData($keys);
$origKeys = array();
if ($condition === false) {
$origKeys = $keys;
}
foreach ($this->dbData as $row) {
$mkey = $this->rowToKey($row);
if (!isset($this->infile[$mkey])) {
continue;
}
$text = Revision::getRevisionText($row);
if ($this->infile[$mkey] === $text) {
// Remove unchanged messages from the list
unset($keys[$mkey]);
}
}
// Remove the messages which have not changed from the list
if ($condition === false) {
$keys = $this->filterOnCondition($keys, $origKeys, false);
}
return $keys;
}
示例12: getTextFromRow
/**
* Get the text from an archive row containing ar_text, ar_flags and ar_text_id
*
* @param object $row Database row
* @return string
*/
function getTextFromRow($row)
{
if (is_null($row->ar_text_id)) {
// An old row from MediaWiki 1.4 or previous.
// Text is embedded in this row in classic compression format.
return Revision::getRevisionText($row, 'ar_');
}
// New-style: keyed to the text storage backend.
$dbr = wfGetDB(DB_SLAVE);
$text = $dbr->selectRow('text', array('old_text', 'old_flags'), array('old_id' => $row->ar_text_id), __METHOD__);
return Revision::getRevisionText($text);
}
示例13: writeRevision
/**
* Dumps a "<revision>" section on the output stream, with
* data filled in from the given database row.
*
* @param object $row
* @return string
* @access private
*/
function writeRevision($row)
{
wfProfileIn(__METHOD__);
$out = " <revision>\n";
$out .= " " . Xml::element('id', null, strval($row->rev_id)) . "\n";
if (isset($row->rev_parent_id) && $row->rev_parent_id) {
$out .= " " . Xml::element('parentid', null, strval($row->rev_parent_id)) . "\n";
}
$out .= $this->writeTimestamp($row->rev_timestamp);
if (isset($row->rev_deleted) && $row->rev_deleted & Revision::DELETED_USER) {
$out .= " " . Xml::element('contributor', array('deleted' => 'deleted')) . "\n";
} else {
$out .= $this->writeContributor($row->rev_user, $row->rev_user_text);
}
if (isset($row->rev_minor_edit) && $row->rev_minor_edit) {
$out .= " <minor/>\n";
}
if (isset($row->rev_deleted) && $row->rev_deleted & Revision::DELETED_COMMENT) {
$out .= " " . Xml::element('comment', array('deleted' => 'deleted')) . "\n";
} elseif ($row->rev_comment != '') {
$out .= " " . Xml::elementClean('comment', array(), strval($row->rev_comment)) . "\n";
}
if (isset($row->rev_content_model) && !is_null($row->rev_content_model)) {
$content_model = strval($row->rev_content_model);
} else {
// probably using $wgContentHandlerUseDB = false;
$title = Title::makeTitle($row->page_namespace, $row->page_title);
$content_model = ContentHandler::getDefaultModelFor($title);
}
$content_handler = ContentHandler::getForModelID($content_model);
if (isset($row->rev_content_format) && !is_null($row->rev_content_format)) {
$content_format = strval($row->rev_content_format);
} else {
// probably using $wgContentHandlerUseDB = false;
$content_format = $content_handler->getDefaultFormat();
}
$text = '';
if (isset($row->rev_deleted) && $row->rev_deleted & Revision::DELETED_TEXT) {
$out .= " " . Xml::element('text', array('deleted' => 'deleted')) . "\n";
} elseif (isset($row->old_text)) {
// Raw text from the database may have invalid chars
$text = strval(Revision::getRevisionText($row));
$text = $content_handler->exportTransform($text, $content_format);
$out .= " " . Xml::elementClean('text', array('xml:space' => 'preserve', 'bytes' => intval($row->rev_len)), strval($text)) . "\n";
} else {
// Stub output
$out .= " " . Xml::element('text', array('id' => $row->rev_text_id, 'bytes' => intval($row->rev_len)), "") . "\n";
}
if (isset($row->rev_sha1) && $row->rev_sha1 && !($row->rev_deleted & Revision::DELETED_TEXT)) {
$out .= " " . Xml::element('sha1', null, strval($row->rev_sha1)) . "\n";
} else {
$out .= " <sha1/>\n";
}
$out .= " " . Xml::element('model', null, strval($content_model)) . "\n";
$out .= " " . Xml::element('format', null, strval($content_format)) . "\n";
wfRunHooks('XmlDumpWriterWriteRevision', array(&$this, &$out, $row, $text));
$out .= " </revision>\n";
wfProfileOut(__METHOD__);
return $out;
}
示例14: compressWithConcat
//.........这里部分代码省略.........
$this->output("{$pageId}\t" . $titleObj->getPrefixedDBkey() . " ");
# Load revisions
$revRes = $dbw->select($tables, $fields, array_merge(array('rev_page' => $pageRow->page_id, 'rev_id < ' . $pageRow->page_latest), $conds), __METHOD__, $revLoadOptions);
$revs = array();
foreach ($revRes as $revRow) {
$revs[] = $revRow;
}
if (count($revs) < 2) {
# No revisions matching, no further processing
$this->output("\n");
continue;
}
# For each chunk
$i = 0;
while ($i < count($revs)) {
if ($i < count($revs) - $maxChunkSize) {
$thisChunkSize = $maxChunkSize;
} else {
$thisChunkSize = count($revs) - $i;
}
$chunk = new ConcatenatedGzipHistoryBlob();
$stubs = array();
$dbw->begin(__METHOD__);
$usedChunk = false;
$primaryOldid = $revs[$i]->rev_text_id;
// @codingStandardsIgnoreStart Ignore avoid function calls in a FOR loop test part warning
# Get the text of each revision and add it to the object
for ($j = 0; $j < $thisChunkSize && $chunk->isHappy(); $j++) {
// @codingStandardsIgnoreEnd
$oldid = $revs[$i + $j]->rev_text_id;
# Get text
if ($loadStyle == self::LS_INDIVIDUAL) {
$textRow = $dbw->selectRow('text', array('old_flags', 'old_text'), array('old_id' => $oldid), __METHOD__, 'FOR UPDATE');
$text = Revision::getRevisionText($textRow);
} else {
$text = Revision::getRevisionText($revs[$i + $j]);
}
if ($text === false) {
$this->error("\nError, unable to get text in old_id {$oldid}");
#$dbw->delete( 'old', array( 'old_id' => $oldid ) );
}
if ($extdb == "" && $j == 0) {
$chunk->setText($text);
$this->output('.');
} else {
# Don't make a stub if it's going to be longer than the article
# Stubs are typically about 100 bytes
if (strlen($text) < 120) {
$stub = false;
$this->output('x');
} else {
$stub = new HistoryBlobStub($chunk->addItem($text));
$stub->setLocation($primaryOldid);
$stub->setReferrer($oldid);
$this->output('.');
$usedChunk = true;
}
$stubs[$j] = $stub;
}
}
$thisChunkSize = $j;
# If we couldn't actually use any stubs because the pages were too small, do nothing
if ($usedChunk) {
if ($extdb != "") {
# Move blob objects to External Storage
$stored = $storeObj->store($extdb, serialize($chunk));
示例15: getTextDb
/**
* May throw a database error if, say, the server dies during query.
*/
private function getTextDb($id)
{
global $wgContLang;
$row = $this->db->selectRow('text', array('old_text', 'old_flags'), array('old_id' => $id), __METHOD__);
$text = Revision::getRevisionText($row);
if ($text === false) {
return false;
}
$stripped = str_replace("\r", "", $text);
$normalized = $wgContLang->normalize($stripped);
return $normalized;
}