本文整理汇总了PHP中Revision::countByPageId方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::countByPageId方法的具体用法?PHP Revision::countByPageId怎么用?PHP Revision::countByPageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::countByPageId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: broken_testDoRollback
/**
* @todo FIXME: this is a better rollback test than the one below, but it
* keeps failing in jenkins for some reason.
*/
public function broken_testDoRollback()
{
$admin = new User();
$admin->setName("Admin");
$text = "one";
$page = $this->newPage("WikiPageTest_testDoRollback");
$page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), "section one", EDIT_NEW, false, $admin);
$user1 = new User();
$user1->setName("127.0.1.11");
$text .= "\n\ntwo";
$page = new WikiPage($page->getTitle());
$page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), "adding section two", 0, false, $user1);
$user2 = new User();
$user2->setName("127.0.2.13");
$text .= "\n\nthree";
$page = new WikiPage($page->getTitle());
$page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), "adding section three", 0, false, $user2);
# we are having issues with doRollback spuriously failing. Apparently
# the last revision somehow goes missing or not committed under some
# circumstances. So, make sure the last revision has the right user name.
$dbr = wfGetDB(DB_SLAVE);
$this->assertEquals(3, Revision::countByPageId($dbr, $page->getId()));
$page = new WikiPage($page->getTitle());
$rev3 = $page->getRevision();
$this->assertEquals('127.0.2.13', $rev3->getUserText());
$rev2 = $rev3->getPrevious();
$this->assertEquals('127.0.1.11', $rev2->getUserText());
$rev1 = $rev2->getPrevious();
$this->assertEquals('Admin', $rev1->getUserText());
# now, try the actual rollback
$admin->addGroup("sysop");
#XXX: make the test user a sysop...
$token = $admin->getEditToken(array($page->getTitle()->getPrefixedText(), $user2->getName()), null);
$errors = $page->doRollback($user2->getName(), "testing revert", $token, false, $details, $admin);
if ($errors) {
$this->fail("Rollback failed:\n" . print_r($errors, true) . ";\n" . print_r($details, true));
}
$page = new WikiPage($page->getTitle());
$this->assertEquals($rev2->getSha1(), $page->getRevision()->getSha1(), "rollback did not revert to the correct revision");
$this->assertEquals("one\n\ntwo", $page->getContent()->getNativeData());
}
示例2: countByTitle
/**
* Get count of revisions per page...not very efficient
* @param Database $db
* @param Title $title
*/
static function countByTitle($db, $title)
{
$id = $title->getArticleId();
if ($id) {
return Revision::countByPageId($db, $id);
}
return 0;
}
示例3: getRevCount
private function getRevCount(ApiResult $result)
{
$res = $result->getData();
$db = $this->getDB();
if (isset($res['query']) && isset($res['query']['pages'])) {
foreach ($this->getPageSet()->getGoodTitles() as $page_id => $oTitle) {
if (isset($res['query']['pages'][$page_id])) {
$revcount = Revision::countByPageId($db, $page_id);
$result->addValue(array("query", "pages", $page_id), "revcount", intval($revcount));
}
}
}
}