Extension:StubManager

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
StubManager

Release status: stable

Implementation framework (invalid type)
Description Framework extension for the vast majority of Jean-Lou Dupont's MediaWiki extensions
Author(s) Jean-Lou Dupont
Last Version 1.3.0
MediaWiki 1.7, 1.10, 1.11, 1.12
License No license specified
Download @see Installation section, or download from here
See SVN ($Id: StubManager.php 368 2007-10-03 17:10:25Z jeanlou.dupont $)

This is extension is required for many other extensions developed by User:Jldupont. This extension is meant for 'extension writers' and for users of extensions that depend on StubManager.

Contents

[edit] Important Note

Please do not use version 1.3.1 as it is buggy. Once the PHP PDT plugin for Eclipse/Ganymede is working, I'll update this extension. Thanks. Jean-Lou Dupont 13:08, 11 November 2008 (UTC)

[edit] Purpose

This extension lowers loading times which speeds up MediaWiki sites. This is done by addressing 'rare events' handling through class object 'stubs'. For infrequent events (of course this is relative!), use this extension to create a 'stub object' for the required hooks.

[edit] Features

  • Provides extension status messages through Special:Version
  • Handles 'hook' registration (e.g. ArticleSave, UserCan etc.)
  • Handles 'parser function' registration (e.g. {{ #magicword: ... }} )
  • Handles 'parser magic word' registration
  • Handles 'parser tag' registration (e.g. < tag> )
  • Handles extensions which implement logging functionality
  • Handles 'namespace triggering' & 'namespace exclusion'
    • reduces even further the load time per transaction

[edit] Dependency

None.

[edit] Installation

Important: To work correctly, make sure that this extension is listed first in LocalSettings.php before any other extensions depending on this one.

1. Add the following to LocalSettings.php:

require_once( "extensions/StubManager/StubManager.php" );

2. The most recent tgz file, currently StubManager-1.3.0.tgz.

3. Unzip the tgz file.

4. Drag and drop the entire "Stubmanager" folder into your /extensions folder, making sure that no folders or files locations are moved around.

5. Change the file name to "StubManager" only, with no version numbers. Don't forget, it's case sensitive.

6. Check to see if the Stubmanager is installed. There should be a line like the following on the Special:Version page:

StubManager (version x.x.x), Provides stubbing facility for extensions handling rare events. $1Extensions registered:, by Jean-Lou Dupont

[edit] PEAR

  • Install PEAR channel http://mediawiki.googlecode.com/svn
    • pear channel-discover mediawiki.googlecode.com/svn
  • Install extension through PEAR:
    • pear install mediawiki/stubmanager
  • Add the following to LocalSettings.php
require 'MediaWiki/StubManager/StubManager.php';

[edit] SVN

  • Download archive: SVN
  • Place extension files in /extensions
  • Add the following to LocalSettings.php:
require 'extensions/StubManager/StubManager.php';

[edit] Usage

To create a stub, use:

StubManager::createStub(  'class name', 
                          'full path filename of class file',
                          'full path filename of i18n file',						  
                          array of hooks,
						  $logging, // true if the extension requires logging support
                          array of tags,
                          array of parser function magic words,
                          array of parser magic words,
						  array of namespaces that trigger the extension
                        );

or, for example:

	StubManager::createStub2(	
		array(	'class' 		=> 'name-of-class-found-in-the-class-file', 
 
				// Class filename location
				'classfilename'	=> dirname(__FILE__).'/XYZ.body.php',
				// i18n file
                'i18nfilename'  => dirname(__FILE__).'/XYZ.i18n.php',	
                // Logging support
                // NOTE that the i18n file must follow some rules
                // See extensions such as UserLoginLogoutLog for examples.
                'logging'		=> true OR false,
				// Hooks:
				// Hook handling will be performed in the class-file through the method names
				// class::hHook-name1, class::hHook-name2 etc.
				'hooks'			=> array( Hook-name1, Hook-name2, ...	),
				// Tags
				// < tag1> < /tag1> etc.
				// Handler in class-file through the method name starting with 'tag_'
				'tags'			=> array( tag1, tag2, ... ),
				// Magic Words:
				// Magic word handling will be done in the class-file through the method names:					
				// class::mg_magic-word1, class::mg_magic-word2 etc.
				'mgs'			=> array( magic-word1, magic-word2, ... )
				// ess: namespace level EXCLUSION
				// Don't execute ANY of the method of this class if the current article falls in these namespaces
				// E.g. below:
				'ess'           => array( NS_MEDIAWIKI, ... ),
				// nss: namespace level TRIGGERS (aka 'inclusion')
				// Execute the methods of this class ONLY in the following namespaces:
				'nss'           => array( NS_MAIN, ... ),
				)
	);

in LocalSettings.php after the require line require( ...'StubManager.php' );

[edit] Examples

See Email Log extension.

[edit] Special:Version Customization

Customization of the extensions' state message can be done through the page MediaWiki:ExtensionState. The first parameter passed to the template is the state variable.

[edit] States

Value Description
0 OK
1 ERROR
2 ATTENTION
3 DISABLED

[edit] Troubleshooting

Extensions that depend on StubManager will show up in Special:Version under Extensions registered. If the extension you are installing does not appear on this list, then it can possibly mean that the require statement of the extension is listed before StubManager in your LocalSettings.php file. To correct this problem, place the dependent extension after the require statement of StubManager.

[edit] History

Version Notes
1.0.1 Adjusted for newest version of Extension:ExtensionManager
1.0.2 Updated to account for extra parameter to 'ArticleSaveComplete' hook introduced in MW1.11
1.0.3 Corrected minor bug in 'processArgList' which caused some erratic behavior in Extension:PageAfterAndBefore * Minor enhancement to the presentation in Special:Version
1.0.4 Small patch for even greater performance
1.0.5 Fix for bug in PHP v5.1.2 which caused Extension:HNP to misconfigure most of its parser functions
1.0.6 Added more allowable parameters to method __call: this is to account for more parameter hungry extensions such as Extension:EmbedObject
1.1.0 Added ExtHelper class - no change to basic functionality (backward compatibility)
1.1.1 Minor bug fix
1.2.0 Added single/double-quotes sanitization to ExtHelper, Added check for restricted parameters
1.2.1 Fixed style for Special:Version
1.3.0 Added ExtImages class: provides access to images. This facility is intended for registered extensions in order to provide visual feedback regarding their state (e.g. functional / missing parameters etc.) * Added additional per-extension information in Special:Version, Added method for registering extension state
Personal tools