Commit graph

59 commits

Author SHA1 Message Date
Sam Reed
c052fc3b7b Documentation followups from lastnight 2012-02-10 15:37:33 +00:00
Sam Reed
7b25f8231f Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 19:30:01 +00:00
Aaron Schulz
5a6559d8b1 Reverted r108743 per CR comment. This should at least be discussed first. 2012-01-12 19:41:18 +00:00
Sam Reed
a5c200a25b Kill "* @return void" 2012-01-12 19:12:24 +00:00
Aaron Schulz
1d77bc94c2 * Cleanup for r108175: made if easier for extensions to interact with each other in TitleReadWhitelist hook. A handler can set $whitelisted to true to whitelist the page or it can set it to false and return false (most restrictive wins).
* Added some hook doc comments.
2012-01-06 06:16:05 +00:00
Alexandre Emsenhuber
4aa1b32903 Throw a FatalError exception instead of calling OutputPage::showFatalError() (on usage of $wgOut less) 2011-11-09 10:59:17 +00:00
Sam Reed
bdf84cb20e Swap else if for elseif
Trimming trailing whitespace also

Doing in 3 commits, so hopefully reviewable in CR...
2011-06-17 16:03:52 +00:00
Alexandre Emsenhuber
6494121882 Now that Hooks.php contains a class, moved wfRunHooks() definition to GlobalFunctions.php and removed its inclusion from Setup.php 2011-05-28 16:11:40 +00:00
Antoine Musso
9787dea7a2 use string as callback when possible (since PHP 5.2.3) 2011-05-18 20:33:47 +00:00
Alexandre Emsenhuber
81e9b02ff5 * Drop 5.1 compat code
* Fix one more PHP version requirement
2011-04-03 09:44:50 +00:00
Jack Phoenix
3f0decb5cd Hooks.php: trim trailing spaces, tweak docs, etc. 2011-01-26 16:50:31 +00:00
X!
aa9b9527b9 Add new Hooks class, because $wgHooks globals are evil.
$wgHooks['EventName'][] = $callback; --> Hooks::register( 'EventName', $callback );
wfRunHooks( 'EventName', array() ); --> Hooks::run( 'EventName', array() );
Tests added to complement change. Backwards compatibility added.
2011-01-17 03:35:42 +00:00
Sam Reed
8a01281913 Remove some unreachable code (usually returns after throwing exceptions)
Fixup call of method after return in DatabaseMssql by using a temp
2010-08-24 22:03:18 +00:00
Alexandre Emsenhuber
5be509b0c1 * Standardised file description headers
* Added some descriptions
* Added @file where needed
2010-08-08 14:23:14 +00:00
Niklas Laxström
f09f99ac1f Follow-up r70109: use restore_error_handler() 2010-08-03 19:46:18 +00:00
Niklas Laxström
f479715fd1 Better error message if hook function signature does not match parameters.
Also took the opportunity to write a short essay why this made me annoyed.
2010-07-28 21:05:15 +00:00
Chad Horohoe
a4e5e935b6 Mass convert NULL -> null. Left strings and comments alone, obviously. 2009-12-11 21:07:27 +00:00
Tim Starling
23cfebd3d2 * Introduced a new system for localisation caching. The system is based around fast fetches of individual messages, minimising memory overhead and startup time in the typical case. It handles both core messages (formerly in Language.php) and extension messages (formerly in MessageCache.php). Profiling indicates a significant win for average throughput.
* The serialized message cache, which would have been redundant, has been removed. Similar performance characteristics can be achieved with $wgLocalisationCacheConf['manualRecache'] = true;
* Added a maintenance script rebuildLocalisationCache.php for offline rebuilding of the localisation cache.
* Extension i18n files can now contain any of the variables which can be set in Messages*.php. It is possible, and recommended, to use this feature instead of the hooks for special page aliases and magic words. 
* $wgExtensionAliasesFiles, LanguageGetMagic and LanguageGetSpecialPageAliases are retained for backwards compatibility. $wgMessageCache->addMessages() and related functions have been removed. wfLoadExtensionMessages() is a no-op and can continue to be called for b/c. 
* Introduced $wgCacheDirectory as a default location for the various local caches that have accumulated. Suggested $IP/cache as a good place for it in the default LocalSettings.php and created this directory with a deny-all .htaccess.
* Patched Exception.php to avoid using the message cache when an exception is thrown from within LocalisationCache, since this tends to fail horribly.
* Removed Language::getLocalisationArray(), Language::loadLocalisation(), Language::load()
* Fixed FileDependency::__sleep()
* In Cdb.php, fixed newlines in debug messages

In MessageCache::get(): 
* Replaced calls to $wgContLang capitalisation functions with plain PHP functions, reducing the typical case from 99us to 93us. Message cache keys are already documented as being restricted to ASCII.
* Implemented a more efficient way to filter out bogus language codes, reducing the "foo/en" case from 430us to 101us
* Optimised wfRunHooks() in the typical do-nothing case, from ~30us to ~3us. This reduced MessageCache::get() typical case time from 93us to 38us.
* Removed hook MessageNotInMwNs to save an extra 3us per cache hit. Reimplemented the only user (LocalisationUpdate) using the new hook LocalisationCacheRecache.
2009-06-28 07:11:43 +00:00
Alexandre Emsenhuber
0ec69aed3b * (bug 18009) $wgHooks and $wgExtensionFunctions now support closures
* Whitespaces fixes in includes/Hooks.php
2009-04-06 12:41:20 +00:00
Brion Vibber
97f77b9b1a Revert r44702, r44703, r44704 (wfInvoke and UserMailer refactor based on it) and r44715, r44721 (cleanup thereof)
As Tim notes, the weird callback setup in $wgHooks isn't really something we want to replicate or ever rely on ever again, as PHP's native callback syntax already handles things fine and is more consistent (and used extensively in the rest of MediaWiki).
May be other remaining issues with the refactor on top of bugs already discovered, but if it's going to be refactored to use callbacks it should be done using regular callbacks.
2008-12-23 18:08:43 +00:00
Alexandre Emsenhuber
a3cbeaeefd * Short circuit EmailNotification::notify() to not call EmailNotification::commonMessageKeys() if there're no users to notify. This is a hack to work arround the following exception:
A database query syntax error has occurred.
The last attempted database query was:
"SELECT gu_id, lu_wiki, gu_salt, gu_password,gu_auth_token, gu_locked,gu_hidden,gu_registration,gu_email,gu_email_authenticated FROM `parsertest_globaluser` LEFT OUTER JOIN `parsertest_localuser` ON gu_name=lu_name AND lu_wiki='test2wiki-parsertest_' WHERE gu_name='127.0.0.1'"
from within function "Database::safeQuery".
MySQL returned error "1146: Table 'centralauth.parsertest_globaluser' doesn't exist (127.0.0.1)"
* Whitespaces fixes
2008-12-17 17:27:43 +00:00
David McCabe
ed8f5b04f0 wfInvoke documentation fix 2008-12-17 07:05:42 +00:00
David McCabe
0e74714049 Factored wfInvoke out of wfRunHooks. This time without breakage. (I think.) 2008-12-17 07:00:18 +00:00
Brion Vibber
d3c6121c5b Roll back r43377, r43379 "Factored wfInvokeFancyCallback() out of wfRunHooks(). Allows flexible dynamic invocation to be used in other contexts." / "Renamed the new wfInvokeFancyCallback to simply wfInvoke."
Breaks existing hooks including core language converters:

Notice: Undefined variable: event in /Library/WebServer/Documents/trunk/includes/Hooks.php on line 61
Warning: call_user_func_array(): First argument is expected to be a valid callback, 'ZhConverter::on' was given in /Library/WebServer/Documents/trunk/includes/Hooks.php on line 119
Notice: Undefined variable: args in /Library/WebServer/Documents/trunk/includes/Hooks.php on line 80
Notice: Undefined variable: event in /Library/WebServer/Documents/trunk/includes/Hooks.php on line 61
Detected bug in an extension! Hook ZhConverter::on failed to return a value; should return true to continue hook processing or false to abort.
Backtrace:
#0 /Library/WebServer/Documents/trunk/includes/Article.php(1684): wfRunHooks('ArticleSaveComp...', Array)
#1 /Library/WebServer/Documents/trunk/includes/Article.php(1354): Article->doEdit('Article for spe...', '', 97)
#2 /Library/WebServer/Documents/trunk/maintenance/parserTests.inc(998): Article->insertNewArticle('Article for spe...', '', false, false)
#3 /Library/WebServer/Documents/trunk/maintenance/parserTests.inc(307): ParserTest->addArticle('Xyzzyx', 'Article for spe...', 5168)
#4 /Library/WebServer/Documents/trunk/maintenance/parserTests.inc(273): ParserTest->runFile('/Library/WebSer...')
#5 /Library/WebServer/Documents/trunk/maintenance/parserTests.php(73): ParserTest->runTestsFromFiles(Array)
#6 {main}
2008-11-12 18:06:14 +00:00
David McCabe
17ebdb72f1 Renamed the new wfInvokeFancyCallback to simply wfInvoke. 2008-11-11 01:49:38 +00:00
David McCabe
0fa321710d Factored wfInvokeFancyCallback() out of wfRunHooks(). Allows flexible dynamic invocation to be used in other contexts. 2008-11-11 01:07:34 +00:00
Alexandre Emsenhuber
087a9f70c5 WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>

Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage

One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
Siebrand Mazeland
79d5225c0e * remove end of line whitespace
* remove empty lines at end of file
* remove "?>" where still present
2008-04-14 07:45:50 +00:00
Tim Starling
554f8277ae Workaround for call_user_func_array bug 2008-04-08 09:51:13 +00:00
Brion Vibber
deb2045611 * (bug 12294) Namespace class renamed to MWNamespace for PHP 5.3 compatibility
* PHP 5.3 compatibility fix for wfRunHooks() called with no parameters

An autoloaded 'Namespace' class alias is retained for compatibility with
extensions which haven't updated to the new class name... however they too
will break on PHP 5.3. Yay!
2008-03-21 23:13:34 +00:00
Brion Vibber
bbdd0f8d0a pretty up the hook error message with an explanation of what it should do instead 2007-07-20 15:15:09 +00:00
Aryeh Gregor
a15c419b3d Remove ?>'s from files. They're pointless, and just asking for people to mess with the files and add trailing whitespace. (Yes, I looked over every one and reverted those that were bogus. Slash-enter a million times in less worked well enough, although it was a bit mind-numbing.) 2007-06-29 01:19:14 +00:00
Tim Starling
42161bac3f Fixed incorrect error message for static member functions 2007-06-26 14:52:37 +00:00
Brion Vibber
4e83003145 * Throw a showstopper exception when a hook function fails to return a value.
Forgetting to give a 'true' return value is a very common error which tends
  to cause hard-to-track-down interactions between extensions.
2007-06-20 19:35:17 +00:00
Tim Starling
81cbabb3a1 Fixed static member invocation, was broken since inception. 2007-03-22 22:56:16 +00:00
Antoine Musso
c771fc9c96 Use Doxygen @addtogroup instead of phpdoc @package && @subpackage 2007-01-20 15:09:52 +00:00
Nick Jenkins
ae8554c45b Completing code housekeeping stuff for rest of includes/ directory: removing unused local vars, removing unused globals, replacing extract() where simple to do, declaring output arrays before calling preg_match(), and so forth. 2006-11-29 11:43:58 +00:00
Tim Starling
d4efe7fa7b Allow hooks to be static member functions 2006-09-24 06:04:58 +00:00
Brion Vibber
60209332e8 * Fix bug in wfRunHooks which caused corruption of objects in the hook list
References EVIL! Not needed anymore in PHP 5 anyway.
2006-08-30 10:56:17 +00:00
Tim Starling
02547dac72 Removed most exit() calls from the MediaWiki core, by replacing them with either a throw or by classic error checking. OutputPage::fatalError() and similar functions are deprecated, use either OutputPage::showFatalError() to return control or throw new FatalError() to relinquish it. Backwards compatibility of all interfaces has been maintained, thus extensions should continue to work and can be ported at a later date. 2006-06-07 06:40:24 +00:00
Brion Vibber
f2c29baf9f Update the FSF's address in all these GPL stub headers 2006-04-05 07:43:17 +00:00
Domas Mituzas
d43e743074 remove profiling hooks from hooks ;-) 2006-01-25 10:51:12 +00:00
Domas Mituzas
8aabcc03d1 Be less anal about entry points, class definitions do no harm to anyone, defined() is expensive 2006-01-14 11:04:04 +00:00
Brion Vibber
266d41f165 * Added wfDie() wrapper, and some manual die(-1), to force the return code
to the shell to return nonzero when we crap out with an error.
2006-01-14 02:49:43 +00:00
Ævar Arnfjörð Bjarmason
a26d5a49d7 * s~\t+$~~ 2006-01-07 13:31:29 +00:00
Ævar Arnfjörð Bjarmason
7bbe971aec * s~ +$~~ 2006-01-07 13:09:30 +00:00
Ævar Arnfjörð Bjarmason
9b1de8577e Code review!
* Don't start a new scope with if ! defined 'MEDIAWIKI...
2006-01-07 12:17:42 +00:00
Tim Starling
0c7c45848b Preserve object references 2005-10-22 16:19:03 +00:00
Brion Vibber
3ed747730d * Fix for hook callbacks on objects containing no fields
A simple 'if($object)' was coming up false; use 'if(isset($object))'.
2005-10-13 23:27:38 +00:00
Brion Vibber
b8f65e7cc4 * (bug 3684) Fix typo in fatal error backtraces in Hooks.php 2005-10-12 06:31:42 +00:00