r39400 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39399‎ | r39400 | r39401 >
Date:09:14, 15 August 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
Modified parser function registration as per DanTMan's suggestion + added Daniel to the contributors' list
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/README (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -197,7 +197,7 @@
198198 */
199199 function smwfSetupExtension() {
200200 wfProfileIn('smwfSetupExtension (SMW)');
201 - global $smwgIP, $smwgStoreActive, $wgHooks, $wgExtensionCredits, $smwgEnableTemplateSupport, $smwgMasterStore, $smwgIQRunningNumber, $wgLanguageCode;
 201+ global $smwgIP, $smwgStoreActive, $wgHooks, $wgParser, $wgExtensionCredits, $smwgEnableTemplateSupport, $smwgMasterStore, $smwgIQRunningNumber, $wgLanguageCode;
202202
203203 /**
204204 * Setting this to false prevents any new data from being stored in
@@ -215,8 +215,9 @@
216216
217217 $smwgMasterStore = NULL;
218218 smwfInitContentLanguage($wgLanguageCode); // this really could not be done in enableSemantics()
219 - wfLoadExtensionMessages('SemanticMediaWiki'); /// FIXME: this is extremely slow; up to 10% of page display time (on a page with queries!) are consumed by loading unnecessary messages from a large file ...
 219+ wfLoadExtensionMessages('SemanticMediaWiki'); /// TODO: this is extremely slow; up to 10% of page display time (on a page with queries!) are consumed by loading unnecessary messages from a large file ...
220220 /// Past SMW releases had an average of about 1% extension loading time per call, while we are now up at 10%!
 221+ /// (if no PHP caching is enabled, things become better with ACP but impact still is noticeable)
221222 /// Should we return to our earlier message management for releases?
222223 $smwgIQRunningNumber = 0;
223224
@@ -225,7 +226,6 @@
226227 require_once($smwgIP . '/includes/SMW_RefreshTab.php');
227228
228229 $wgHooks['InternalParseBeforeLinks'][] = 'smwfParserHook'; // parse annotations
229 - $wgHooks['ParserBeforeStrip'][] = 'smwfRegisterInlineQueries'; // register the <ask> parser hook
230230 $wgHooks['ArticleSave'][] = 'smwfPreSaveHook'; // check some settings here
231231 $wgHooks['ArticleUndelete'][] = 'smwfUndeleteHook'; // restore annotations
232232 $wgHooks['ArticleDelete'][] = 'smwfDeleteHook'; // delete annotations
@@ -237,6 +237,15 @@
238238
239239 $wgHooks['ArticleFromTitle'][] = 'smwfShowListPage'; // special implementations for property/type articles
240240
 241+ if( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
 242+ $wgHooks['ParserFirstCallInit'][] = 'smwfRegisterParserFunctions';
 243+ } else {
 244+ if ( class_exists( 'StubObject' ) && !StubObject::isRealObject( $wgParser ) ) {
 245+ $wgParser->_unstub();
 246+ }
 247+ smwfRegisterParserFunctions( $wgParser );
 248+ }
 249+
241250 ///// credits (see "Special:Version") /////
242251 $wgExtensionCredits['parserhook'][]= array('name'=>'Semantic&nbsp;MediaWiki', 'version'=>SMW_VERSION, 'author'=>"Klaus&nbsp;Lassleben, [http://korrekt.org Markus&nbsp;Kr&ouml;tzsch], [http://simia.net Denny&nbsp;Vrandecic], S&nbsp;Page, and others. Maintained by [http://www.aifb.uni-karlsruhe.de/Forschungsgruppen/WBS/english AIFB Karlsruhe].", 'url'=>'http://semantic-mediawiki.org', 'description' => 'Making your wiki more accessible&nbsp;&ndash; for machines \'\'and\'\' humans. [http://semantic-mediawiki.org/wiki/Help:User_manual View online documentation.]');
243252
@@ -245,21 +254,16 @@
246255 }
247256
248257 /**
249 - * This hook registers a parser-hook to the current parser.
 258+ * This hook registers parser functions and hooks to the given parser.
250259 * Note that parser hooks are something different than MW hooks
251260 * in general, which explains the two-level registration.
252261 */
253 -function smwfRegisterInlineQueries( &$parser, &$text, &$stripstate ) {
254 - SMWFactbox::initStorage($parser->getTitle());
255 -
256 - $oldhook = $parser->setFunctionHook( 'ask', 'smwfProcessInlineQueryParserFunction' );
257 - if ($oldhook != 'smwfProcessInlineQueryParserFunction') {
258 - $parser->setHook( 'ask', 'smwfProcessInlineQuery' );
259 - $parser->setFunctionHook( 'ask', 'smwfProcessInlineQueryParserFunction' );
260 - $parser->setFunctionHook( 'show', 'smwfProcessShowParserFunction' );
261 - $parser->setFunctionHook( 'info', 'smwfProcessInfoParserFunction' );
262 - $parser->setFunctionHook( 'concept', 'smwfProcessConceptParserFunction' );
263 - }
 262+function smwfRegisterParserFunctions( &$parser) {
 263+ $parser->setHook( 'ask', 'smwfProcessInlineQuery' );
 264+ $parser->setFunctionHook( 'ask', 'smwfProcessInlineQueryParserFunction' );
 265+ $parser->setFunctionHook( 'show', 'smwfProcessShowParserFunction' );
 266+ $parser->setFunctionHook( 'info', 'smwfProcessInfoParserFunction' );
 267+ $parser->setFunctionHook( 'concept', 'smwfProcessConceptParserFunction' );
264268 return true; // always return true, in order not to stop MW's hook processing!
265269 }
266270
@@ -314,6 +318,7 @@
315319 // The global $smwgConceptText is used to pass information to the MW hooks for storing it,
316320 // $smwgPreviousConcept is used to detect if we already have a concept defined for this page.
317321 $title = $parser->getTitle();
 322+ SMWFactbox::initStorage($title); // make sure we have the right title
318323 if ($title->getNamespace() != SMW_NS_CONCEPT) {
319324 return smwfEncodeMessages(array(wfMsgForContent('smw_no_concept_namespace')));
320325 } elseif (isset($smwgPreviousConcept) && ($smwgPreviousConcept == $title->getText())) {
Index: trunk/extensions/SemanticMediaWiki/README
@@ -45,7 +45,7 @@
4646
4747 * Code has been contributed by (in no particular order) Kai Hüner, Fernando Correia,
4848 Yaron Koren, Nick Grandy, Jörg Heizmann, Daniel Herzig, Nikolas Iwan, Tobias Matzner,
49 - Thomas Bleher, Felix Kratzer, Frank Dengler, Nathan R. Yergler.
 49+ Thomas Bleher, Felix Kratzer, Frank Dengler, Nathan R. Yergler, Daniel Friesen.
5050
5151 * The new logo and related artwork for Semantic MediaWiki (see semanticweb.org)
5252 has been designed and realised by Rozana Vrandecic.

Status & tagging log