From: Sam Reed Date: Thu, 29 Sep 2011 22:08:00 +0000 (+0000) Subject: Back out r95396 and friends X-Git-Tag: 1.31.0-rc.0~27356 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=937fc3bcfd0f3d1112e528b13c4829816e820045;p=lhc%2Fweb%2Fwiklou.git Back out r95396 and friends --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index e596739b64..76a17f7389 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -559,7 +559,6 @@ $wgAutoloadLocalClasses = array( 'BmpHandler' => 'includes/media/BMP.php', 'DjVuHandler' => 'includes/media/DjVu.php', 'Exif' => 'includes/media/Exif.php', - 'GlobalUsageQuery' => 'includes/GlobalUsageQuery.php', 'FormatExif' => 'includes/media/FormatMetadata.php', 'FormatMetadata' => 'includes/media/FormatMetadata.php', 'GIFHandler' => 'includes/media/GIF.php', @@ -773,8 +772,6 @@ $wgAutoloadLocalClasses = array( 'SpecialEmailUser' => 'includes/specials/SpecialEmailuser.php', 'SpecialExport' => 'includes/specials/SpecialExport.php', 'SpecialFilepath' => 'includes/specials/SpecialFilepath.php', - 'SpecialGlobalFileUsage' => 'includes/specials/SpecialGlobalFileUsage.php', - 'SpecialGlobalTemplateUsage' => 'includes/specials/SpecialGlobalTemplateUsage.php', 'SpecialImport' => 'includes/specials/SpecialImport.php', 'SpecialListFiles' => 'includes/specials/SpecialListfiles.php', 'SpecialListGroupRights' => 'includes/specials/SpecialListgrouprights.php', diff --git a/includes/BacklinkCache.php b/includes/BacklinkCache.php index a6ad003986..1194015c52 100644 --- a/includes/BacklinkCache.php +++ b/includes/BacklinkCache.php @@ -176,25 +176,6 @@ class BacklinkCache { return $ta; } - /** - * Get the distant backtemplatelinks for the table globaltemplatelinks. Cached in process memory only. - * @return ResultWrapper list of distant pages that use the local title - */ - public function getDistantTemplateLinks( ) { - global $wgGlobalDatabase, $wgLocalInterwiki; - - $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); - $res = $dbr->select( - array( 'globaltemplatelinks', 'globalinterwiki' ), - array( 'gtl_from_wiki', 'gtl_from_page', 'gtl_from_title', 'giw_prefix' ), - array( 'gtl_to_prefix' => $wgLocalInterwiki, 'gtl_to_title' => $this->title->getDBkey( ) ), - __METHOD__, - null, - array( 'gtl_from_wiki = giw_wikiid' ) - ); - return $res; - } - /** * Get the field name prefix for a given table * @param $table String @@ -206,7 +187,6 @@ class BacklinkCache { 'categorylinks' => 'cl', 'templatelinks' => 'tl', 'redirect' => 'rd', - 'globaltemplatelinks' => 'gtl', ); if ( isset( $prefixes[$table] ) ) { @@ -305,7 +285,7 @@ class BacklinkCache { */ public function partition( $table, $batchSize ) { - // 1) try partition cache ... + // 1) try partition cache ... if ( isset( $this->partitionCache[$table][$batchSize] ) ) { wfDebug( __METHOD__ . ": got from partition cache\n" ); @@ -360,7 +340,7 @@ class BacklinkCache { * Partition a DB result with backlinks in it into batches * @param $res ResultWrapper database result * @param $batchSize integer - * @return array @see + * @return array @see */ protected function partitionResult( $res, $batchSize ) { $batches = array(); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 71ecd5c124..1f8c17e8d1 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2998,34 +2998,13 @@ $wgExpensiveParserFunctionLimit = 100; $wgPreprocessorCacheThreshold = 1000; /** - * Enable interwiki transcluding. Only when iw_trans=1 in the interwiki table. - * If the interwiki prefix is associated with a wiki ID in the interwiki table, - * then the distant templates will be retrieved in the distant DB. If there is - * no wiki ID but a API URL for that prefix, the distant templates will be - * retrieved using the API and cached in memcached. + * Enable interwiki transcluding. Only when iw_trans=1. */ -$wgEnableInterwikiTranscluding = false; +$wgEnableScaryTranscluding = false; /** - * If $wgEnableInterwikiTranscluding is set to true and if an interwiki prefix - * is associated with a wiki ID, then, this option should be set to true to - * enable the cache invalidation of the distant pages when the local templates - * are edited and also to display the list of the distant templates used by - * the local pages. Enabling this requires to set up a global shared database - * (see next option $wgGlobalDatabase). + * (see next option $wgGlobalDatabase). */ -$wgEnableInterwikiTemplatesTracking = false; - -/** - * If $wgEnableInterwikiTemplatesTracking is set to true, this option should - * contain the wiki ID of the database that hosts the globaltemplatelinks table. - */ -$wgGlobalDatabase = ''; - -/** - * If $wgEnableInterwikiTranscluding is set to true and if an interwiki - * prefix is associated with an API URL and no wiki ID, this will be - * the expiry time for the transcluded templates cached in memcached. */ $wgTranscludeCacheExpiry = 3600; @@ -5198,8 +5177,6 @@ $wgSpecialPageGroups = array( 'Export' => 'pagetools', 'Import' => 'pagetools', 'Whatlinkshere' => 'pagetools', - 'GlobalFileUsage' => 'pagetools', - 'GlobalTemplateUsage' => 'pagetools', 'Statistics' => 'wiki', 'Version' => 'wiki', diff --git a/includes/EditPage.php b/includes/EditPage.php index d8f913ffd6..d1c8ec5a8f 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1376,7 +1376,7 @@ class EditPage { * during form output near the top, for captchas and the like. */ function showEditForm( $formCallback = null ) { - global $wgOut, $wgUser, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; + global $wgOut, $wgUser; wfProfileIn( __METHOD__ ); @@ -1410,6 +1410,7 @@ class EditPage { $toolbar = ''; } + $wgOut->addHTML( $this->editFormPageTop ); if ( $wgUser->getOption( 'previewontop' ) ) { @@ -1421,9 +1422,6 @@ class EditPage { $templates = $this->getTemplates(); $formattedtemplates = Linker::formatTemplates( $templates, $this->preview, $this->section != ''); - $distantTemplates = $this->getDistantTemplates(); - $formattedDistantTemplates = Linker::formatDistantTemplates( $distantTemplates, $this->preview, $this->section != '' ); - $hiddencats = $this->mArticle->getHiddenCategories(); $formattedhiddencats = Linker::formatHiddenCategories( $hiddencats ); @@ -1522,21 +1520,6 @@ HTML
{$formattedtemplates}
-HTML -); - - if ( $wgEnableInterwikiTranscluding && $wgEnableInterwikiTemplatesTracking ) { - $wgOut->addHTML( <<editFormTextAfterTools} -
-{$formattedDistantTemplates} -
-HTML -); - } - - $wgOut->addHTML( <<editFormTextAfterTools}
{$formattedhiddencats}
@@ -2198,28 +2181,6 @@ HTML } } - function getDistantTemplates() { - global $wgEnableInterwikiTemplatesTracking; - if ( !$wgEnableInterwikiTemplatesTracking ) { - return array( ); - } - if ( $this->preview || $this->section != '' ) { - $templates = array(); - if ( !isset( $this->mParserOutput ) ) return $templates; - $templatesList = $this->mParserOutput->getDistantTemplates(); - foreach( $templatesList as $prefix => $templatesbyns ) { - foreach( $templatesbyns as $ns => $template ) { - foreach( array_keys( $template ) as $dbk ) { - $templates[] = Title::makeTitle( $ns, $dbk, null, $prefix ); - } - } - } - return $templates; - } else { - return $this->mArticle->getUsedDistantTemplates(); - } - } - /** * Call the stock "user is blocked" page */ diff --git a/includes/GlobalUsageQuery.php b/includes/GlobalUsageQuery.php deleted file mode 100644 index 50f0bfbc4b..0000000000 --- a/includes/GlobalUsageQuery.php +++ /dev/null @@ -1,367 +0,0 @@ -db = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); - if ( $target instanceof Title && $target->getNamespace( ) == NS_FILE ) { - $this->target = $target->getDBKey(); - } else { - $this->target = $target; - } - $this->offset = array(); - } - - /** - * Set the offset parameter - * - * @param $offset string offset - * @param $reversed bool True if this is the upper offset - */ - public function setOffset( $offset, $reversed = null ) { - if ( !is_null( $reversed ) ) { - $this->reversed = $reversed; - } - - if ( !is_array( $offset ) ) { - $offset = explode( '|', $offset ); - } - - if ( count( $offset ) == 3 ) { - $this->offset = $offset; - return true; - } else { - return false; - } - } - /** - * Return the offset set by the user - * - * @return array offset - */ - public function getOffsetString() { - return implode( '|', $this->offset ); - } - /** - * Is the result reversed - * - * @return bool - */ - public function isReversed() { - return $this->reversed; - } - - /** - * Returns the string used for continuation in a file search - * - * @return string - * - */ - public function getContinueFileString() { - if ( $this->hasMore() ) { - return "{$this->lastRow->gil_to}|{$this->lastRow->gil_wiki}|{$this->lastRow->gil_page}"; - } else { - return ''; - } - } - - /** - * Returns the string used for continuation in a template search - * - * @return string - * - */ - public function getContinueTemplateString() { - if ( $this->hasMore() ) { - return "{$this->lastRow->gtl_to_title}|{$this->lastRow->gtl_from_wiki}|{$this->lastRow->gtl_from_page}"; - } else { - return ''; - } - } - - /** - * Set the maximum amount of items to return. Capped at 500. - * - * @param $limit int The limit - */ - public function setLimit( $limit ) { - $this->limit = min( $limit, 500 ); - } - /** - * Returns the user set limit - */ - public function getLimit() { - return $this->limit; - } - - /** - * Set whether to filter out the local usage - */ - public function filterLocal( $value = true ) { - $this->filterLocal = $value; - } - - /** - * Executes the query for a file search - */ - public function searchTemplate() { - global $wgLocalInterwiki; - - /* Construct a where clause */ - // Add target template(s) - $where = array( 'gtl_to_prefix' => $wgLocalInterwiki, - 'gtl_to_namespace' => $this->target->getNamespace( ), - 'gtl_to_title' => $this->target->getDBkey( ) - ); - - // Set the continuation condition - $order = 'ASC'; - if ( $this->offset ) { - $qTo = $this->db->addQuotes( $this->offset[0] ); - $qWiki = $this->db->addQuotes( $this->offset[1] ); - $qPage = intval( $this->offset[2] ); - - // Check which limit we got in order to determine which way to traverse rows - if ( $this->reversed ) { - // Reversed traversal; do not include offset row - $op1 = '<'; - $op2 = '<'; - $order = 'DESC'; - } else { - // Normal traversal; include offset row - $op1 = '>'; - $op2 = '>='; - $order = 'ASC'; - } - - $where[] = "(gtl_to_title $op1 $qTo) OR " . - "(gtl_to_title = $qTo AND gtl_from_wiki $op1 $qWiki) OR " . - "(gtl_to_title = $qTo AND gtl_from_wiki = $qWiki AND gtl_from_page $op2 $qPage)"; - } - - /* Perform select (Duh.) */ - $res = $this->db->select( - array( - 'globaltemplatelinks', - 'globalnamespaces' - ), - array( - 'gtl_to_title', - 'gtl_from_wiki', - 'gtl_from_page', - 'gtl_from_namespace', - 'gtl_from_title' - ), - $where, - __METHOD__, - array( - 'ORDER BY' => "gtl_to_title $order, gtl_from_wiki $order, gtl_from_page $order", - // Select an extra row to check whether we have more rows available - 'LIMIT' => $this->limit + 1, - ), - array( - 'gtl_from_namespace = gn_namespace' - ) - ); - - /* Process result */ - // Always return the result in the same order; regardless whether reversed was specified - // reversed is really only used to determine from which direction the offset is - $rows = array(); - foreach ( $res as $row ) { - $rows[] = $row; - } - if ( $this->reversed ) { - $rows = array_reverse( $rows ); - } - - // Build the result array - $count = 0; - $this->hasMore = false; - $this->result = array(); - foreach ( $rows as $row ) { - $count++; - if ( $count > $this->limit ) { - // We've reached the extra row that indicates that there are more rows - $this->hasMore = true; - $this->lastRow = $row; - break; - } - - if ( !isset( $this->result[$row->gtl_to_title] ) ) { - $this->result[$row->gtl_to_title] = array(); - } - if ( !isset( $this->result[$row->gtl_to_title][$row->gtl_from_wiki] ) ) { - $this->result[$row->gtl_to_title][$row->gtl_from_wiki] = array(); - } - - $this->result[$row->gtl_to_title][$row->gtl_from_wiki][] = array( - 'template' => $row->gtl_to_title, - 'id' => $row->gtl_from_page, - 'namespace' => $row->gn_namespacetext, - 'title' => $row->gtl_from_title, - 'wiki' => $row->gtl_from_wiki, - ); - } - } - - /** - * Executes the query for a template search - */ - public function searchFile() { - /* Construct a where clause */ - // Add target image(s) - $where = array( 'gil_to' => $this->target ); - - if ( $this->filterLocal ) { - // Don't show local file usage - $where[] = 'gil_wiki != ' . $this->db->addQuotes( wfWikiId() ); - } - - // Set the continuation condition - $order = 'ASC'; - if ( $this->offset ) { - $qTo = $this->db->addQuotes( $this->offset[0] ); - $qWiki = $this->db->addQuotes( $this->offset[1] ); - $qPage = intval( $this->offset[2] ); - - // Check which limit we got in order to determine which way to traverse rows - if ( $this->reversed ) { - // Reversed traversal; do not include offset row - $op1 = '<'; - $op2 = '<'; - $order = 'DESC'; - } else { - // Normal traversal; include offset row - $op1 = '>'; - $op2 = '>='; - $order = 'ASC'; - } - - $where[] = "(gil_to $op1 $qTo) OR " . - "(gil_to = $qTo AND gil_wiki $op1 $qWiki) OR " . - "(gil_to = $qTo AND gil_wiki = $qWiki AND gil_page $op2 $qPage)"; - } - - /* Perform select (Duh.) */ - $res = $this->db->select( 'globalimagelinks', - array( - 'gil_to', - 'gil_wiki', - 'gil_page', - 'gil_page_namespace', - 'gil_page_title' - ), - $where, - __METHOD__, - array( - 'ORDER BY' => "gil_to $order, gil_wiki $order, gil_page $order", - // Select an extra row to check whether we have more rows available - 'LIMIT' => $this->limit + 1, - ) - ); - - /* Process result */ - // Always return the result in the same order; regardless whether reversed was specified - // reversed is really only used to determine from which direction the offset is - $rows = array(); - foreach ( $res as $row ) { - $rows[] = $row; - } - if ( $this->reversed ) { - $rows = array_reverse( $rows ); - } - - // Build the result array - $count = 0; - $this->hasMore = false; - $this->result = array(); - foreach ( $rows as $row ) { - $count++; - if ( $count > $this->limit ) { - // We've reached the extra row that indicates that there are more rows - $this->hasMore = true; - $this->lastRow = $row; - break; - } - - if ( !isset( $this->result[$row->gil_to] ) ) { - $this->result[$row->gil_to] = array(); - } - if ( !isset( $this->result[$row->gil_to][$row->gil_wiki] ) ) { - $this->result[$row->gil_to][$row->gil_wiki] = array(); - } - - $this->result[$row->gil_to][$row->gil_wiki][] = array( - 'image' => $row->gil_to, - 'id' => $row->gil_page, - 'namespace' => $row->gil_page_namespace, - 'title' => $row->gil_page_title, - 'wiki' => $row->gil_wiki, - ); - } - } - - /** - * Returns the result set. The result is a 4 dimensional array - * (file, wiki, page), whose items are arrays with keys: - * - image or template: File name or template name - * - id: Page id - * - namespace: Page namespace text - * - title: Unprefixed page title - * - wiki: Wiki id - * - * @return array Result set - */ - public function getResult() { - return $this->result; - } - /** - * Returns a 3 dimensional array with the result of the first file. Useful - * if only one resource was queried. - * - * For further information see documentation of getResult() - * - * @return array Result set - */ - public function getSingleResult() { - if ( $this->result ) { - return current( $this->result ); - } else { - return array(); - } - } - - /** - * Returns whether there are more results - * - * @return bool - */ - public function hasMore() { - return $this->hasMore; - } - - /** - * Returns the result length - * - * @return int - */ - public function count() { - return count( $this->result ); - } -} diff --git a/includes/Linker.php b/includes/Linker.php index 6d264c37f1..71a510706f 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1661,42 +1661,6 @@ class Linker { return $outText; } - /** - * Returns HTML for the "templates used on this page" list. - * - * @param $templates Array of templates from Article::getUsedTemplate - * or similar - * @param $preview Boolean: whether this is for a preview - * @param $section Boolean: whether this is for a section edit - * @return String: HTML output - */ - public static function formatDistantTemplates( $templates, $preview = false, $section = false ) { - wfProfileIn( __METHOD__ ); - - $outText = ''; - if ( count( $templates ) > 0 ) { - - # Construct the HTML - $outText = '
'; - if ( $preview ) { - $outText .= wfMsgExt( 'distanttemplatesusedpreview', array( 'parse' ), count( $templates ) ); - } elseif ( $section ) { - $outText .= wfMsgExt( 'distanttemplatesusedsection', array( 'parse' ), count( $templates ) ); - } else { - $outText .= wfMsgExt( 'distanttemplatesused', array( 'parse' ), count( $templates ) ); - } - $outText .= "
'; - } - wfProfileOut( __METHOD__ ); - return $outText; - } - /** * Returns HTML for the "hidden categories on this page" list. * diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 09d0866dc9..3252fb655f 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -29,7 +29,6 @@ class LinksUpdate { $mLinks, //!< Map of title strings to IDs for the links in the document $mImages, //!< DB keys of the images used, in the array key only $mTemplates, //!< Map of title strings to IDs for the template references, including broken ones - $mDistantTemplates,//!< Map of title strings to IDs for the distant template references, including broken ones $mExternals, //!< URLs of external links, array key only $mCategories, //!< Map of category names to sort keys $mInterlangs, //!< Map of language codes to titles @@ -67,7 +66,6 @@ class LinksUpdate { $this->mLinks = $parserOutput->getLinks(); $this->mImages = $parserOutput->getImages(); $this->mTemplates = $parserOutput->getTemplates(); - $this->mDistantTemplates = $parserOutput->getDistantTemplates(); $this->mExternals = $parserOutput->getExternalLinks(); $this->mCategories = $parserOutput->getCategories(); $this->mProperties = $parserOutput->getProperties(); @@ -154,15 +152,6 @@ class LinksUpdate { $this->incrTableUpdate( 'templatelinks', 'tl', $this->getTemplateDeletions( $existing ), $this->getTemplateInsertions( $existing ) ); - # Distant template links - global $wgGlobalDatabase; - if ( $wgGlobalDatabase ) { - $existing = $this->getDistantExistingTemplates(); - $this->incrSharedTableUpdate( 'globaltemplatelinks', 'gtl', - $this->getDistantTemplateDeletions( $existing ), - $this->getDistantTemplateInsertions( $existing ) ); - } - # Category links $existing = $this->getExistingCategories(); @@ -378,53 +367,11 @@ class LinksUpdate { if ( $where ) { $this->mDb->delete( $table, $where, __METHOD__ ); } - if ( isset( $insertions['globaltemplatelinks'] ) ) { - $this->mDb->insert( 'globaltemplatelinks', $insertions['globaltemplatelinks'], __METHOD__, 'IGNORE' ); - unset( $insertions['globaltemplatelinks'] ); - } - if ( isset( $insertions['globalnamespaces'] ) ) { - $this->mDb->insert( 'globalnamespaces', $insertions['globalnamespaces'], __METHOD__, 'IGNORE' ); - unset( $insertions['globalnamespaces'] ); - } - if ( isset( $insertions['globalinterwiki'] ) ) { - $this->mDb->insert( 'globalinterwiki', $insertions['globalinterwiki'], __METHOD__, 'IGNORE' ); - unset( $insertions['globalinterwiki'] ); - } if ( count( $insertions ) ) { $this->mDb->insert( $table, $insertions, __METHOD__, 'IGNORE' ); } } - /** - * Update a shared table by doing a delete query then an insert query - * @private - */ - function incrSharedTableUpdate( $table, $prefix, $deletions, $insertions ) { - global $wgGlobalDatabase; - - if ( $wgGlobalDatabase ) { - $dbw = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase ); - $where = array( "{$prefix}_from_wiki" => wfWikiID(), - "{$prefix}_from_page" => $this->mId - ); - $baseKey = "{$prefix}_to_wiki"; - $middleKey = "{$prefix}_to_namespace"; - - $clause = $dbw->makeWhereFrom3d( $deletions, $baseKey, $middleKey, "{$prefix}_to_title" ); - if ( $clause ) { - $where[] = $clause; - } else { - $where = false; - } - - if ( $where ) { - $dbw->delete( $table, $where, __METHOD__ ); - } - if ( count( $insertions ) ) { - $dbw->insert( $table, $insertions, __METHOD__, 'IGNORE' ); - } - } - } /** * Get an array of pagelinks insertions for passing to the DB @@ -467,44 +414,6 @@ class LinksUpdate { return $arr; } - /** - * Get an array of distant template insertions. Like getLinkInsertions() - * @private - */ - function getDistantTemplateInsertions( $existing = array() ) { - $arr = array(); - foreach( $this->mDistantTemplates as $prefix => $templatesToNS ) { - foreach( $templatesToNS as $ns => $dbkeys ) { - $diffs = isset( $existing[$prefix] ) && isset( $existing[$prefix][$ns] ) - ? array_diff_key( $dbkeys, $existing[$prefix][$ns] ) - : $dbkeys; - $interwiki = Interwiki::fetch( $prefix ); - $wikiid = $interwiki->getWikiID(); - foreach ( $diffs as $dbk => $id ) { - $arr['globaltemplatelinks'][] = array( - 'gtl_from_wiki' => wfWikiID(), - 'gtl_from_page' => $this->mId, - 'gtl_from_namespace' => $this->mTitle->getNamespace(), - 'gtl_from_title' => $this->mTitle->getText(), - 'gtl_to_wiki' => $wikiid, - 'gtl_to_namespace' => $ns, - 'gtl_to_title' => $dbk - ); - $arr['globalinterwiki'][] = array( - 'giw_wikiid' => $wikiid, - 'giw_prefix' => $prefix, - ); - $arr['globalnamespaces'][] = array( - 'gn_wiki' => wfWikiID( ), - 'gn_namespace' => $this->mTitle->getNamespace(), - 'gn_namespacetext' => $this->mTitle->getNsText(), - ); - } - } - } - return $arr; - } - /** * Get an array of image insertions * Skips the names specified in $existing @@ -671,30 +580,6 @@ class LinksUpdate { return $del; } - /** - * Given an array of existing templates, returns those templates which are not in $this - * and thus should be deleted. - * @private - */ - function getDistantTemplateDeletions( $existing ) { - $del = array(); - foreach ( $existing as $wikiid => $templatesForNS ) { - if ( isset( $this->mDistantTemplates[$wikiid] ) ) { - $del[$wikiid] = array_diff_key( $existing[$wikiid], $this->mDistantTemplates[$wikiid] ); - } else { - $del[$wikiid] = $existing[$wikiid]; - } - foreach ( $templatesForNS as $ns => $dbkeys ) { - if ( isset( $this->mDistantTemplates[$wikiid][$ns] ) ) { - $del[$wikiid][$ns] = array_diff_key( $existing[$wikiid][$ns], $this->mDistantTemplates[$wikiid][$ns] ); - } else { - $del[$wikiid][$ns] = $existing[$wikiid][$ns]; - } - } - } - return $del; - } - /** * Given an array of existing images, returns those images which are not in $this * and thus should be deleted. @@ -790,36 +675,6 @@ class LinksUpdate { return $arr; } - /** - * Get an array of existing distant templates, as a 3-D array - * @private - */ - function getDistantExistingTemplates() { - global $wgGlobalDatabase; - - $arr = array(); - if ( $wgGlobalDatabase ) { - $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); - $res = $dbr->select( - 'globaltemplatelinks', - array( 'gtl_to_wiki', 'gtl_to_namespace', 'gtl_to_title' ), - array( 'gtl_from_wiki' => wfWikiID(), 'gtl_from_page' => $this->mId ), - __METHOD__, - $this->mOptions - ); - foreach ( $res as $row ) { - if ( !isset( $arr[$row->gtl_to_wiki] ) ) { - $arr[$row->gtl_to_wiki] = array(); - } - if ( !isset( $arr[$row->gtl_to_wiki][$row->gtl_to_namespace] ) ) { - $arr[$row->gtl_to_wiki][$row->gtl_to_namespace] = array(); - } - $arr[$row->gtl_to_wiki][$row->gtl_to_namespace][$row->gtl_to_title] = 1; - } - } - return $arr; - } - /** * Get an array of existing images, image names in the keys * @private diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6ea70b96b4..118dba33b9 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2061,8 +2061,6 @@ class OutputPage extends ContextSource { * @param $action String: action that was denied or null if unknown */ public function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) { - global $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; - $this->setRobotPolicy( 'noindex,nofollow' ); $this->setArticleRelated( false ); @@ -2110,12 +2108,6 @@ class OutputPage extends ContextSource { $this->addHTML( "
$templates
-" ); - if ( $wgEnableInterwikiTranscluding && $wgEnableInterwikiTemplatesTracking ) { - $distantTemplates = Linker::formatDistantTemplates( $article->getUsedDistantTemplates() ); - $this->addHTML( "
-$distantTemplates -
" ); } } diff --git a/includes/Revision.php b/includes/Revision.php index 243c9c06a0..e3db835f46 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -110,7 +110,8 @@ class Revision { 'minor_edit' => $row->ar_minor_edit, 'text_id' => isset( $row->ar_text_id ) ? $row->ar_text_id : null, 'deleted' => $row->ar_deleted, - 'len' => $row->ar_len); + 'len' => $row->ar_len + ); if ( isset( $row->ar_text ) && !$row->ar_text_id ) { // Pre-1.5 ar_text row $attribs['text'] = self::getRevisionText( $row, 'ar_' ); @@ -165,30 +166,6 @@ class Revision { return Revision::loadFromConds( $db, $conds ); } - /** - * Stores the origin wiki of a revision in case it is a foreign wiki - */ - function setWikiID( $wikiID ) { - $this->mWikiID = $wikiID; - } - - /** - * Load the current revision of a given page of a foreign wiki. - * The WikiID is stored for further use, such as loadText() and getTimestampFromId() - */ - public static function loadFromTitleForeignWiki( $wikiID, $title ) { - $dbr = wfGetDB( DB_SLAVE, array(), $wikiID ); - - $revision = self::loadFromTitle( $dbr, $title ); - - if( $revision ) { - $revision->setWikiID( $wikiID ); - } - - return $revision; - - } - /** * Load either the current, or a specified, revision * that's attached to a given page. If not attached @@ -426,7 +403,6 @@ class Revision { throw new MWException( 'Revision constructor passed invalid row format.' ); } $this->mUnpatrolled = null; - $this->mWikiID = false; } /** @@ -474,8 +450,7 @@ class Revision { if( isset( $this->mTitle ) ) { return $this->mTitle; } - $dbr = wfGetDB( DB_SLAVE, array(), $this->mWikiID ); - + $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( array( 'page', 'revision' ), array( 'page_namespace', 'page_title' ), @@ -614,7 +589,7 @@ class Revision { if( $this->mUnpatrolled !== null ) { return $this->mUnpatrolled; } - $dbr = wfGetDB( DB_SLAVE, array(), $this->mWikiID ); + $dbr = wfGetDB( DB_SLAVE ); $this->mUnpatrolled = $dbr->selectField( 'recentchanges', 'rc_id', array( // Add redundant user,timestamp condition so we can use the existing index @@ -950,11 +925,7 @@ class Revision { // Caching may be beneficial for massive use of external storage global $wgRevisionCacheExpiry, $wgMemc; $textId = $this->getTextId(); - if( isset( $this->mWikiID ) && $this->mWikiID !== false ) { - $key = wfForeignMemcKey( $this->mWikiID, null, 'revisiontext', 'textid', $textId ); - } else { $key = wfMemcKey( 'revisiontext', 'textid', $textId ); - } if( $wgRevisionCacheExpiry ) { $text = $wgMemc->get( $key ); if( is_string( $text ) ) { @@ -974,7 +945,7 @@ class Revision { if( !$row ) { // Text data is immutable; check slaves first. - $dbr = wfGetDB( DB_SLAVE, array(), $this->mWikiID ); + $dbr = wfGetDB( DB_SLAVE ); $row = $dbr->selectRow( 'text', array( 'old_text', 'old_flags' ), array( 'old_id' => $this->getTextId() ), @@ -983,7 +954,7 @@ class Revision { if( !$row && wfGetLB()->getServerCount() > 1 ) { // Possible slave lag! - $dbw = wfGetDB( DB_MASTER, array(), $this->mWikiID ); + $dbw = wfGetDB( DB_MASTER ); $row = $dbw->selectRow( 'text', array( 'old_text', 'old_flags' ), array( 'old_id' => $this->getTextId() ), @@ -1094,8 +1065,7 @@ class Revision { * @return String */ static function getTimestampFromId( $title, $id ) { - $wikiId = wfWikiID(); - $dbr = wfGetDB( DB_SLAVE, array(), $wikiId ); + $dbr = wfGetDB( DB_SLAVE ); // Casting fix for DB2 if ( $id == '' ) { $id = 0; @@ -1105,7 +1075,7 @@ class Revision { $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ ); if ( $timestamp === false && wfGetLB()->getServerCount() > 1 ) { # Not in slave, try master - $dbw = wfGetDB( DB_MASTER, array(), $wikiId ); + $dbw = wfGetDB( DB_MASTER ); $timestamp = $dbw->selectField( 'revision', 'rev_timestamp', $conds, __METHOD__ ); } return wfTimestamp( TS_MW, $timestamp ); diff --git a/includes/SpecialPageFactory.php b/includes/SpecialPageFactory.php index 290f115b7b..eb19200f07 100644 --- a/includes/SpecialPageFactory.php +++ b/includes/SpecialPageFactory.php @@ -126,8 +126,6 @@ class SpecialPageFactory { // Page tools 'ComparePages' => 'SpecialComparePages', 'Export' => 'SpecialExport', - 'GlobalFileUsage' => 'SpecialGlobalFileUsage', - 'GlobalTemplateUsage' => 'SpecialGlobalTemplateUsage', 'Import' => 'SpecialImport', 'Undelete' => 'SpecialUndelete', 'Whatlinkshere' => 'SpecialWhatlinkshere', @@ -264,7 +262,7 @@ class SpecialPageFactory { /** * Add a page to a certain display group for Special:SpecialPages * - * @param $page SpecialPage|string + * @param $page Mixed: SpecialPage or string * @param $group String */ public static function setGroup( $page, $group ) { @@ -277,8 +275,6 @@ class SpecialPageFactory { * Get the group that the special page belongs in on Special:SpecialPage * * @param $page SpecialPage - * - * @return string */ public static function getGroup( &$page ) { $name = $page->getName(); diff --git a/includes/Title.php b/includes/Title.php index 1c98275416..41488ad2db 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -47,7 +47,6 @@ class Title { */ const GAID_FOR_UPDATE = 1; - /** * @name Private member variables * Please use the accessor functions instead. @@ -766,19 +765,6 @@ class Title { } /** - * Return the prefixed title with spaces _without_ the interwiki prefix - * - * @return \type{\string} the title, prefixed by the namespace but not by the interwiki prefix, with spaces - */ - public function getSemiPrefixedText() { - if ( !isset( $this->mSemiPrefixedText ) ){ - $s = ( $this->mNamespace === NS_MAIN ? '' : $this->getNsText() . ':' ) . $this->mTextform; - $s = str_replace( '_', ' ', $s ); - $this->mSemiPrefixedText = $s; - } - return $this->mSemiPrefixedText; - } - /** * Get the prefixed title with spaces, plus any fragment * (part beginning with '#') @@ -857,6 +843,8 @@ class Title { * @return String the URL */ public function getFullURL( $query = '', $variant = false ) { + global $wgServer, $wgRequest; + # Hand off all the decisions on urls to getLocalURL $url = $this->getLocalURL( $query, $variant ); @@ -1029,12 +1017,8 @@ class Title { * @return String the URL */ public function getInternalURL( $query = '', $variant = false ) { - if ( $this->isExternal( ) ) { - $server = ''; - } else { - global $wgInternalServer, $wgServer; - $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer; - } + global $wgInternalServer, $wgServer; + $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer; $url = wfExpandUrl( $server . $this->getLocalURL( $query, $variant ), PROTO_HTTP ); wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query, $variant ) ); return $url; @@ -2853,10 +2837,6 @@ class Title { $this->mFragment = str_replace( '_', ' ', substr( $fragment, 1 ) ); } - public function setInterwiki( $interwiki ) { - $this->mInterwiki = $interwiki; - } - /** * Get a Title object associated with the talk page of this article * @@ -3168,8 +3148,6 @@ class Title { * @return Mixed true on success, getUserPermissionsErrors()-like array on failure */ public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) { - global $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; - $err = $this->isValidMoveOperation( $nt, $auth, $reason ); if ( is_array( $err ) ) { return $err; @@ -3197,7 +3175,7 @@ class Title { $pageCountChange = ( $createRedirect ? 1 : 0 ) - ( $nt->exists() ? 1 : 0 ); // Do the actual move - $err = $this->moveOverExistingRedirect( $nt, $reason, $createRedirect ); + $err = $this->moveToInternal( $nt, $reason, $createRedirect ); if ( is_array( $err ) ) { # @todo FIXME: What about the File we have already moved? $dbw->rollback(); @@ -3229,15 +3207,6 @@ class Title { ); } - if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) { - $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase ); - $dbw2->update( 'globaltemplatelinks', - array( 'gtl_from_namespace' => $nt->getNamespace(), - 'gtl_from_title' => $nt->getText() ), - array ( 'gtl_from_page' => $pageid ), - __METHOD__ ); - } - if ( $protected ) { # Protect the redirect title as the title used to be... $dbw->insertSelect( 'page_restrictions', 'page_restrictions', @@ -3331,8 +3300,8 @@ class Title { * @param $createRedirect Bool Whether to leave a redirect at the old title. Ignored * if the user doesn't have the suppressredirect right */ - private function moveOverExistingRedirect( &$nt, $reason = '', $createRedirect = true ) { - global $wgUser, $wgContLang, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase; + private function moveToInternal( &$nt, $reason = '', $createRedirect = true ) { + global $wgUser, $wgContLang; if ( $nt->exists() ) { $moveOverRedirect = true; @@ -3399,14 +3368,7 @@ class Title { array( 'rc_timestamp' => $rcts, 'rc_namespace' => $newns, 'rc_title' => $newdbk, 'rc_new' => 1 ), __METHOD__ ); - - if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) { - $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase ); - $dbw2->delete( 'globaltemplatelinks', - array( 'gtl_from_wiki' => wfGetID(), - 'gtl_from_page' => $newid ), __METHOD__ ); - } } # Save a null revision in the page's history notifying of the move @@ -4406,4 +4368,4 @@ class Title { wfRunHooks( 'PageContentLanguage', array( $this, &$pageLang, $wgLang ) ); return wfGetLangObj( $pageLang ); } -} +} \ No newline at end of file diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 1c869484f5..d53b5e45f9 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1600,7 +1600,7 @@ class WikiPage extends Page { public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null ) { - global $wgUseTrackbacks, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase, $wgUser; + global $wgDeferredUpdateList, $wgUseTrackbacks, $wgUser; $user = is_null( $user ) ? $wgUser : $user; wfDebug( __METHOD__ . "\n" ); @@ -1706,13 +1706,6 @@ class WikiPage extends Page { $dbw->delete( 'iwlinks', array( 'iwl_from' => $id ), __METHOD__ ); $dbw->delete( 'redirect', array( 'rd_from' => $id ), __METHOD__ ); $dbw->delete( 'page_props', array( 'pp_page' => $id ), __METHOD__ ); - - if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) { - $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase ); - $dbw2->delete( 'globaltemplatelinks', - array( 'gtl_from_wiki' => wfGetID(), - 'gtl_from_page' => $id ) - ); } } @@ -2234,9 +2227,7 @@ class WikiPage extends Page { $title->touchLinks(); $title->purgeSquid(); $title->deleteTitleProtection(); - - # Invalidate caches of distant articles which transclude this page - DeferredUpdates::addHTMLCacheUpdate( $title, 'globaltemplatelinks' ); + $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' ); } /** @@ -2280,9 +2271,7 @@ class WikiPage extends Page { # Image redirects RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $title ); - - # Invalidate caches of distant articles which transclude this page - DeferredUpdates::addHTMLCacheUpdate( $title, 'globaltemplatelinks' ); + $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' ); } /** @@ -2295,8 +2284,6 @@ class WikiPage extends Page { // Invalidate caches of articles which include this page DeferredUpdates::addHTMLCacheUpdate( $title, 'templatelinks' ); - // Invalidate caches of distant articles which transclude this page - DeferredUpdates::addHTMLCacheUpdate( $title, 'globaltemplatelinks' ); // Invalidate the caches of all pages which redirect here DeferredUpdates::addHTMLCacheUpdate( $title, 'redirect' ); @@ -2339,40 +2326,6 @@ class WikiPage extends Page { return $result; } - /** - * Return a list of distant templates used by this article. - * Uses the globaltemplatelinks table - * - * @return Array of Title objects - */ - public function getUsedDistantTemplates() { - global $wgGlobalDatabase; - - $result = array(); - - if ( $wgGlobalDatabase ) { - $id = $this->mTitle->getArticleID(); - - if ( $id == 0 ) { - return array(); - } - - $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); - $res = $dbr->select( 'globaltemplatelinks', - array( 'gtl_to_prefix', 'gtl_to_namespace', 'gtl_to_title' ), - array( 'gtl_from_wiki' => wfWikiID( ), 'gtl_from_page' => $id ), - __METHOD__ ); - - if ( $res !== false ) { - foreach ( $res as $row ) { - $result[] = Title::makeTitle( $row->gtl_to_namespace, $row->gtl_to_title, null, $row->gtl_to_prefix ); - } - } - } - - return $result; - } - /** * Returns a list of hidden categories this page is a member of. * Uses the page_props and categorylinks tables. diff --git a/includes/cache/HTMLCacheUpdate.php b/includes/cache/HTMLCacheUpdate.php index 91a0930ff0..1c3c3a1cd8 100644 --- a/includes/cache/HTMLCacheUpdate.php +++ b/includes/cache/HTMLCacheUpdate.php @@ -50,15 +50,6 @@ class HTMLCacheUpdate implements DeferrableUpdate { return; } - if ( $this->mTable === 'globaltemplatelinks' ) { - global $wgEnableInterwikiTemplatesTracking; - - if ( $wgEnableInterwikiTemplatesTracking ) { - $distantPageArray = $this->mCache->getDistantTemplateLinks( 'globaltemplatelinks' ); - $this->invalidateDistantTitles( $distantPageArray ); - } - return; - } # Get an estimate of the number of rows from the BacklinkCache $numRows = $this->mCache->getNumLinks( $this->mTable ); @@ -77,7 +68,6 @@ class HTMLCacheUpdate implements DeferrableUpdate { $this->invalidateTitles( $titleArray ); } } - wfRunHooks( 'HTMLCacheUpdate::doUpdate', array($this->mTitle) ); } /** @@ -208,45 +198,9 @@ class HTMLCacheUpdate implements DeferrableUpdate { } } - /** - * Invalidate an array of distant pages, given the wiki ID and page ID of those pages - */ - protected function invalidateDistantTitles( $distantPageArray ) { - global $wgUseSquid; - - $pagesByWiki = array(); - $titleArray = array(); - # Sort by WikiID in $pagesByWiki - # Create the distant titles for Squid in $titleArray - foreach ( $distantPageArray as $row ) { - $wikiid = $row->gtl_from_wiki; - if( !isset( $pagesByWiki[$wikiid] ) ) { $pagesByWiki[$wikiid] = array(); } - $pagesByWiki[$wikiid][] = $row->gtl_from_page; - $titleArray[] = Title::makeTitle( $row->gtl_from_namespace, $row->gtl_from_title, '', $row->gil_interwiki ); - } - foreach ( $pagesByWiki as $wikiid => $pages ) { - $dbw = wfGetDB( DB_MASTER, array( ), $wikiid ); - $timestamp = $dbw->timestamp(); - $batches = array_chunk( $pages, $this->mRowsPerQuery ); - foreach ( $batches as $batch ) { - $dbw->update( 'page', - array( 'page_touched' => $timestamp ), - array( 'page_id IN (' . $dbw->makeList( $batch ) . ')' ), - __METHOD__ - ); - } - } - - # Update squid - if ( $wgUseSquid ) { - $u = SquidUpdate::newFromTitles( $titleArray ); - $u->doUpdate(); - } - } -} /** * Job wrapper for HTMLCacheUpdate. Gets run whenever a related diff --git a/includes/db/Database.php b/includes/db/Database.php index fbba5539b5..cff669074c 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1816,39 +1816,6 @@ abstract class DatabaseBase implements DatabaseType { } } - /** - * Build a partial where clause from a 3-d array - * The keys on each level may be either integers or strings. - * - * @param $data Array: organized as 3-d array(baseKeyVal => array(middleKeyVal => array(subKeyVal => , ...), ...), ...) - * @param $baseKey String: field name to match the base-level keys to (eg 'gtl_to_prefix') - * @param $middleKey String: field name to match the middle-level keys to (eg 'gtl_to_namespace') - * @param $subKey String: field name to match the sub-level keys to (eg 'gtl_to_title') - * @return Mixed: string SQL fragment, or false if no items in array. - */ - function makeWhereFrom3d( $data, $baseKey, $middleKey, $subKey ) { - $conds = array(); - foreach ( $data as $base => $subdata ) { - foreach ( $subdata as $middle => $sub ) { - if ( count( $sub ) ) { - $conds[] = $this->makeList( - array( $baseKey => $base, - $middleKey => $middle, - $subKey => array_keys( $sub ) ), - LIST_AND - ); - } - } - } - - if ( $conds ) { - return $this->makeList( $conds, LIST_OR ); - } else { - // Nothing to search for... - return false; - } - } - /** * Bitwise operations */ diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 80d9a0084b..cd6de36468 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -185,9 +185,6 @@ class MysqlUpdater extends DatabaseUpdater { // 1.19 array( 'addTable', 'config', 'patch-config.sql' ), array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'), - array( 'addTable', 'globaltemplatelinks', 'patch-globaltemplatelinks.sql' ), - array( 'addTable', 'globalnamespaces', 'patch-globalnamespaces.sql' ), - array( 'addTable', 'globalinterwiki', 'patch-globalinterwiki.sql' ), array( 'doMigrateUserOptions' ), array( 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ), diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index d43e40906c..b922ec76ce 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -63,8 +63,6 @@ class SqliteUpdater extends DatabaseUpdater { // 1.19 array( 'addTable', 'config', 'patch-config.sql' ), array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'), - array( 'addTable', 'globaltemplatelinks', 'patch-globaltemplatelinks.sql' ), - array( 'addTable', 'globalnamespaces', 'patch-globalnamespaces.sql' ), array( 'addTable', 'globalinterwiki', 'patch-globalinterwiki.sql' ), array( 'doMigrateUserOptions' ), ); diff --git a/includes/interwiki/Interwiki.php b/includes/interwiki/Interwiki.php index fa7e6818f1..e6469a1b09 100644 --- a/includes/interwiki/Interwiki.php +++ b/includes/interwiki/Interwiki.php @@ -9,7 +9,6 @@ * All information is loaded on creation when called by Interwiki::fetch( $prefix ). * All work is done on slave, because this should *never* change (except during * schema updates etc, which aren't wiki-related) - * This class also contains the functions that allow interwiki templates transclusion. */ class Interwiki { @@ -172,7 +171,6 @@ class Interwiki { $mc = array( 'iw_url' => $iw->mURL, 'iw_api' => $iw->mAPI, - 'iw_wikiid' => $iw->mWikiID, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans ); @@ -197,7 +195,6 @@ class Interwiki { $iw->mURL = $mc['iw_url']; $iw->mLocal = isset( $mc['iw_local'] ) ? $mc['iw_local'] : 0; $iw->mTrans = isset( $mc['iw_trans'] ) ? $mc['iw_trans'] : 0; - $iw->mAPI = isset( $mc['iw_api'] ) ? $mc['iw_api'] : $iw->mAPI = isset( $mc['iw_api'] ) ? $mc['iw_api'] : ''; $iw->mWikiID = isset( $mc['iw_wikiid'] ) ? $mc['iw_wikiid'] : ''; @@ -392,166 +389,4 @@ class Interwiki { $msg = wfMessage( 'interwiki-desc-' . $this->mPrefix )->inContentLanguage(); return !$msg->exists() ? '' : $msg; } - - - /** - * Transclude an interwiki link. - */ - public static function interwikiTransclude( $title ) { - - // If we have a wikiID, we will use it to get an access to the remote database - // if not, we will use the API URL to retrieve the data through a HTTP Get - - $wikiID = $title->getTransWikiID( ); - $transAPI = $title->getTransAPI( ); - - if ( $wikiID !== '') { - - $finalText = self::fetchTemplateFromDB( $wikiID, $title ); - return $finalText; - - } else if( $transAPI !== '' ) { - - $interwiki = $title->getInterwiki( ); - $fullTitle = $title->getSemiPrefixedText( ); - - $finalText = self::fetchTemplateFromAPI( $interwiki, $transAPI, $fullTitle ); - - return $finalText; - -} - return false; - } - - /** - * Retrieve the wikitext of a distant page accessing the foreign DB - */ - public static function fetchTemplateFromDB ( $wikiID, $title ) { - - $revision = Revision::loadFromTitleForeignWiki( $wikiID, $title ); - - if ( $revision ) { - $text = $revision->getText(); - return $text; - } - - return false; - } - - /** - * Retrieve the wikitext of a distant page using the API of the foreign wiki - */ - public static function fetchTemplateFromAPI( $interwiki, $transAPI, $fullTitle ) { - global $wgMemc, $wgTranscludeCacheExpiry; - - $key = wfMemcKey( 'iwtransclustiontext', 'textid', $interwiki, $fullTitle ); - $text = $wgMemc->get( $key ); - if( is_array ( $text ) && - isset ( $text['missing'] ) && - $text['missing'] === true ) { - return false; - } else if ( $text ) { - return $text; - } - - $url = wfAppendQuery( - $transAPI, - array( 'action' => 'query', - 'titles' => $fullTitle, - 'prop' => 'revisions', - 'rvprop' => 'content', - 'format' => 'json' - ) - ); - - $get = Http::get( $url ); - $content = FormatJson::decode( $get, true ); - - if ( isset ( $content['query'] ) && - isset ( $content['query']['pages'] ) ) { - $page = array_pop( $content['query']['pages'] ); - if ( $page && isset( $page['revisions'][0]['*'] ) ) { - $text = $page['revisions'][0]['*']; - $wgMemc->set( $key, $text, $wgTranscludeCacheExpiry ); - - // When we cache a template, we also retrieve and cache its subtemplates - $subtemplates = self::getSubtemplatesListFromAPI( $interwiki, $transAPI, $fullTitle ); - self::cacheTemplatesFromAPI( $interwiki, $transAPI, $subtemplates ); - - return $text; - } else { - $wgMemc->set( $key, array ( 'missing' => true ), $wgTranscludeCacheExpiry ); - } - } - return false; - } - - public static function getSubtemplatesListFromAPI ( $interwiki, $transAPI, $title ) { - $url = wfAppendQuery( $transAPI, - array( 'action' => 'query', - 'titles' => $title, - 'prop' => 'templates', - 'format' => 'json' - ) - ); - - $get = Http::get( $url ); - $myArray = FormatJson::decode($get, true); - - $templates = array( ); - if ( ! empty( $myArray['query'] )) { - if ( ! empty( $myArray['query']['pages'] )) { - $templates = array_pop( $myArray['query']['pages'] ); - if ( ! empty( $templates['templates'] )) { - $templates = $templates['templates']; - } - } - return $templates; - } - } - - public static function cacheTemplatesFromAPI( $interwiki, $transAPI, $titles ){ - global $wgMemc, $wgTranscludeCacheExpiry; - - $outdatedTitles = array( ); - - foreach( $titles as $title ){ - if ( isset ( $title['title'] ) ) { - $key = wfMemcKey( 'iwtransclustiontext', 'textid', $interwiki, $title['title'] ); - $text = $wgMemc->get( $key ); - if( !$text ){ - $outdatedTitles[] = $title['title']; - } - } - } - - $batches = array_chunk( $outdatedTitles, 50 ); - - foreach( $batches as $batch ){ - $url = wfAppendQuery( - $transAPI, - array( 'action' => 'query', - 'titles' => implode( '|', $batch ), - 'prop' => 'revisions', - 'rvprop' => 'content', - 'format' => 'json' - ) - ); - $get = Http::get( $url ); - $content = FormatJson::decode( $get, true ); - - if ( isset ( $content['query'] ) && - isset ( $content['query']['pages'] ) ) { - foreach( $content['query']['pages'] as $page ) { - $key = wfMemcKey( 'iwtransclustiontext', 'textid', $interwiki, $page['title'] ); - if ( isset ( $page['revisions'][0]['*'] ) ) { - $text = $page['revisions'][0]['*']; - } else { - $text = array ( 'missing' => true ); - } - $wgMemc->set( $key, $text, $wgTranscludeCacheExpiry ); - } - } - } - } } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index eef496cf14..b5aabb5b3a 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3022,7 +3022,7 @@ class Parser { * @private */ function braceSubstitution( $piece, $frame ) { - global $wgNonincludableNamespaces, $wgEnableInterwikiTranscluding, $wgEnableInterwikiTemplatesTracking; + global $wgContLang, $wgNonincludableNamespaces; wfProfileIn( __METHOD__ ); wfProfileIn( __METHOD__.'-setup' ); @@ -3030,6 +3030,7 @@ class Parser { $found = false; # $text has been filled $nowiki = false; # wiki markup in $text should be escaped $isHTML = false; # $text is HTML, armour it against wikitext transformation + $forceRawInterwiki = false; # Force interwiki transclusion to be done in raw mode not rendered $isChildObj = false; # $text is a DOM node needing expansion in a child frame $isLocalObj = false; # $text is a DOM node needing expansion in the current frame @@ -3194,9 +3195,6 @@ class Parser { } $title = Title::newFromText( $part1, $ns ); if ( $title ) { - if ( !$title->isExternal() && $piece['interwiki'] !== '' ) { - $title->setInterwiki( $piece['interwiki'] ); - } $titleText = $title->getPrefixedText(); # Check for language variants if the template is not found if ( $this->getFunctionLang()->hasVariants() && $title->getArticleID() == 0 ) { @@ -3264,22 +3262,18 @@ class Parser { $text = "[[:$titleText]]"; $found = true; } - } elseif ( $wgEnableInterwikiTranscluding && $title->isTrans() ) { - - $text = Interwiki::interwikiTransclude( $title ); - $this->registerDistantTemplate( $title ); - - if ( $wgEnableInterwikiTemplatesTracking ) { - $this->registerDistantTemplate( $title ); - } - - if ( $text !== false ) { + } elseif ( $title->isTrans() ) { + # Interwiki transclusion + if ( $this->ot['html'] && !$forceRawInterwiki ) { + $text = $this->interwikiTransclude( $title, 'render' ); + $isHTML = true; + } else { + $text = $this->interwikiTransclude( $title, 'raw' ); # Preprocess it like a template $text = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION ); - $found = true; $isChildObj = true; } - + $found = true; } # Do infinite loop check @@ -3429,19 +3423,10 @@ class Parser { } /** - * Register a distant template as used + * Fetch the unparsed text of a template and register a reference to it. + * @param Title $title + * @return mixed string or false */ - function registerDistantTemplate( $title ) { - $stuff = Parser::distantTemplateCallback( $title, $this ); - $text = $stuff['text']; - $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title; - if ( isset( $stuff['deps'] ) ) { - foreach ( $stuff['deps'] as $dep ) { - $this->mOutput->addDistantTemplate( $dep['title'], $dep['page_id'], $dep['rev_id'] ); - } - } - } - function fetchTemplate( $title ) { $rv = $this->fetchTemplateAndTitle( $title ); return $rv[0]; @@ -3570,22 +3555,57 @@ class Parser { return array( $file, $title ); } - static function distantTemplateCallback( $title, $parser=false ) { - $text = ''; - $rev_id = null; - $deps[] = array( - 'title' => $title, - 'page_id' => $title->getArticleID(), - 'rev_id' => $rev_id ); + /** + * Transclude an interwiki link. + * + * @param $title Title + * @param $action + * + * @return string + */ + function interwikiTransclude( $title, $action ) { + global $wgEnableScaryTranscluding; + + if ( !$wgEnableScaryTranscluding ) { + return wfMsgForContent('scarytranscludedisabled'); + } - $finalTitle = $title; + $url = $title->getFullUrl( "action=$action" ); - return array( - 'text' => $text, - 'finalTitle' => $finalTitle, - 'deps' => $deps ); + if ( strlen( $url ) > 255 ) { + return wfMsgForContent( 'scarytranscludetoolong' ); + } + return $this->fetchScaryTemplateMaybeFromCache( $url ); + } + + /** + * @param $url string + * @return Mixed|String + */ + function fetchScaryTemplateMaybeFromCache( $url ) { + global $wgTranscludeCacheExpiry; + $dbr = wfGetDB( DB_SLAVE ); + $tsCond = $dbr->timestamp( time() - $wgTranscludeCacheExpiry ); + $obj = $dbr->selectRow( 'transcache', array('tc_time', 'tc_contents' ), + array( 'tc_url' => $url, "tc_time >= " . $dbr->addQuotes( $tsCond ) ) ); + if ( $obj ) { + return $obj->tc_contents; } + $text = Http::get( $url ); + if ( !$text ) { + return wfMsgForContent( 'scarytranscludefailed', $url ); + } + + $dbw = wfGetDB( DB_MASTER ); + $dbw->replace( 'transcache', array('tc_url'), array( + 'tc_url' => $url, + 'tc_time' => $dbw->timestamp( time() ), + 'tc_contents' => $text) + ); + return $text; + } + /** * Triple brace replacement -- used for template arguments * @private diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index eefefac736..3e5a3f28f5 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -121,8 +121,6 @@ class ParserOutput extends CacheTime { $mLinks = array(), # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken. $mTemplates = array(), # 2-D map of NS/DBK to ID for the template references. ID=zero for broken. $mTemplateIds = array(), # 2-D map of NS/DBK to rev ID for the template references. ID=zero for broken. - $mDistantTemplates = array(), # 3-D map of WIKIID/NS/DBK to ID for the template references. ID=zero for broken. - $mDistantTemplateIds = array(), # 3-D map of WIKIID/NS/DBK to rev ID for the template references. ID=zero for broken. $mImages = array(), # DB keys of the images used, in the array key only $mFileSearchOptions = array(), # DB keys of the images used mapped to sha1 and MW timestamp $mExternalLinks = array(), # External link URLs, in the key only @@ -193,8 +191,6 @@ class ParserOutput extends CacheTime { function getEditSectionTokens() { return $this->mEditSectionTokens; } function &getLinks() { return $this->mLinks; } function &getTemplates() { return $this->mTemplates; } - function &getDistantTemplates() { return $this->mDistantTemplates; } - function &getDistantTemplateIds() { return $this->mDistantTemplateIds; } function &getTemplateIds() { return $this->mTemplateIds; } function &getImages() { return $this->mImages; } function &getFileSearchOptions() { return $this->mFileSearchOptions; } @@ -316,31 +312,6 @@ class ParserOutput extends CacheTime { $this->mTemplateIds[$ns][$dbk] = $rev_id; // For versioning } - function addDistantTemplate( $title, $page_id, $rev_id ) { - $prefix = $title->getInterwiki(); - if ( $prefix !=='' ) { - $ns = $title->getNamespace(); - $dbk = $title->getDBkey(); - - if ( !isset( $this->mDistantTemplates[$prefix] ) ) { - $this->mDistantTemplates[$prefix] = array(); - } - if ( !isset( $this->mDistantTemplates[$prefix][$ns] ) ) { - $this->mDistantTemplates[$prefix][$ns] = array(); - } - $this->mDistantTemplates[$prefix][$ns][$dbk] = $page_id; - - // For versioning - if ( !isset( $this->mDistantTemplateIds[$prefix] ) ) { - $this->mDistantTemplateIds[$prefix] = array(); - } - if ( !isset( $this->mDistantTemplateIds[$prefix][$ns] ) ) { - $this->mDistantTemplateIds[$prefix][$ns] = array(); - } - $this->mDistantTemplateIds[$prefix][$ns][$dbk] = $rev_id; - } - } - /** * @param $title Title object, must be an interwiki link * @throws MWException if given invalid input diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 128b36a339..9f92b18c21 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -1039,8 +1039,7 @@ class PPFrame_DOM implements PPFrame { $params = array( 'title' => new PPNode_DOM( $title ), 'parts' => new PPNode_DOM( $parts ), - 'lineStart' => $lineStart, - 'interwiki' => $this->title->getInterwiki( ) ); + 'lineStart' => $lineStart ); $ret = $this->parser->braceSubstitution( $params, $this ); if ( isset( $ret['object'] ) ) { $newIterator = $ret['object']; diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 509f2d5070..df1c2975e3 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -976,7 +976,6 @@ class PPFrame_Hash implements PPFrame { if ( $flags & PPFrame::NO_TEMPLATES ) { $newIterator = $this->virtualBracketedImplode( '{{', '|', '}}', $bits['title'], $bits['parts'] ); } else { - $bits['interwiki'] = $this->title->getInterwiki( ); $ret = $this->parser->braceSubstitution( $bits, $this ); if ( isset( $ret['object'] ) ) { $newIterator = $ret['object']; diff --git a/includes/specials/SpecialGlobalFileUsage.php b/includes/specials/SpecialGlobalFileUsage.php deleted file mode 100644 index 97aa4413f1..0000000000 --- a/includes/specials/SpecialGlobalFileUsage.php +++ /dev/null @@ -1,213 +0,0 @@ -getRequest(); - $target = $par ? $par : $request->getVal( 'target' ); - $this->target = Title::makeTitleSafe( NS_FILE, $target ); - - $this->filterLocal = $request->getCheck( 'filterlocal' ); - - $this->setHeaders(); - - $this->showForm(); - - if ( !is_null( $this->target ) ) { - $this->getOutput()->setPageTitle( wfMsg( 'globalfileusage-for', $this->target->getPrefixedText() ) ); - $this->showResult(); - } - } - - /** - * Shows the search form - */ - private function showForm() { - global $wgScript, $wgContLang; - - /* Build form */ - $html = Xml::openElement( 'form', array( 'action' => $wgScript ) ) . "\n"; - // Name of SpecialPage - $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; - // Limit - $html .= Html::hidden( 'limit', $this->getRequest()->getInt( 'limit', 50 ) ); - // Input box with target prefilled if available - $formContent = "\t" . Xml::input( 'target', 40, is_null( $this->target ) ? '' - : $this->target->getText() ) - // Submit button - . "\n\t" . Xml::element( 'input', array( - 'type' => 'submit', - 'value' => wfMsg( 'globalfileusage-ok' ) - ) ) - // Filter local checkbox - . "\n\t

" . Xml::checkLabel( wfMsg( 'globalfileusage-filterlocal' ), - 'filterlocal', 'mw-filterlocal', $this->filterLocal ) . '

'; - - if ( !is_null( $this->target ) ) { - $file = wfFindFile( $this->target ); - if ( $file !== null ) { - // Show the image if it exists - $html .= Linker::makeImageLink2( $this->target, $file, - array( 'align' => $this->getLang()->alignEnd(), 'thumbnail' => true ) ); - } - } - - // Wrap the entire form in a nice fieldset - $html .= Xml::fieldSet( wfMsg( 'globalfileusage-text' ), $formContent ) . "\n"; - - $this->getOutput()->addHtml( $html ); - } - - /** - * Creates as queryer and executes it based on the WebRequest object - */ - private function showResult() { - $request = $this->getRequest(); - $query = new GlobalUsageQuery( $this->target ); - - // Extract params from the WebRequest object - if ( $request->getText( 'from' ) ) { - $query->setOffset( $request->getText( 'from' ) ); - } elseif ( $request->getText( 'to' ) ) { - $query->setOffset( $request->getText( 'to' ), true ); - } - $query->setLimit( $request->getInt( 'limit', 50 ) ); - $query->filterLocal( $this->filterLocal ); - - // Perform query - $query->searchFile(); - - // Show result - $out = $this->getOutput(); - - // Don't show form element if there is no data - if ( $query->count() == 0 ) { - $out->addWikiMsg( 'globalfileusage-no-results', $this->target->getPrefixedText() ); - return; - } - - $offset = $query->getOffsetString(); - $navbar = $this->getNavBar( $query ); - $targetName = $this->target->getText(); - - // Top navbar - $out->addHtml( $navbar ); - - $out->addHtml( '
' ); - foreach ( $query->getSingleResult() as $wiki => $result ) { - $out->addHtml( - '

' . wfMsgExt( - 'globalfileusage-on-wiki', 'parseinline', - $targetName, WikiMap::getWikiName( $wiki ) ) - . "

    \n" ); - foreach ( $result as $item ) { - $out->addHtml( "\t
  • " . self::formatItem( $item ) . "
  • \n" ); - } - $out->addHtml( "
\n" ); - } - $out->addHtml( '
' ); - - // Bottom navbar - $out->addHtml( $navbar ); - } - - /** - * Helper to format a specific item - */ - public static function formatItem( $item ) { - if ( !$item['namespace'] ) { - $page = $item['title']; - } else { - $page = "{$item['namespace']}:{$item['title']}"; - } - - $link = WikiMap::makeForeignLink( $item['wiki'], $page, - str_replace( '_', ' ', $page ) ); - // Return only the title if no link can be constructed - return $link === false ? $page : $link; - } - - /** - * Helper function to create the navbar, stolen from wfViewPrevNext - * - * @param $query GlobalUsageQuery An executed GlobalUsageQuery object - * @return string Navbar HTML - */ - protected function getNavBar( $query ) { - $lang = $this->getLang(); - $target = $this->target->getText(); - $limit = $query->getLimit(); - $fmtLimit = $lang->formatNum( $limit ); - - # Find out which strings are for the prev and which for the next links - $offset = $query->getOffsetString(); - $continue = $query->getContinueFileString(); - if ( $query->isReversed() ) { - $from = $offset; - $to = $continue; - } else { - $from = $continue; - $to = $offset; - } - - # Get prev/next link display text - $prev = wfMsgExt( 'prevn', array( 'parsemag', 'escape' ), $fmtLimit ); - $next = wfMsgExt( 'nextn', array( 'parsemag', 'escape' ), $fmtLimit ); - # Get prev/next link title text - $pTitle = wfMsgExt( 'prevn-title', array( 'parsemag', 'escape' ), $fmtLimit ); - $nTitle = wfMsgExt( 'nextn-title', array( 'parsemag', 'escape' ), $fmtLimit ); - - # Fetch the title object - $title = $this->getTitle(); - - # Make 'previous' link - if ( $to ) { - $attr = array( 'title' => $pTitle, 'class' => 'mw-prevlink' ); - $q = array( 'limit' => $limit, 'to' => $to, 'target' => $target ); - if ( $this->filterLocal ) - $q['filterlocal'] = '1'; - $plink = Linker::link( $title, $prev, $attr, $q ); - } else { - $plink = $prev; - } - - # Make 'next' link - if ( $from ) { - $attr = array( 'title' => $nTitle, 'class' => 'mw-nextlink' ); - $q = array( 'limit' => $limit, 'from' => $from, 'target' => $target ); - if ( $this->filterLocal ) - $q['filterlocal'] = '1'; - $nlink = Linker::link( $title, $next, $attr, $q ); - } else { - $nlink = $next; - } - - # Make links to set number of items per page - $numLinks = array(); - foreach ( array( 20, 50, 100, 250, 500 ) as $num ) { - $fmtLimit = $lang->formatNum( $num ); - - $q = array( 'offset' => $offset, 'limit' => $num, 'target' => $target ); - if ( $this->filterLocal ) - $q['filterlocal'] = '1'; - $lTitle = wfMsgExt( 'shown-title', array( 'parsemag', 'escape' ), $num ); - $attr = array( 'title' => $lTitle, 'class' => 'mw-numlink' ); - - $numLinks[] = Linker::link( $title, $fmtLimit, $attr, $q ); - } - $nums = $lang->pipeList( $numLinks ); - - return wfMsgHtml( 'viewprevnext', $plink, $nlink, $nums ); - } -} - diff --git a/includes/specials/SpecialGlobalTemplateUsage.php b/includes/specials/SpecialGlobalTemplateUsage.php deleted file mode 100644 index 5cecc0ee3c..0000000000 --- a/includes/specials/SpecialGlobalTemplateUsage.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @author Peter Potrowl - */ - -class SpecialGlobalTemplateUsage extends SpecialPage { - public function __construct() { - parent::__construct( 'GlobalTemplateUsage' ); - } - - /** - * Entry point - */ - public function execute( $par ) { - $target = $par ? $par : $this->getRequest()->getVal( 'target' ); - $this->target = Title::newFromText( $target ); - - $this->setHeaders(); - - $this->showForm(); - - if ( $this->target !== null ) { - $this->getOutput()->setPageTitle( wfMsg( 'globaltemplateusage-for', $this->target->getPrefixedText() ) ); - - $this->showResult(); - } - } - - /** - * Shows the search form - */ - private function showForm() { - global $wgScript; - - /* Build form */ - $html = Xml::openElement( 'form', array( 'action' => $wgScript ) ) . "\n"; - // Name of SpecialPage - $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; - // Limit - $html .= Html::hidden( 'limit', $this->getRequest()->getInt( 'limit', 50 ) ); - // Input box with target prefilled if available - $formContent = "\t" . Xml::input( 'target', 40, is_null( $this->target ) ? '' - : $this->target->getPrefixedText( ) ) - // Submit button - . "\n\t" . Xml::element( 'input', array( - 'type' => 'submit', - 'value' => wfMsg( 'globaltemplateusage-ok' ) - ) ); - - // Wrap the entire form in a nice fieldset - $html .= Xml::fieldSet( wfMsg( 'globaltemplateusage-text' ), $formContent ) . "\n"; - - $this->getOutput()->addHtml( $html ); - } - - /** - * Creates as queryer and executes it based on the WebRequest object - */ - private function showResult() { - $request = $this->getRequest(); - $query = new GlobalUsageQuery( $this->target ); - - // Extract params from the WebRequest object - if ( $request->getText( 'from' ) ) { - $query->setOffset( $request->getText( 'from' ) ); - } elseif ( $request->getText( 'to' ) ) { - $query->setOffset( $request->getText( 'to' ), true ); - } - $query->setLimit( $request->getInt( 'limit', 50 ) ); - - // Perform query - $query->searchTemplate(); - - $out = $this->getOutput(); - - // Don't show form element if there is no data - if ( $query->count() == 0 ) { - $out->addWikiMsg( 'globaltemplateusage-no-results', $this->target->getPrefixedText( ) ); - return; - } - - $navbar = $this->getNavBar( $query ); - $targetName = $this->target->getPrefixedText( ); - - // Top navbar - $out->addHtml( $navbar ); - - $out->addHtml( '
' ); - foreach ( $query->getSingleResult() as $wiki => $result ) { - $out->addHtml( - '

' . wfMsgExt( - 'globaltemplateusage-on-wiki', 'parseinline', - $targetName, WikiMap::getWikiName( $wiki ) ) - . "

    \n" ); - foreach ( $result as $item ) { - $out->addHtml( "\t
  • " . self::formatItem( $item ) . "
  • \n" ); - } - $out->addHtml( "
\n" ); - } - $out->addHtml( '
' ); - - // Bottom navbar - $out->addHtml( $navbar ); - } - - /** - * Helper to format a specific item - */ - public static function formatItem( $item ) { - if ( !$item['namespace'] ) { - $page = $item['title']; - } else { - $page = "{$item['namespace']}:{$item['title']}"; - } - - $link = WikiMap::makeForeignLink( $item['wiki'], $page, - str_replace( '_', ' ', $page ) ); - // Return only the title if no link can be constructed - return $link === false ? $page : $link; - } - - /** - * Helper function to create the navbar, stolen from wfViewPrevNext - * - * @param $query GlobalTemplateUsageQuery An executed GlobalTemplateUsageQuery object - * @return string Navbar HTML - */ - protected function getNavBar( $query ) { - $lang = $this->getLang(); - $target = $this->target->getPrefixedText(); - $limit = $query->getLimit(); - $fmtLimit = $lang->formatNum( $limit ); - - # Find out which strings are for the prev and which for the next links - $offset = $query->getOffsetString(); - $continue = $query->getContinueTemplateString(); - if ( $query->isReversed() ) { - $from = $offset; - $to = $continue; - } else { - $from = $continue; - $to = $offset; - } - - # Get prev/next link display text - $prev = wfMsgExt( 'prevn', array( 'parsemag', 'escape' ), $fmtLimit ); - $next = wfMsgExt( 'nextn', array( 'parsemag', 'escape' ), $fmtLimit ); - # Get prev/next link title text - $pTitle = wfMsgExt( 'prevn-title', array( 'parsemag', 'escape' ), $fmtLimit ); - $nTitle = wfMsgExt( 'nextn-title', array( 'parsemag', 'escape' ), $fmtLimit ); - - # Fetch the title object - $title = $this->getTitle(); - - # Make 'previous' link - if ( $to ) { - $attr = array( 'title' => $pTitle, 'class' => 'mw-prevlink' ); - $q = array( 'limit' => $limit, 'to' => $to, 'target' => $target ); - $plink = Linker::link( $title, $prev, $attr, $q ); - } else { - $plink = $prev; - } - - # Make 'next' link - if ( $from ) { - $attr = array( 'title' => $nTitle, 'class' => 'mw-nextlink' ); - $q = array( 'limit' => $limit, 'from' => $from, 'target' => $target ); - $nlink = Linker::link( $title, $next, $attr, $q ); - } else { - $nlink = $next; - } - - # Make links to set number of items per page - $numLinks = array(); - foreach ( array( 20, 50, 100, 250, 500 ) as $num ) { - $fmtLimit = $lang->formatNum( $num ); - - $q = array( 'offset' => $offset, 'limit' => $num, 'target' => $target ); - $lTitle = wfMsgExt( 'shown-title', array( 'parsemag', 'escape' ), $num ); - $attr = array( 'title' => $lTitle, 'class' => 'mw-numlink' ); - - $numLinks[] = Linker::link( $title, $fmtLimit, $attr, $q ); - } - $nums = $lang->pipeList( $numLinks ); - - return wfMsgHtml( 'viewprevnext', $plink, $nlink, $nums ); - } -} - - diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index e68584dad3..74ff8edfc2 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -34,8 +34,8 @@ class SpecialSearch extends SpecialPage { * For users tt replaces the set of enabled namespaces from the query * string when applicable. Extensions can add new profiles with hooks * with custom search options just for that profile. - * @var null|string - */ + * null|string + */ protected $profile; /// Search engine diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index ce939d62f7..b231c4a7a2 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -461,8 +461,6 @@ $specialPageAliases = array( 'Watchlist' => array( 'Watchlist' ), 'Whatlinkshere' => array( 'WhatLinksHere' ), 'Withoutinterwiki' => array( 'WithoutInterwiki' ), - 'GlobalFileUsage' => array( 'GlobalFileUsage' ), - 'GlobalTemplateUsage' => array( 'GlobalTemplateUsage' ), ); /** @@ -1412,9 +1410,6 @@ The latest log entry is provided below for reference:", 'templatesused' => '{{PLURAL:$1|Template|Templates}} used on this page:', 'templatesusedpreview' => '{{PLURAL:$1|Template|Templates}} used in this preview:', 'templatesusedsection' => '{{PLURAL:$1|Template|Templates}} used in this section:', -'distanttemplatesused' => 'Distant {{PLURAL:$1|template|templates}} used on this page:', -'distanttemplatesusedpreview' => 'Distant {{PLURAL:$1|template|templates}} used in this preview:', -'distanttemplatesusedsection' => 'Distant {{PLURAL:$1|template|templates}} used in this section:', 'template-protected' => '(protected)', 'template-semiprotected' => '(semi-protected)', 'hiddencategories' => 'This page is a member of {{PLURAL:$1|1 hidden category|$1 hidden categories}}:', @@ -4580,26 +4575,6 @@ Images are shown in full resolution, other file types are started with their ass 'compare-title-not-exists' => 'The title you specified does not exist.', 'compare-revision-not-exists' => 'The revision you specified does not exist.', -# Special:GlobalFileUsage -'globalfileusage' => 'Global file usage', -'globalfileusage-for' => 'Global file usage for "$1"', -'globalfileusage-desc' => '[[Special:GlobalFileUsage|Special page]] to view global file usage', -'globalfileusage-ok' => 'Search', -'globalfileusage-text' => 'Search global file usage', -'globalfileusage-no-results' => '[[$1]] is not used on other wikis.', -'globalfileusage-on-wiki' => 'Usage on $2', -'globalfileusage-more' => 'View [[{{#Special:GlobalUsage}}/$1|more global usage]] of this file.', -'globalfileusage-filterlocal' => 'Do not show local usage', - -# Special:GlobalTemplateUsage -'globaltemplateusage' => 'Global template usage', -'globaltemplateusage-for' => 'Global template usage for "$1"', -'globaltemplateusage-ok' => 'Search', -'globaltemplateusage-text' => 'Search global template usage', -'globaltemplateusage-no-results' => '[[$1]] is not used on other wikis.', -'globaltemplateusage-on-wiki' => 'Usage on $2', -'globaltemplateusage-more' => 'View [[{{#Special:GlobalUsage}}/$1|more global usage]] of this template.', -'globaltemplateusage-filterlocal' => 'Do not show local usage', # Database error messages 'dberr-header' => 'This wiki has a problem', diff --git a/maintenance/archives/patch-globalinterwiki.sql b/maintenance/archives/patch-globalinterwiki.sql deleted file mode 100644 index 6571a5aff2..0000000000 --- a/maintenance/archives/patch-globalinterwiki.sql +++ /dev/null @@ -1,10 +0,0 @@ --- Table associating distant wiki IDs with their interwiki prefixes. -CREATE TABLE /*_*/globalinterwiki ( - -- The wiki ID of the wiki - giw_wikiid varchar(64) NOT NULL, - - -- The interwiki prefix of that wiki - giw_prefix varchar(32) NOT NULL - -) /*$wgDBTableOptions*/; -CREATE UNIQUE INDEX /*i*/giw_index ON /*_*/globalinterwiki (giw_wikiid, giw_prefix); diff --git a/maintenance/archives/patch-globalnamespaces.sql b/maintenance/archives/patch-globalnamespaces.sql deleted file mode 100644 index 91b3578f6a..0000000000 --- a/maintenance/archives/patch-globalnamespaces.sql +++ /dev/null @@ -1,14 +0,0 @@ --- Table listing distant wiki namespace texts. -CREATE TABLE /*_*/globalnamespaces ( - -- The wiki ID of the remote wiki - gn_wiki varchar(64) NOT NULL, - - -- The namespace ID of the transcluded page on that wiki - gn_namespace int NOT NULL, - - -- The namespace text of transcluded page - -- Needed for display purposes, since the local namespace ID doesn't necessarily match a distant one - gn_namespacetext varchar(255) NOT NULL - -) /*$wgDBTableOptions*/; -CREATE UNIQUE INDEX /*i*/gn_index ON /*_*/globalnamespaces (gn_wiki, gn_namespace, gn_namespacetext); diff --git a/maintenance/archives/patch-globaltemplatelinks.sql b/maintenance/archives/patch-globaltemplatelinks.sql deleted file mode 100644 index d2da21bd82..0000000000 --- a/maintenance/archives/patch-globaltemplatelinks.sql +++ /dev/null @@ -1,36 +0,0 @@ --- Table tracking interwiki transclusions in the spirit of templatelinks. --- This table tracks transclusions of this wiki's templates on another wiki --- The gtl_from_* fields describe the (remote) page the template is transcluded from --- The gtl_to_* fields describe the (local) template being transcluded -CREATE TABLE /*_*/globaltemplatelinks ( - -- The wiki ID of the remote wiki - gtl_from_wiki varchar(64) NOT NULL, - - -- The page ID of the calling page on the remote wiki - gtl_from_page int unsigned NOT NULL, - - -- The namespace of the calling page on the remote wiki - -- Needed for display purposes, since the foreign namespace ID doesn't necessarily match a local one - -- The link between the namespace and the namespace name is made by the globalnamespaces table - gtl_from_namespace int NOT NULL, - - -- The title of the calling page on the remote wiki - -- Needed for display purposes - gtl_from_title varchar(255) binary NOT NULL, - - -- The interwiki prefix of the wiki that hosts the transcluded page - gtl_to_prefix varchar(32) NOT NULL, - - -- The namespace of the transcluded page on that wiki - gtl_to_namespace int NOT NULL, - - -- The namespace name of transcluded page - -- Needed for display purposes, since the local namespace ID doesn't necessarily match a distant one - gtl_to_namespacetext varchar(255) NOT NULL, - - -- The title of the transcluded page on that wiki - gtl_to_title varchar(255) binary NOT NULL -) /*$wgDBTableOptions*/; - -CREATE UNIQUE INDEX /*i*/gtl_to_from ON /*_*/globaltemplatelinks (gtl_to_prefix, gtl_to_namespace, gtl_to_title, gtl_from_wiki, gtl_from_page); -CREATE UNIQUE INDEX /*i*/gtl_from_to ON /*_*/globaltemplatelinks (gtl_from_wiki, gtl_from_page, gtl_to_prefix, gtl_to_namespace, gtl_to_title); diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index d53ada215f..9a8cd164f2 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -645,9 +645,6 @@ $wgMessageStructure = array( 'templatesused', 'templatesusedpreview', 'templatesusedsection', - 'distanttemplatesused', - 'distanttemplatesusedpreview', - 'distanttemplatesusedsection', 'template-protected', 'template-semiprotected', 'hiddencategories', @@ -3444,27 +3441,6 @@ $wgMessageStructure = array( 'compare-title-not-exists', 'compare-revision-not-exists', ), - 'globalfileusage' => array( - 'globalfileusage', - 'globalfileusage-for', - 'globalfileusage-desc', - 'globalfileusage-ok', - 'globalfileusage-text', - 'globalfileusage-no-results', - 'globalfileusage-on-wiki', - 'globalfileusage-more', - 'globalfileusage-filterlocal', - ), - 'globaltemplateusage' => array( - 'globaltemplateusage', - 'globaltemplateusage-for', - 'globaltemplateusage-ok', - 'globaltemplateusage-text', - 'globaltemplateusage-no-results', - 'globaltemplateusage-on-wiki', - 'globaltemplateusage-more', - 'globaltemplateusage-filterlocal', - ), 'db-error-messages' => array( 'dberr-header', 'dberr-problems', @@ -3752,8 +3728,6 @@ Variants for Chinese language", 'external_images' => 'External image whitelist', 'special-tags' => 'Special:Tags', 'comparepages' => 'Special:ComparePages', - 'globalfileusage' => 'Special:GlobalFileUsage', - 'globaltemplateusage' => 'Special:GlobalTemplateUsage', 'db-error-messages' => 'Database error messages', 'html-forms' => 'HTML forms', 'sqlite' => 'SQLite database support', diff --git a/maintenance/tables.sql b/maintenance/tables.sql index bacf6ce8e7..4b469b4d37 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -1474,68 +1474,4 @@ CREATE TABLE /*_*/config ( -- Should cover *most* configuration - strings, ints, bools, etc. CREATE INDEX /*i*/cf_name_value ON /*_*/config (cf_name,cf_value(255)); --- Table tracking interwiki transclusions in the spirit of templatelinks. --- This table tracks transclusions of this wiki's templates on another wiki --- The gtl_from_* fields describe the (remote) page the template is transcluded from --- The gtl_to_* fields describe the (local) template being transcluded -CREATE TABLE /*_*/globaltemplatelinks ( - -- The wiki ID of the remote wiki - gtl_from_wiki varchar(64) NOT NULL, - - -- The page ID of the calling page on the remote wiki - gtl_from_page int unsigned NOT NULL, - - -- The namespace of the calling page on the remote wiki - -- Needed for display purposes, since the foreign namespace ID doesn't necessarily match a local one - -- The link between the namespace and the namespace name is made by the globalnamespaces table - gtl_from_namespace int NOT NULL, - - -- The title of the calling page on the remote wiki - -- Needed for display purposes - gtl_from_title varchar(255) binary NOT NULL, - - -- The interwiki prefix of the wiki that hosts the transcluded page - gtl_to_prefix varchar(32) NOT NULL, - - -- The namespace of the transcluded page on that wiki - gtl_to_namespace int NOT NULL, - - -- The namespace name of transcluded page - -- Needed for display purposes, since the local namespace ID doesn't necessarily match a distant one - gtl_to_namespacetext varchar(255) NOT NULL, - - -- The title of the transcluded page on that wiki - gtl_to_title varchar(255) binary NOT NULL -) /*$wgDBTableOptions*/; - -CREATE UNIQUE INDEX /*i*/gtl_to_from ON /*_*/globaltemplatelinks (gtl_to_prefix, gtl_to_namespace, gtl_to_title, gtl_from_wiki, gtl_from_page); -CREATE UNIQUE INDEX /*i*/gtl_from_to ON /*_*/globaltemplatelinks (gtl_from_wiki, gtl_from_page, gtl_to_prefix, gtl_to_namespace, gtl_to_title); - --- Table listing distant wiki namespace texts. -CREATE TABLE /*_*/globalnamespaces ( - -- The wiki ID of the remote wiki - gn_wiki varchar(64) NOT NULL, - - -- The namespace ID of the transcluded page on that wiki - gn_namespace int NOT NULL, - - -- The namespace text of transcluded page - -- Needed for display purposes, since the local namespace ID doesn't necessarily match a distant one - gn_namespacetext varchar(255) NOT NULL - -) /*$wgDBTableOptions*/; -CREATE UNIQUE INDEX /*i*/gn_index ON /*_*/globalnamespaces (gn_wiki, gn_namespace, gn_namespacetext); - --- Table associating distant wiki IDs with their interwiki prefixes. -CREATE TABLE /*_*/globalinterwiki ( - -- The wiki ID of the wiki - giw_wikiid varchar(64) NOT NULL, - - -- The interwiki prefix of that wiki - giw_prefix varchar(32) NOT NULL - -) /*$wgDBTableOptions*/; -CREATE UNIQUE INDEX /*i*/giw_index ON /*_*/globalinterwiki (giw_wikiid, giw_prefix); - - -- vim: sw=2 sts=2 et