Exemple #1
0
 /**
  * Purges the cache of a page
  */
 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if (!$wgUser->isAllowed('purge') && !$this->getMain()->isInternalMode() && !$this->getMain()->getRequest()->wasPosted()) {
         $this->dieUsageMsg(array('mustbeposted', $this->getModuleName()));
     }
     $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 = MediaWiki::articleFromTitle($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);
 }
Exemple #2
0
 /**
  * Really find the title match.
  */
 private static function getNearMatchInternal($searchterm)
 {
     global $wgContLang;
     $allSearchTerms = array($searchterm);
     if ($wgContLang->hasVariants()) {
         $allSearchTerms = array_merge($allSearchTerms, $wgContLang->convertLinkToAllVariants($searchterm));
     }
     if (!wfRunHooks('SearchGetNearMatchBefore', array($allSearchTerms, &$titleResult))) {
         return $titleResult;
     }
     foreach ($allSearchTerms as $term) {
         # Exact match? No need to look further.
         $title = Title::newFromText($term);
         if (is_null($title)) {
             return null;
         }
         if ($title->getNamespace() == NS_SPECIAL || $title->isExternal() || $title->exists()) {
             return $title;
         }
         # See if it still otherwise has content is some sane sense
         $article = MediaWiki::articleFromTitle($title);
         if ($article->hasViewableContent()) {
             return $title;
         }
         # Now try all lower case (i.e. first letter capitalized)
         #
         $title = Title::newFromText($wgContLang->lc($term));
         if ($title && $title->exists()) {
             return $title;
         }
         # Now try capitalized string
         #
         $title = Title::newFromText($wgContLang->ucwords($term));
         if ($title && $title->exists()) {
             return $title;
         }
         # Now try all upper case
         #
         $title = Title::newFromText($wgContLang->uc($term));
         if ($title && $title->exists()) {
             return $title;
         }
         # Now try Word-Caps-Breaking-At-Word-Breaks, for hyphenated names etc
         $title = Title::newFromText($wgContLang->ucwordbreaks($term));
         if ($title && $title->exists()) {
             return $title;
         }
         // Give hooks a chance at better match variants
         $title = null;
         if (!wfRunHooks('SearchGetNearMatch', array($term, &$title))) {
             return $title;
         }
     }
     $title = Title::newFromText($searchterm);
     # Entering an IP address goes to the contributions page
     if ($title->getNamespace() == NS_USER && User::isIP($title->getText()) || User::isIP(trim($searchterm))) {
         return SpecialPage::getTitleFor('Contributions', $title->getDBkey());
     }
     # Entering a user goes to the user page whether it's there or not
     if ($title->getNamespace() == NS_USER) {
         return $title;
     }
     # Go to images that exist even if there's no local page.
     # There may have been a funny upload, or it may be on a shared
     # file repository such as Wikimedia Commons.
     if ($title->getNamespace() == NS_FILE) {
         $image = wfFindFile($title);
         if ($image) {
             return $title;
         }
     }
     # MediaWiki namespace? Page may be "implied" if not customized.
     # Just return it, with caps forced as the message system likes it.
     if ($title->getNamespace() == NS_MEDIAWIKI) {
         return Title::makeTitle(NS_MEDIAWIKI, $wgContLang->ucfirst($title->getText()));
     }
     # Quoted term? Try without the quotes...
     $matches = array();
     if (preg_match('/^"([^"]+)"$/', $searchterm, $matches)) {
         return SearchEngine::getNearMatch($matches[1]);
     }
     return null;
 }
Exemple #3
0
    exit;
}
if ($wgUseFileCache && isset($wgTitle)) {
    wfProfileIn('main-try-filecache');
    // Raw pages should handle cache control on their own,
    // even when using file cache. This reduces hits from clients.
    if ($action != 'raw' && HTMLFileCache::useFileCache()) {
        /* Try low-level file cache hit */
        $cache = new HTMLFileCache($wgTitle, $action);
        if ($cache->isFileCacheGood()) {
            /* Check incoming headers to see if client has this cached */
            if (!$wgOut->checkLastModified($cache->fileCacheTime())) {
                $cache->loadFromFileCache();
            }
            # Do any stats increment/watchlist stuff
            $wgArticle = MediaWiki::articleFromTitle($wgTitle);
            $wgArticle->viewUpdates();
            # Tell $wgOut that output is taken care of
            wfProfileOut('main-try-filecache');
            $mediaWiki->restInPeace();
            exit;
        }
    }
    wfProfileOut('main-try-filecache');
}
# Setting global variables in mediaWiki
$mediaWiki->setVal('action', $action);
$mediaWiki->setVal('DisabledActions', $wgDisabledActions);
$mediaWiki->setVal('DisableHardRedirects', $wgDisableHardRedirects);
$mediaWiki->setVal('EnableCreativeCommonsRdf', $wgEnableCreativeCommonsRdf);
$mediaWiki->setVal('EnableDublinCoreRdf', $wgEnableDublinCoreRdf);
function cdbfPurgeMainSubpage($article, $user, $text, $summary, $isMinor, $isWatch, $section, $section, $flags, $revision, $baseRevId)
{
    $title = $article->getTitle();
    $main = cdbfGetMainSubpage($title);
    if ($main != '' && $main != $title->getText()) {
        $mainTitle = Title::newFromText($main);
        $mainArticle = MediaWiki::articleFromTitle($mainTitle);
        $mainArticle->doPurge();
    }
    return true;
}