Rename $wgVaryOnXFPForAPI (introduced in r93818) to $wgVaryOnXFP and extend it to...
[lhc/web/wiklou.git] / includes / BacklinkCache.php
index e44e19d..1194015 100644 (file)
@@ -75,6 +75,8 @@ class BacklinkCache {
         * Serialization handler, diasallows to serialize the database to prevent
         * failures after this class is deserialized from cache with dead DB
         * connection.
+        *
+        * @return array
         */
        function __sleep() {
                return array( 'partitionCache', 'fullResultCache', 'title' );
@@ -190,7 +192,13 @@ class BacklinkCache {
                if ( isset( $prefixes[$table] ) ) {
                        return $prefixes[$table];
                } else {
-                       throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
+                       $prefix = null;
+                       wfRunHooks( 'BacklinkCacheGetPrefix', array( $table, &$prefix ) );
+                       if( $prefix ) {
+                               return $prefix;
+                       } else {
+                               throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
+                       }
                }
        }
 
@@ -207,10 +215,20 @@ class BacklinkCache {
                switch ( $table ) {
                        case 'pagelinks':
                        case 'templatelinks':
+                               $conds = array(
+                                       "{$prefix}_namespace" => $this->title->getNamespace(),
+                                       "{$prefix}_title"     => $this->title->getDBkey(),
+                                       "page_id={$prefix}_from"
+                               );
+                               break;
                        case 'redirect':
                                $conds = array(
                                        "{$prefix}_namespace" => $this->title->getNamespace(),
                                        "{$prefix}_title"     => $this->title->getDBkey(),
+                                       $this->getDb()->makeList( array(
+                                               "{$prefix}_interwiki = ''",
+                                               "{$prefix}_interwiki is null",
+                                       ), LIST_OR ),
                                        "page_id={$prefix}_from"
                                );
                                break;
@@ -227,7 +245,10 @@ class BacklinkCache {
                                );
                                break;
                        default:
-                               throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
+                               $conds = null;
+                               wfRunHooks( 'BacklinkCacheGetConditions', array( $table, $this->title, &$conds ) );
+                               if( !$conds )
+                                       throw new MWException( "Invalid table \"$table\" in " . __CLASS__ );
                }
 
                return $conds;