Two new hooks and one new global function from Wikia codebase
authorJack Phoenix <ashley@users.mediawiki.org>
Mon, 30 Jun 2008 08:42:09 +0000 (08:42 +0000)
committerJack Phoenix <ashley@users.mediawiki.org>
Mon, 30 Jun 2008 08:42:09 +0000 (08:42 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/GlobalFunctions.php
includes/MessageCache.php
includes/Skin.php

index 3ec30a5..fecd299 100644 (file)
@@ -63,7 +63,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * $wgMessageCacheType defines now the type of cache used by the MessageCache class,
   previously it was choosen based on $wgParserCacheType
 * $wgExtensionAliasesFiles option to simplify adding aliases to special pages
-* provided by extensions, in a similar way to $wgExtensionMessagesFiles
+  provided by extensions, in a similar way to $wgExtensionMessagesFiles
 
 === New features in 1.13 ===
 
@@ -173,6 +173,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Allow an $error message to be passed to ArticleDelete hook
 * Allow extensions to modify the user creation form by calling addInputItem();
 * Add meta generator tag to HTML output
+* Two new hooks, ExtendJSGlobalVars and wfMessageCacheReplace added
+* New global function, wfSharedTable - used to get the name of a table in the
+  shared database ($wgSharedDB)
  
 === Bug fixes in 1.13 ===
 
index fe856a2..5da995e 100644 (file)
@@ -600,6 +600,10 @@ $from: address of sending user
 $subject: subject of the mail
 $text: text of the mail
 
+'ExtendJSGlobalVars': called right before Skin::makeVariablesScript is executed
+&$vars: variable (or multiple variables) to be added into the output
+               of Skin::makeVariablesScript
+
 'FetchChangesList': When fetching the ChangesList derivative for a particular user
 &$user: User the list is being fetched for
 &$skin: Skin object to be used with the list
@@ -1287,5 +1291,9 @@ $article: article object watched
 'wgQueryPages': called when initialising $wgQueryPages, use this to add new query pages to be updated with maintenance/updateSpecialPages.php
 $query: $wgQueryPages itself
 
+'wfMessageCacheReplace': called after sidebar memcached key has been deleted, use this to replace core messages by using an extension
+$title: title of the MediaWiki: message page
+$text: text of the MediaWiki: message page
+
 More hooks might be available but undocumented, you can execute
 ./maintenance/findhooks.php to find hidden one.
index 25c3162..fe82f1e 100644 (file)
@@ -2675,3 +2675,24 @@ function wfGenerateToken( $salt = '' ) {
 
        return md5( mt_rand( 0, 0x7fffffff ) . $salt );
 }
+
+/**
+ * Create table name for shared database.
+ *
+ * @access public
+ * @author eloy@wikia
+ *
+ * @param string $table: table name
+ *
+ * @return string: table name with additional shared database
+ */
+function wfSharedTable( $table, $useExternal = true ) {
+       global $wgSharedDB, $wgExternalSharedDB;
+
+       if ($useExternal && !empty( $wgExternalSharedDB )) {
+               return "`$wgExternalSharedDB`.`$table`";
+       } elseif (!empty( $wgSharedDB )) {
+               return "`$wgSharedDB`.`$table`";
+       } else
+               return "`$table`";
+}
\ No newline at end of file
index 9bd3321..9d9a057 100644 (file)
@@ -363,6 +363,7 @@ class MessageCache {
                }
                $this->unlock();
                $parserMemc->delete(wfMemcKey('sidebar'));
+               wfRunHooks( 'wfMessageCacheReplace', array( $title, $text ) );
                wfProfileOut( __METHOD__ );
        }
 
index 3f8c6b9..15b7a1f 100644 (file)
@@ -362,6 +362,8 @@ class Skin extends Linker {
                        $vars['wgAjaxWatch'] = $msgs;
                }
 
+               wfRunHooks('ExtendJSGlobalVars', array(&$vars));
+
                return self::makeVariablesScript( $vars );
        }