Manual talk:Developing extensions

From MediaWiki.org
Jump to: navigation, search

This section could use a tutorial if anyone feels inclined to write one. --Sjledet 21:57, 22 January 2011 (UTC)

Well, lets start small... How do I Making your extension user configurable? --Dmb 16:18, 22 April 2011 (UTC)
BTW, There is a tutorial (of sorts) here: How_to_become_a_MediaWiki_hacker/Extension_Writing_Tutorial --Dan Bolser (talk) 04:24, 16 February 2013 (UTC)

Canonical extension 'setup' script?[edit]

I know different extension types need different extension types require different setup, but I wan't to create a nice 'template' setup script where sections you don't need can be commented out...

There is a good example of a ParserFunction type extension here: Manual:Parser_functions.
I have added this suggestion for the parser extension type into my cookiecutter template for MediaWiki extensions:

Best place for storing generated files[edit]

Hello all, is there a best practice where to store files that belong to an extension? I would suppose they should be stored in a subdirectory of $wgUploadDirectory (e. g. $IP/images/myextension/... ). Is that a recommended approach? --Pigpen (talk) 16:28, 20 March 2013 (UTC)

Disable caching while developing[edit]

Sorry for my bad English.

"While developing, you may want to disable caching by setting $wgMainCacheType = CACHE_NONE and $wgCacheDirectory = false, otherwise system message and other changes may not show up."

Localisation cache still enebled in Db, or not?

This will not affect on Localisation сache because in "includes/DefaultSettings.php(1844)": $wgLocalisationCacheConf = array( 'class' => 'LocalisationCache', 'store' => 'detect', 'storeClass' => false, 'storeDirectory' => false, 'manualRecache' => false, ); "* store: The location to store cache data. May be 'files', 'db' or * 'detect'. If set to "files", data will be in CDB files. If set * to "db", data will be stored to the database. If set to * "detect", files will be used if $wgCacheDirectory is set, * otherwise the database will be used."

But in http://www.mediawiki.org/wiki/Manual:$wgCacheDirectory "Set this to false to not use any local caches." And in http://www.mediawiki.org/wiki/Manual:Cache#Localization_caching "After finding out that a large number of the cached objects above were interface messages, the bits of text that are not content, an advanced localisation cache was introduced. Set $wgCacheDirectory in LocalSettings.php to a valid path to use."

As I understand it, initialy Localisation cache store only in filesystem, and $wgCacheDirectory used as trigger for disable/enable Localisation cache. But than by adding future for storing localisation cache in datebase and by mistake continue use $wgCacheDirectory as trigger. Therefore currently with parameters $wgMainCacheType = CACHE_NONE and $wgCacheDirectory = false Localisation Cache is still enebled and use datebase. This may confuse extention developers. (Its confuse me when I set hook $wgHooks['MessagesPreLoad'][] that not work, thanx debugging i find table with cache and modify exprie column, for row with cached messages).

Is currently there a way to disable localisation cache?

how to upload code to extension page[edit]

I have built an extension I would like to share, I've created an extension page and I would like to upload my code to the page so users can download a 'snapshot'. I've submitted a request to 'tool labs' for a gir repository but I'm not sure if I did it correctly as I haven't heard back from them in months. How do I go about adding my code to my new extension? Thanks --Tech (talk) 09:10, 24 June 2013 (UTC)

more information on Handlers?[edit]

I was bugging @bawolff on IRC because the docs on ImageHandler/MediaHandler were either out-of-date or non-existent. Posting this here for posterity. --MisterLambda (talk) 19:26, 24 May 2014 (UTC)

Updated localisation section[edit]

Hello everybody!

I havae briefly updated the localisation section to use json files, instead of i18n Message files. I was curt, so i'm unsure, if we can remove the outdated notice. Can anyone take a look? :)

Thanks! --Florianschmidtwelzow (talk) 14:11, 18 June 2014 (UTC)

Inconsistencies[edit]

The article says "A minimal extension will consist of three files, ... MyExtension_body.php ...". But, the Example and BoilerPlate extensions don't have files named Example_body.php or BoilerPlate_body.php. They simply have Example.php or BoilerPlate.php. What is correct, the article or the examples it recommends imitating?

The article says "If your extension is complex and involves multiple PHP files, you should follow the convention to put its implementation code in a subdirectory named MyExtension/includes." But, the Example and BoilerPlate extensions don't have "includes" subdirectories, in spite of having multiple (3 or 4) PHP files. How complex must an extension be, for the convention to be appropriate?

Specify file(s) under Load the localisation file[edit]

The part about the "setup routine" threw me off. I was quite sure it was supposed to go in a json-file by looking at the code snippet, but I had to go look in other extensions, as I didn't know what file. I think it would help to specify in what file(s) the code should go. I got it working by putting it in extension.json, but I don't know if that's the only place for it. /Sebastian Berlin (WMSE) (talk) 07:50, 25 May 2016 (UTC)

Internal Link: #Setup[edit]

This page appears to use {{anchor|Setup}} to create the Setup anchor. The way it's positioned, it renders above the Table of Contents. So, people clicking on it (like me) might think it's broken unless they look twice. I am unsure how to fix this (or even if I have the perms necessary). --Druid816 (talk) 04:45, 13 October 2016 (UTC)

Fixed. Thanks for mentioning it! Robin Hood  (talk) 05:04, 13 October 2016 (UTC)