本文整理汇总了PHP中Article::doPurge方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::doPurge方法的具体用法?PHP Article::doPurge怎么用?PHP Article::doPurge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::doPurge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Purges the cache of a page
*/
public function execute()
{
global $wgUser;
$params = $this->extractRequestParams();
if (!$wgUser->isAllowed('purge')) {
$this->dieUsageMsg(array('cantpurge'));
}
if (!isset($params['titles'])) {
$this->dieUsageMsg(array('missingparam', 'titles'));
}
$result = array();
foreach ($params['titles'] as $t) {
$r = array();
$title = Title::newFromText($t);
if (!$title instanceof Title) {
$r['title'] = $t;
$r['invalid'] = '';
$result[] = $r;
continue;
}
ApiQueryBase::addTitleInfo($r, $title);
if (!$title->exists()) {
$r['missing'] = '';
$result[] = $r;
continue;
}
$article = new Article($title);
$article->doPurge();
// Directly purge and skip the UI part of purge().
$r['purged'] = '';
$result[] = $r;
}
$this->getResult()->setIndexedTagName($result, 'page');
$this->getResult()->addValue(null, $this->getModuleName(), $result);
}
示例2: doPurge
/**
* Purge quizElement's Article and QuizElement
*/
public function doPurge()
{
parent::doPurge();
wfDebug(__METHOD__ . "\n");
// purge poll's data
if (!empty($this->mQuizElement)) {
$this->mQuizElement->purge();
}
}
示例3: doPurge
/**
* Purge quiz (and articles embedding it) when quiz's page is purged
*/
public function doPurge()
{
parent::doPurge();
wfDebug(__METHOD__ . "\n");
// purge quiz's data
if (!empty($this->mQuiz)) {
$this->mQuiz->purge();
}
// purge QuizPlay article
$quizPlayTitle = Title::newFromText($this->getTitle()->getText(), NS_WIKIA_PLAYQUIZ);
$quizPlayArticle = new Article($quizPlayTitle);
$quizPlayArticle->doPurge();
}
示例4: doPurge
/**
* Purge quiz (and articles embedding it) when quiz's page is purged
*/
public function doPurge()
{
parent::doPurge();
wfDebug(__METHOD__ . "\n");
// purge quiz's data
if (!empty($this->mQuiz)) {
$this->mQuiz->purge();
}
// purge QuizPlay article
$quizPlayTitle = F::build('Title', array($this->getTitle()->getText(), NS_WIKIA_PLAYQUIZ), 'newFromText');
$quizPlayArticle = F::build('Article', array($quizPlayTitle));
$quizPlayArticle->doPurge();
}
示例5: doPurge
/**
* Override handling of action=purge
*/
function doPurge()
{
$this->img = new Image($this->mTitle);
if ($this->img->exists()) {
wfDebug("ImagePage::doPurge purging " . $this->img->getName() . "\n");
$update = new HTMLCacheUpdate($this->mTitle, 'imagelinks');
$update->doUpdate();
$this->img->purgeCache();
} else {
wfDebug("ImagePage::doPurge no image\n");
}
parent::doPurge();
}
示例6: doPurge
/**
* Override handling of action=purge
*/
public function doPurge()
{
$this->loadFile();
if ($this->img->exists()) {
wfDebug("ImagePage::doPurge purging " . $this->img->getName() . "\n");
$update = new HTMLCacheUpdate($this->mTitle, 'imagelinks');
$update->doUpdate();
$this->img->upgradeRow();
$this->img->purgeCache();
} else {
wfDebug("ImagePage::doPurge no image for " . $this->img->getName() . "; limiting purge to cache only\n");
// even if the file supposedly doesn't exist, force any cached information
// to be updated (in case the cached information is wrong)
$this->img->purgeCache();
}
parent::doPurge();
}
示例7:
videoLog( 'postmigration', 'VARIABLE_SET', "");
echo "Purging articles including videos:";
$rows = $dbw->query( "SELECT img_name FROM image WHERE img_media_type = 'VIDEO'" );
while( $image = $dbw->fetchObject( $rows ) ) {
$rows2 = $dbw->query( "SELECT distinct il_from FROM imagelinks WHERE il_to ='".mysql_real_escape_string($image->img_name)."'");
while( $page = $dbw->fetchObject( $rows2 ) ) {
global $wgTitle;
$oTitle = Title::newFromId( $page->il_from );
$wgTitle = $oTitle;
if ( $oTitle instanceof Title && $oTitle->exists() && ($oArticle = new Article ( $oTitle )) instanceof Article ) {
$oTitle->purgeSquid();
$oArticle->doPurge();
echo "+";
} else {
echo "-";
}
}
$dbw->freeResult($rows2);
}
echo "\nDone\n";
videoLog( 'postmigration', 'STOP', "");
wfWaitForSlaves( 2 );
?>
示例8: invalidateCache
protected function invalidateCache()
{
$title = $this->user->getUserPage();
$title->invalidateCache();
$title->purgeSquid();
$article = new Article($title);
$article->doPurge();
}
示例9: storeInPage
public function storeInPage()
{
$pageTitleObj = Title::newFromText($this->pageName);
$pageArticleObj = new Article($pageTitleObj);
$articleContents = $pageArticleObj->getContent();
// Remove the original hero text; if there's a newline at the end, we will strip it
// as new tag has one and we don't want a barrage of newlines
$newContent = mb_ereg_replace('<hero(.*?)/>\\n?', '', $articleContents, 'mi');
// Prepend the hero tag
$heroTag = Xml::element('hero', $attribs = ['description' => $this->description, 'imagename' => $this->imageName, 'cropposition' => $this->cropPosition]);
$newContent = $heroTag . PHP_EOL . $newContent;
// save and purge
$pageArticleObj->doEdit($newContent, '');
$pageArticleObj->doPurge();
}
示例10: testTimestamp
public function testTimestamp()
{
$this->markTestIncomplete();
$pagename = self::$username . '/NonArticle';
$title = Title::newFromText($pagename, NS_USER);
if ($title->exists()) {
$article = new Article($title);
$article->doPurge();
}
$agent = MwRdf::ModelingAgent($title);
$this->assertType('boolean', $agent->getTimestampResource());
$this->assertFalse($agent->getTimestampResource());
}
示例11: moveMainPage
/**
* move main page to SEO-friendly name
*/
private function moveMainPage()
{
global $wgSitename, $parserMemc, $wgContLanguageCode;
$source = wfMsgForContent('Mainpage');
$target = $wgSitename;
$sourceTitle = \Title::newFromText($source);
if (!$sourceTitle) {
$sourceTitle = \Title::newFromText('Main_Page');
if (!$sourceTitle) {
$this->error('invalid page title', ['title' => $source]);
return;
}
}
$mainArticle = new \Article($sourceTitle, 0);
if ($mainArticle->exists()) {
/**
* check target title
*/
$targetTitle = \Title::newFromText($target);
if ($targetTitle) {
$moveContext = ['source' => $sourceTitle->getPrefixedText(), 'target' => $targetTitle->getPrefixedText()];
if ($sourceTitle->getPrefixedText() !== $targetTitle->getPrefixedText()) {
$wikiaUser = \User::newFromName(self::WIKIA_USER);
$wrapper = new GlobalStateWrapper(['wgUser' => $wikiaUser]);
$err = $wrapper->wrap(function () use($sourceTitle, $targetTitle) {
return $sourceTitle->moveTo($targetTitle, false, 'SEO');
});
if ($err !== true) {
$this->error('main page move failed', $moveContext);
} else {
$this->info('main page moved', $moveContext);
/**
* fill Mediawiki:Mainpage with new title
*/
$mwMainPageTitle = \Title::newFromText('Mainpage', NS_MEDIAWIKI);
$mwMainPageArticle = new \Article($mwMainPageTitle, 0);
$mwMainPageArticle->doEdit($targetTitle->getText(), 'SEO', EDIT_SUPPRESS_RC | EDIT_MINOR | EDIT_FORCE_BOT, false, $wikiaUser);
$mwMainPageArticle->doPurge();
/**
* also move associated talk page if it exists
*/
$sourceTalkTitle = $sourceTitle->getTalkPage();
$targetTalkTitle = $targetTitle->getTalkPage();
if ($sourceTalkTitle instanceof \Title && $sourceTalkTitle->exists() && $targetTalkTitle instanceof \Title) {
$moveContext = ['source' => $sourceTalkTitle->getPrefixedText(), 'target' => $targetTalkTitle->getPrefixedText()];
$err = $wrapper->wrap(function () use($sourceTalkTitle, $targetTitle) {
return $sourceTalkTitle->moveTo($targetTitle->getTalkPage(), false, "SEO");
});
if ($err === true) {
$this->info('talk page moved', $moveContext);
} else {
$this->warning('talk page move failed', $moveContext);
}
}
}
} else {
$this->info('talk page not moved. source, destination are the same', $moveContext);
}
}
}
/**
* clear skin cache for rt#63874
*
* @todo establish what $code is exactly in this case
*/
$parserMemc->delete(wfMemcKey('sidebar', $wgContLanguageCode));
$parserMemc->delete(wfMemcKey('quartzsidebar'));
$parserMemc->delete(wfMemcKey('navlinks'));
$parserMemc->delete(wfMemcKey('MonacoData'));
$parserMemc->delete(wfMemcKey('MonacoDataOld'));
}
示例12: isset
function do_adjust_submit($titleKey, $mvd_id, $newTitle, $contextTitle, $outputMVD = '')
{
global $wgOut, $mvgIP, $wgUser;
//print "js_log('do_adjust_submit, move $titleKey to: $newTitle ')\n";
//get context from MVStream request title:
$this->get_overlay_context_from_title($contextTitle);
$this->reason = isset($_REQUEST['wpSummary']) ? $_REQUEST['wpSummary'] : wfMsg('mv_adjust_default_reason');
$this->moveTalk = true;
$this->watch = false;
//do the move:
if ($wgUser->pingLimiter('move')) {
$wgOut->rateLimited();
return php2jsObj(array('status' => 'error', 'error_txt' => $wgOut->getHTML()));
}
//we should only be adjusting MVD namespace items:
$ot = Title::newFromText($titleKey, MV_NS_MVD);
$nt = Title::newFromText($newTitle, MV_NS_MVD);
//make sure the old title exist (what we are moving from)
if (!$ot->exists()) {
$wgOut->addHTML('<p class="error">' . wfMsg('mv_adjust_old_title_missing', $ot->getText()) . "</p>\n");
return php2jsObj(array('status' => 'error', 'error_txt' => $wgOut->getHTML()));
}
//if the page we want to move to exists and starts with #REDIRECT override it
if ($nt->exists()) {
$ntArticle = new Article($nt);
$cur_text = $ntArticle->getContent();
if (substr($cur_text, 0, strlen('#REDIRECT')) == '#REDIRECT') {
//remove page (normal users can "delete mvd_pages if they are redirects)
$ntArticle->doDelete(wfMsgForContent('mv_redirect_and_delete_reason'));
//clear deletion log msg:
$wgOut->clearHTML();
}
}
# Delete to make way if requested (not dealt with for now)
//if ( $wgUser->isAllowed( 'delete' ) && $this->deleteAndMove ) {
// $article = new Article( $nt );
// This may output an error message and exit
// $article->doDelete( wfMsgForContent( 'delete_and_move_reason' ) );
//}
# don't allow moving to pages with # in
if (!$nt || $nt->getFragment() != '') {
$wgOut->addWikiText('<p class="error">' . wfMsg('badtitletext') . "</p>\n");
return php2jsObj(array('status' => 'error', 'error_txt' => $wgOut->getHTML()));
}
$old_article = new Article($ot);
$this->preMoveArtileText = $old_article->getContent();
unset($old_article);
/*
$pos1 = strpos($titleKey,'/');
$pos2 = strpos($newTitle,'/');
$nameKey = 'Mp_names'.$wgTitle.substr($titleKey, $pos1);
// $newnamekey = 'Mp_names:'.$wgTitle.'/'.$_REQUEST['mv_start_hr_'.$mvd_id].'/'.$_REQUEST['mv_end_hr_'.$mvd_id];
$newnamekey = 'Mp_names:/'.$_REQUEST['mv_start_hr_'.$mvd_id].'/'.$_REQUEST['mv_end_hr_'.$mvd_id];
*/
//$newnameKey = 'Mp_names:'.$_REQUEST['wgTitle'].'/'.$_REQUEST['mv_start_hr_'.$mvd_id].'/'.$_REQUEST['mv_end_hr_'.$mvd_id];
$oldnamekey = 'Mp_names' . substr($titleKey, strpos($titleKey, ':'));
$newnamekey = 'Mp_names' . substr($newTitle, strpos($newTitle, ':'));
//$nameKey = 'Mp_names'.substr($titleKey, strpos($titleKey,':'));
$tit = Title::newFromText($oldnamekey, MV_NS_MVD);
$tit2 = Title::newFromText($newnamekey, MV_NS_MVD);
$art = new Article($tit);
$art2 = new Article($tit2);
$text = $_REQUEST['smw_Spoken_By'];
$art2->doEdit($text, 'MP names DO NOT EDIT', EDIT_NEW);
$art2->doPurge();
$art->doDelete($this->reason, true);
//$error2 = $tit->moveTo( $tit2, true, $this->reason );
//$art = new Article($tit);
//$tit2 = Title::newFromText($newnamekey, MV_NS_MVD);
$wgOut->clearHTML();
//$art = new Article($tit);
//$art->doDelete("Article Moved");
//@@todo we should really just remove the old article (instead of putting a redirect there)
$error = $ot->moveTo($nt, true, $this->reason);
if ($error !== true) {
$wgOut->addWikiText('<p class="error">' . wfMsg($error) . "</p>\n");
return php2jsObj(array('status' => 'error', 'error_txt' => $wgOut->getHTML()));
} else {
/*print "js_log('should have moved the page');\n";
print "js_log('new page title: ".$nt->getText()."');\n";
//clear cache for title:
//$nt->invalidateCache();
//Article::onArticleEdit($nt);
global $wgDeferredUpdateList, $mediaWiki;
$mediaWiki->doUpdates( $wgDeferredUpdateList );
//try again:
$newTitle = Title::newFromText($nt->getText(), MV_NS_MVD);
$na = new Article($newTitle);
print "js_log('new page content: " .$na->getContent() . "');\n";
*/
}
//wfRunHooks( 'SpecialMovepageAfterMove', array( &$this , &$ot , &$nt ) ) ;
$ott = $ot->getTalkPage();
if ($ott->exists()) {
if ($this->moveTalk && !$ot->isTalkPage() && !$nt->isTalkPage()) {
$ntt = $nt->getTalkPage();
# Attempt the move
$error = $ott->moveTo($ntt, true, $this->reason);
if ($error === true) {
$talkmoved = 1;
//.........这里部分代码省略.........
示例13: moveMainPage
/**
* move main page to SEO-friendly name
*/
private function moveMainPage()
{
global $wgSitename, $wgUser, $parserMemc, $wgContLanguageCode;
$source = wfMsgForContent('Mainpage');
$target = $wgSitename;
$sourceTitle = Title::newFromText($source);
if (!$sourceTitle) {
$sourceTitle = Title::newFromText("Main_Page");
if (!$sourceTitle) {
Wikia::log(__METHOD__, "err", "Invalid page title: {$source} and Main_page");
return;
}
}
$mainArticle = new Article($sourceTitle, 0);
if ($mainArticle->exists()) {
/**
* check target title
*/
$targetTitle = Title::newFromText($target);
if ($targetTitle) {
if ($sourceTitle->getPrefixedText() !== $targetTitle->getPrefixedText()) {
Wikia::log(__METHOD__, "move", $sourceTitle->getPrefixedText() . ' --> ' . $targetTitle->getPrefixedText());
$err = $sourceTitle->moveTo($targetTitle, false, "SEO");
if ($err !== true) {
Wikia::log(__METHOD__, "move", "Moving FAILED");
} else {
/**
* fill Mediawiki:Mainpage with new title
*/
$mwMainPageTitle = Title::newFromText("Mainpage", NS_MEDIAWIKI);
$mwMainPageArticle = new Article($mwMainPageTitle, 0);
$mwMainPageArticle->doEdit($targetTitle->getText(), "SEO", EDIT_SUPPRESS_RC | EDIT_MINOR | EDIT_FORCE_BOT);
$mwMainPageArticle->doPurge();
Wikia::log(__METHOD__, "move", "Page moved");
/**
* also move associated talk page if it exists
*/
$sourceTalkTitle = $sourceTitle->getTalkPage();
$targetTalkTitle = $targetTitle->getTalkPage();
if ($sourceTalkTitle instanceof Title && $sourceTalkTitle->exists() && $targetTalkTitle instanceof Title) {
Wikia::log(__METHOD__, "move", $sourceTalkTitle->getPrefixedText() . ' --> ' . $targetTalkTitle->getPrefixedText());
$err = $sourceTalkTitle->moveTo($targetTitle->getTalkPage(), false, "SEO");
if ($err === true) {
Wikia::log(__METHOD__, "move", "Moved talk page");
} else {
Wikia::log(__METHOD__, "move", "Found talk page but moving FAILED");
}
}
}
} else {
Wikia::log(__METHOD__, "move", "source {$source} and target {$target} are the same");
}
}
}
/**
* clear skin cache for rt#63874
* @todo establish what $code is exactly in this case
*/
$parserMemc->delete(wfMemcKey('sidebar', $wgContLanguageCode));
$parserMemc->delete(wfMemcKey('quartzsidebar'));
$parserMemc->delete(wfMemcKey('navlinks'));
$parserMemc->delete(wfMemcKey('MonacoData'));
$parserMemc->delete(wfMemcKey('MonacoDataOld'));
}
示例14: onArticleSaveComplete
/**
* Purges aricle cache on save when smartlist tag is present.
* @param Article $article The article that is created.
* @param User $user User that saved the article.
* @param string $text New text.
* @param string $summary Edit summary.
* @param bool $minoredit Marked as minor.
* @param bool $watchthis Put on watchlist.
* @param int $sectionanchor Not in use any more.
* @param int $flags Bitfield.
* @param Revision $revision New revision object.
* @param Status $status Status object (since MW1.14)
* @param int $baseRevId Revision ID this edit is based on (since MW1.15)
* @param bool $redirect Redirect user back to page after edit (since MW1.17)
* @return bool allow other hooked methods to be executed. Always true
*/
public function onArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
{
if (stripos($text, "smartlist") || stripos($text, "infobox")) {
$article->doPurge();
}
return true;
}
示例15: updateTranslationPage
public static function updateTranslationPage(TranslatablePage $page, $code, $user, $flags, $summary)
{
$source = $page->getTitle();
$target = Title::makeTitle($source->getNamespace(), $source->getDBkey() . "/{$code}");
// We don't know and don't care
$flags &= ~EDIT_NEW & ~EDIT_UPDATE;
// Update the target page
$job = RenderJob::newJob($target);
$job->setUser($user);
$job->setSummary($summary);
$job->setFlags($flags);
$job->run();
// Regenerate translation caches
$page->getTranslationPercentages('force');
// Invalidate caches
$pages = $page->getTranslationPages();
foreach ($pages as $title) {
$article = new Article($title, 0);
$article->doPurge();
}
// And the source page itself too
$article = new Article($page->getTitle(), 0);
$article->doPurge();
}