From 599b5a42d01f9c0f6b89fbf02e04ba2ffd05d91f Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Mon, 30 Jun 2008 08:42:09 +0000 Subject: [PATCH] Two new hooks and one new global function from Wikia codebase --- RELEASE-NOTES | 5 ++++- docs/hooks.txt | 8 ++++++++ includes/GlobalFunctions.php | 21 +++++++++++++++++++++ includes/MessageCache.php | 1 + includes/Skin.php | 2 ++ 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3ec30a5663..fecd299ccd 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/docs/hooks.txt b/docs/hooks.txt index fe856a2805..5da995eecd 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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. diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 25c3162513..fe82f1ee1e 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 diff --git a/includes/MessageCache.php b/includes/MessageCache.php index 9bd33214f0..9d9a057f8d 100644 --- a/includes/MessageCache.php +++ b/includes/MessageCache.php @@ -363,6 +363,7 @@ class MessageCache { } $this->unlock(); $parserMemc->delete(wfMemcKey('sidebar')); + wfRunHooks( 'wfMessageCacheReplace', array( $title, $text ) ); wfProfileOut( __METHOD__ ); } diff --git a/includes/Skin.php b/includes/Skin.php index 3f8c6b983f..15b7a1ffa6 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -362,6 +362,8 @@ class Skin extends Linker { $vars['wgAjaxWatch'] = $msgs; } + wfRunHooks('ExtendJSGlobalVars', array(&$vars)); + return self::makeVariablesScript( $vars ); } -- 2.20.1