Index: branches/iwtransclusion/phase3v2/includes/DefaultSettings.php |
— | — | @@ -2938,13 +2938,35 @@ |
2939 | 2939 | $wgPreprocessorCacheThreshold = 1000; |
2940 | 2940 | |
2941 | 2941 | /** |
2942 | | - * Enable interwiki transcluding. Only when iw_trans=1. |
| 2942 | + * Enable interwiki transcluding. Only when iw_trans=1 in the interwiki table. |
| 2943 | + * If the interwiki prefix is associated with a wiki ID in the interwiki table, |
| 2944 | + * then the distant templates will be retrieved in the distant DB. If there is |
| 2945 | + * no wiki ID but a API URL for that prefix, the distant templates will be |
| 2946 | + * retrieved using the API and cached in memcached. |
2943 | 2947 | */ |
2944 | | -$wgEnableScaryTranscluding = false; |
| 2948 | +$wgEnableInterwikiTranscluding = false; |
2945 | 2949 | |
2946 | 2950 | /** |
2947 | | - * Expiry time for interwiki transclusion |
| 2951 | + * If $wgEnableInterwikiTranscluding is set to true and if an interwiki prefix |
| 2952 | + * is associated with a wiki ID, then, this option should be set to true to |
| 2953 | + * enable the cache invalidation of the distant pages when the local templates |
| 2954 | + * are edited and also to display the list of the distant templates used by |
| 2955 | + * the local pages. Enabling this requires to set up a global shared database |
| 2956 | + * (see next option $wgGlobalDatabase). |
2948 | 2957 | */ |
| 2958 | +$wgEnableInterwikiTemplatesTracking = false; |
| 2959 | + |
| 2960 | +/** |
| 2961 | + * If $wgEnableInterwikiTemplatesTracking is set to true, this option should |
| 2962 | + * contain the wiki ID of the database that hosts the globaltemplatelinks table. |
| 2963 | + */ |
| 2964 | +$wgGlobalDatabase = ''; |
| 2965 | + |
| 2966 | +/** |
| 2967 | + * If $wgEnableInterwikiTranscluding is set to true and if an interwiki |
| 2968 | + * prefix is associated with an API URL and no wiki ID, this will be |
| 2969 | + * the expiry time for the transcluded templates cached in memcached. |
| 2970 | + */ |
2949 | 2971 | $wgTranscludeCacheExpiry = 3600; |
2950 | 2972 | |
2951 | 2973 | /** @} */ # end of parser settings } |
Index: branches/iwtransclusion/phase3v2/includes/Article.php |
— | — | @@ -4007,6 +4007,10 @@ |
4008 | 4008 | |
4009 | 4009 | // Invalidate caches of articles which include this page |
4010 | 4010 | $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'templatelinks' ); |
| 4011 | + |
| 4012 | + // Invalidate caches of distant articles which transclude this page |
| 4013 | + $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'globaltemplatelinks' ); |
| 4014 | + wfDoUpdates(); |
4011 | 4015 | |
4012 | 4016 | // Invalidate the caches of all pages which redirect here |
4013 | 4017 | $wgDeferredUpdateList[] = new HTMLCacheUpdate( $title, 'redirect' ); |
— | — | @@ -4174,7 +4178,7 @@ |
4175 | 4179 | } |
4176 | 4180 | |
4177 | 4181 | $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); |
4178 | | - $res = $dbr->select( array( 'globaltemplatelinks' ), |
| 4182 | + $res = $dbr->select( 'globaltemplatelinks', |
4179 | 4183 | array( 'gtl_to_prefix', 'gtl_to_namespace', 'gtl_to_title' ), |
4180 | 4184 | array( 'gtl_from_wiki' => wfWikiID( ), 'gtl_from_page' => $id ), |
4181 | 4185 | __METHOD__ ); |
— | — | @@ -4184,10 +4188,8 @@ |
4185 | 4189 | $result[] = Title::makeTitle( $row->gtl_to_namespace, $row->gtl_to_title, null, $row->gtl_to_prefix ); |
4186 | 4190 | } |
4187 | 4191 | } |
4188 | | - |
4189 | | - $dbr->freeResult( $res ); |
4190 | 4192 | } |
4191 | | - |
| 4193 | + |
4192 | 4194 | return $result; |
4193 | 4195 | } |
4194 | 4196 | |
Index: branches/iwtransclusion/phase3v2/includes/Linker.php |
— | — | @@ -1594,12 +1594,6 @@ |
1595 | 1595 | |
1596 | 1596 | $outText = ''; |
1597 | 1597 | if ( count( $templates ) > 0 ) { |
1598 | | - # Do a batch existence check |
1599 | | - $batch = new LinkBatch; |
1600 | | - foreach( $templates as $title ) { |
1601 | | - $batch->addObj( $title ); |
1602 | | - } |
1603 | | - $batch->execute(); |
1604 | 1598 | |
1605 | 1599 | # Construct the HTML |
1606 | 1600 | $outText = '<div class="mw-templatesUsedExplanation">'; |
Index: branches/iwtransclusion/phase3v2/includes/interwiki/Interwiki.php |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | * All information is loaded on creation when called by Interwiki::fetch( $prefix ). |
11 | 11 | * All work is done on slave, because this should *never* change (except during |
12 | 12 | * schema updates etc, which aren't wiki-related) |
| 13 | + * This class also contains the functions that allow interwiki templates transclusion. |
13 | 14 | */ |
14 | 15 | class Interwiki { |
15 | 16 | |
Property changes on: branches/iwtransclusion/phase3v2/includes/interwiki/Interwiki.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
16 | 17 | Merged /branches/iwtransclusion/phase3/includes/interwiki/Interwiki.php:r70802 |
Index: branches/iwtransclusion/phase3v2/includes/BacklinkCache.php |
— | — | @@ -173,6 +173,27 @@ |
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
| 177 | + * Get the distant backtemplatelinks for the table globaltemplatelinks. Cached in process memory only. |
| 178 | + * @param $table String |
| 179 | + * @param $startId Integer or false |
| 180 | + * @param $endId Integer or false |
| 181 | + * @return TitleArray |
| 182 | + */ |
| 183 | + public function getDistantTemplateLinks( ) { |
| 184 | + global $wgGlobalDatabase, $wgLocalInterwiki; |
| 185 | + |
| 186 | + $dbr = $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase ); |
| 187 | + $res = $dbr->select( |
| 188 | + array( 'globaltemplatelinks' ), |
| 189 | + array( 'gtl_from_wiki', 'gtl_from_page' ), |
| 190 | + array( 'gtl_to_prefix' => $wgLocalInterwiki, 'gtl_to_title' => $this->title->getDBkey( ) ), |
| 191 | + __METHOD__, |
| 192 | + 'GROUP BY gtl_from_wiki' |
| 193 | + ); |
| 194 | + return $res; |
| 195 | + } |
| 196 | + |
| 197 | + /** |
177 | 198 | * Get the field name prefix for a given table |
178 | 199 | * @param $table String |
179 | 200 | */ |
— | — | @@ -183,6 +204,7 @@ |
184 | 205 | 'categorylinks' => 'cl', |
185 | 206 | 'templatelinks' => 'tl', |
186 | 207 | 'redirect' => 'rd', |
| 208 | + 'globaltemplatelinks' => 'gtl', |
187 | 209 | ); |
188 | 210 | |
189 | 211 | if ( isset( $prefixes[$table] ) ) { |
Index: branches/iwtransclusion/phase3v2/includes/cache/HTMLCacheUpdate.php |
— | — | @@ -51,6 +51,16 @@ |
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
| 55 | + if ( $this->mTable === 'globaltemplatelinks' ) { |
| 56 | + global $wgEnableInterwikiTemplatesTracking; |
| 57 | + |
| 58 | + if ( $wgEnableInterwikiTemplatesTracking ) { |
| 59 | + $distantPageArray = $this->mCache->getDistantTemplateLinks( 'globaltemplatelinks' ); |
| 60 | + $this->invalidateDistantTitles( $distantPageArray ); |
| 61 | + } |
| 62 | + return; |
| 63 | + } |
| 64 | + |
55 | 65 | # Get an estimate of the number of rows from the BacklinkCache |
56 | 66 | $numRows = $this->mCache->getNumLinks( $this->mTable ); |
57 | 67 | if ( $numRows > $this->mRowsPerJob * 2 ) { |
— | — | @@ -68,6 +78,7 @@ |
69 | 79 | $this->invalidateTitles( $titleArray ); |
70 | 80 | } |
71 | 81 | } |
| 82 | + wfRunHooks( 'HTMLCacheUpdate::doUpdate', array($this->mTitle) ); |
72 | 83 | } |
73 | 84 | |
74 | 85 | /** |
— | — | @@ -204,7 +215,35 @@ |
205 | 216 | } |
206 | 217 | } |
207 | 218 | } |
208 | | - |
| 219 | + |
| 220 | + /** |
| 221 | + * Invalidate an array of distant pages, given the wiki ID and page ID of those pages |
| 222 | + */ |
| 223 | + protected function invalidateDistantTitles( $distantPageArray ) { |
| 224 | + global $wgUseFileCache, $wgUseSquid, $wgLocalInterwiki; |
| 225 | + |
| 226 | + $pagesByWiki = array(); |
| 227 | + foreach ( $distantPageArray as $row ) { |
| 228 | + $wikiid = $row->gtl_from_wiki; |
| 229 | + if( !isset( $pagesByWiki[$wikiid] ) ) { |
| 230 | + $pagesByWiki[$wikiid] = array(); |
| 231 | + } |
| 232 | + $pagesByWiki[$wikiid][] = $row->gtl_from_page; |
| 233 | + } |
| 234 | + |
| 235 | + foreach ( $pagesByWiki as $wikiid => $pages ) { |
| 236 | + $dbw = wfGetDB( DB_MASTER, array( ), $wikiid ); |
| 237 | + $timestamp = $dbw->timestamp(); |
| 238 | + $batches = array_chunk( $pages, $this->mRowsPerQuery ); |
| 239 | + foreach ( $batches as $batch ) { |
| 240 | + $dbw->update( 'page', |
| 241 | + array( 'page_touched' => $timestamp ), |
| 242 | + array( 'page_id IN (' . $dbw->makeList( $batch ) . ')' ), |
| 243 | + __METHOD__ |
| 244 | + ); |
| 245 | + } |
| 246 | + } |
| 247 | + } |
209 | 248 | } |
210 | 249 | |
211 | 250 | /** |
Property changes on: branches/iwtransclusion/phase3v2 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
212 | 251 | Merged /branches/iwtransclusion/phase3:r70802-70803 |