Extension talk:UserFunctions

About this board

MagicWord.php: Error: invalid magic word 'ifanon'

Antdragone (talkcontribs)

I'm trying to install BlueSpice 4 on my Green Geeks hosted webserver, and I have been getting the following error when attempting to run wiki/mw-config/index.php for updating tables.

[5d21ae33df9a95266fcf8af3] /mw-config/index.php?page=ExistingWiki MWException from line 129 of /home/positro2/public_html/nomadsgalaxy/wiki/includes/MagicWord.php: Error: invalid magic word 'ifanon'


#0 /home/positro2/public_html/nomadsgalaxy/wiki/includes/MagicWordFactory.php(230): MagicWord->load(string)

#1 /home/positro2/public_html/nomadsgalaxy/wiki/includes/parser/Parser.php(4872): MagicWordFactory->get(string)

#2 /home/positro2/public_html/nomadsgalaxy/wiki/extensions/UserFunctions/UserFunctions.php(109): Parser->setFunctionHook(string, string, integer)

#3 /home/positro2/public_html/nomadsgalaxy/wiki/includes/HookContainer/HookContainer.php(329): wfRegisterUserFunctions(Parser)

#4 /home/positro2/public_html/nomadsgalaxy/wiki/includes/HookContainer/HookContainer.php(132): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)

#5 /home/positro2/public_html/nomadsgalaxy/wiki/includes/HookContainer/HookRunner.php(2960): MediaWiki\HookContainer\HookContainer->run(string, array)

#6 /home/positro2/public_html/nomadsgalaxy/wiki/includes/parser/Parser.php(532): MediaWiki\HookContainer\HookRunner->onParserFirstCallInit(Parser)

#7 /home/positro2/public_html/nomadsgalaxy/wiki/includes/parser/Parser.php(477): Parser->firstCallInit()

#8 /home/positro2/public_html/nomadsgalaxy/wiki/includes/parser/ParserFactory.php(142): Parser->__construct(MediaWiki\Config\ServiceOptions, MagicWordFactory, LanguageEn, ParserFactory, string, MediaWiki\SpecialPage\SpecialPageFactory, MediaWiki\Linker\LinkRendererFactory, NamespaceInfo, MediaWiki\Logger\LegacyLogger, MediaWiki\BadFileLookup, MediaWiki\Languages\LanguageConverterFactory, MediaWiki\HookContainer\HookContainer)

#9 /home/positro2/public_html/nomadsgalaxy/wiki/includes/ServiceWiring.php(817): ParserFactory->create()

#10 /home/positro2/public_html/nomadsgalaxy/wiki/vendor/wikimedia/services/src/ServiceContainer.php(447): Wikimedia\Services\ServiceContainer->{closure}(MediaWiki\MediaWikiServices)

#11 /home/positro2/public_html/nomadsgalaxy/wiki/vendor/wikimedia/services/src/ServiceContainer.php(416): Wikimedia\Services\ServiceContainer->createService(string)

#12 /home/positro2/public_html/nomadsgalaxy/wiki/includes/MediaWikiServices.php(1000): Wikimedia\Services\ServiceContainer->getService(string)

#13 /home/positro2/public_html/nomadsgalaxy/wiki/includes/installer/Installer.php(732): MediaWiki\MediaWikiServices->getParser()

#14 /home/positro2/public_html/nomadsgalaxy/wiki/includes/installer/WebInstaller.php(657): Installer->parse(string, boolean)

#15 /home/positro2/public_html/nomadsgalaxy/wiki/includes/installer/WebInstallerExistingWiki.php(104): WebInstaller->getInfoBox(string)

#16 /home/positro2/public_html/nomadsgalaxy/wiki/includes/installer/WebInstallerExistingWiki.php(92): WebInstallerExistingWiki->showKeyForm()

#17 /home/positro2/public_html/nomadsgalaxy/wiki/includes/installer/WebInstaller.php(269): WebInstallerExistingWiki->execute()

#18 /home/positro2/public_html/nomadsgalaxy/wiki/mw-config/index.php(82): WebInstaller->execute(array)

#19 /home/positro2/public_html/nomadsgalaxy/wiki/mw-config/index.php(40): wfInstallerMain()

#20 {main}

BlueSpice 4 is using Media Wiki 1.35.6

I have tried manually updating the extension, but I'm still getting this error. I'm fairly new to all of this, so I'm trying to figure out how to get passed this.

My PHP is Version 7.4 if that helps.

Antdragone (talkcontribs)

What's strange is that this only happens at;


When I access the wiki, everything loads perfectly normal, and I can use the site without issue, and when I check Special:Version, UserFunction is marked as loaded.

Antdragone (talkcontribs)

I can't say exactly what fixed it, but I tried a code branch I found here;


That fixed the error I was experiencing.

I did have to change

if ( isset( (int)$wgUFAllowedNamespaces[$cur_ns] ) ) {


if ( null !== ( (int)$wgUFAllowedNamespaces[$cur_ns] ) ) {

in UserFunctions_body.php

So, hopefully this is useful for anyone trying to run BlueSpice 4.

Reply to "MagicWord.php: Error: invalid magic word 'ifanon'"

How to show ifingroup in VisualEditor?

Stefahn (talkcontribs)

We use ifingroup for several reasons. One is to not show content to visitors as long as an article is in draft mode. However in the VisualEditor all ifingroup statements show up as a puzzle icon. See https://pasteboard.co/I4ckujT4MShA.png for a screenshot.

Is there any way to show the content of ifingroup in the VisualEditor so that it can be edited? At least to the corresponding user group?

To edit the content in the (very small) puzzle pop up is not an option for us.

Reply to "How to show ifingroup in VisualEditor?"

Some troubles on some namespaces

FrViPofm (talkcontribs)

Hi, In a local wiki (witch will be moved on the web later) I've found a way to display in infoboxes shortway links to technical pages according to the current namespace (e.g. special:All Categories|Templates|Properties...). Very handful ! those links are in a template in a #ifsysop condition. It works well in several namespaces : main, template, category, help (ns: 12)... and not in some : Property (from Semantic Mediawiki, ns: 102), Reference (ns: 3010) in spite of configuration at the end of LocalSetting.php like :

$wgUFAllowedNamespaces[SMW_NS_PROPERTY] = true; // ns: 102 or : $wgUFAllowedNamespaces[102 ] = true; // ns: 102 SMW_NS_PROPERTY

(the namespace numbers are checked with the special:AllPages : when choosing a namespace, the corresponding number is shown in the url) In those case, the "{{#ifsysop:" ... "|}}" code is displayed as not interpreted by the parser.

Anny hint ? How to enable UserFunctions in extention and custom namespaces ?


mw: 1.36.1 php: 7.4.22 smw: 3.2.3 userfunction: 2.8.0 (talkcontribs)

It seems that $wgUFAllowedNamespaces is overwritten in MediaWiki due to the usage of array_merge and it's "Values in the input arrays with numeric keys will be renumbered with incrementing keys starting from zero in the result array".

Reply to "Some troubles on some namespaces"
GregRundlett (talkcontribs)

From the $IP of my mediawiki installation, running composer test fails with a message originating from UserFunctions:

This file is a MediaWiki extension, it is not a valid entry point

Is there a way to exclude the offending file (./extensions/UserFunctions/UserFunctions.php); or is there a technique that would make this file compatible with composer test?

Note: This is using the REL_1_35 branch with

Product Version
MediaWiki 1.35.4 (87ad58f)

14:19, 22 October 2021

PHP 7.4.24 (apache2handler)
MariaDB 10.4.21-MariaDB-log
ICU 67.1
Elasticsearch 6.7.2

If I checkout 'master' of UserFunctions, I get "This version of the UserFunctions extension requires MediaWiki 1.35+" from the same file.

Reply to "Composer test fails"
Adrianzlobinski (talkcontribs)

When I upgrade to MW 1.35 get error on Parser::disableCache. Looking on forum and found https://www.mediawiki.org/wiki/Topic:Vj94nk4mug1yfn1t

So i repleced '$parser->disableCache();' to '$parser->getOutput()->updateCacheExpiry(0);' in UserFunctions_body.php and it works.

Reply to "Upgrading to MW 1.35"
Seppl2013 (talkcontribs)

This extension used to work nicely with my MW 1.27.3 - after upgrading to 1.31.7 the realname Parser function hook seems to not be activated any more. What can i do about this?

Reply to "Upgrading to MW 1.31.7"
ClemFlip (talkcontribs)

Hi Guys, We, at Dokit, need to create a parsing function to check if the logged-in user has/hasn't a specific permission. So we suggest to develop a new feature in your UserFunctions extension to do that. Something like :


What do you think? We can develop it and ask for a merge request if you like the idea. Best, Clément

Kghbln (talkcontribs)
Reply to "Suggesting new feature"

User Functions stops Auto Create Category Pages

7 (talkcontribs)


For unknown reason, while I'm using User Functions on my MediaWiki (checked on 1.28.2 and 1.31.0) the Auto Create Category Pages extension don't work. It seems to happen in every configuration I'm trying to do for the User Functions extension.

The problem happens not only on pages who has {{#ifsysop:}} (the only command I need from the extension), but all over the mediawiki, even when User Functions Allowed only on MediaWiki namespace.

I've tried to figure it out but it is simply way over my abilities..

Does anyone met this problem before?

FreedomFighterSparrow (talkcontribs)

I'm the maintainer of AutoCreateCategoryPages; I just installed UserFunctions on my wiki and AutoCreateCategoryPages still worked fine for me. Can you tell me the following to help me test?

  1. MediaWiki version
  2. AutoCreateCategoryPages version/branch
  3. UserFunctions version/branch
  4. Do you see a specific error message, or are category pages just not created?
  5. If you disable UserFunctions, does AutoCreateCategoryPages immediately work?

Thanks! (talkcontribs)

Hi, Thanks a lot for the fast responsive..

I've tested the situation on two different systems, because I'm planning to move my mediawiki as soon as this problem will be solved. Therefor, I'll have 2 answers for your questions :)

My MediaWiki version is 1.28.2 (tested also on 1.31.0 which I'm planning to be moved for)

AutoCreateCategoryPages version is 1.0.1 (tested also on 1.0.3)

UserFunction version is 2.7.0

I don't get any massage, and I've noticed that the whole functions of category doesn't work. What I mean is that once UserFunction is installed, as well as the AutoCreateCategoryPages which don't create pages, also other functions as adding a page into existing category doesn't work... Once I remove the UserFunctions from LocalSettings the MediaWiki starts doing the magic...

Thanks Again

FreedomFighterSparrow (talkcontribs)

So far I could find nothing new. In all my testing both extensions worked. Do you have any new information?

As an aside, please make sure to use v1.0.3 - it queries the DB much more efficiently than v1.0.1. (talkcontribs)

By the time, seems the problem has solved, somehow. Thanks A-lot!

FreedomFighterSparrow (talkcontribs)

Glad to hear it! Let's hope for no repeats :-)

This post was hidden by FreedomFighterSparrow (history)
Reply to "User Functions stops Auto Create Category Pages"

Call to a member function getNamespace() on a non-object in UserFunctions.php:69

Uckelman (talkcontribs)

I'm seeing this error with MW 1.21 and UserFunctions 2.4.2:

PHP Fatal error: Call to a member function getNamespace() on a non-object in /usr/share/mediawiki/extensions/UserFunctions/UserFunctions.php on line 69

It looks like what's failing is this:

$cur_ns = RequestContext::getMain()->getTitle()->getNamespace();

Apparently getTitle() is not returning an object.

Uckelman (talkcontribs)

Here's a patch which fixes the bug.

--- a/mediawiki/extensions/UserFunctions/UserFunctions.php
+++ b/mediawiki/extensions/UserFunctions/UserFunctions.php
@@ -66,7 +66,8 @@ function wfRegisterUserFunctions( $parser ) {
        $special = false;
        // Initialize NS
-       $cur_ns = RequestContext::getMain()->getTitle()->getNamespace();
+       $title = RequestContext::getMain()->getTitle();
+       $cur_ns = $title === null ? -1 : $title->getNamespace();
        if ( $cur_ns == -1 ) {
                $special = true;
        } (talkcontribs)

This post is Old but al try to assist you guys experiencing this error. What happens is that when the response from the SoapCall is returned it fails to get captured with the simplexml_load_string so a workaround to assist you those facing this problem. First capture the response in an xml $request = file_put_contents('response.xml',$data); Then load the xml captured using simplexml_load_file the trick is ordinary xml will get captured but an xml response with namespaces has to be treated differently this is how i managed to sort out the issue in php

Reply to "Call to a member function getNamespace() on a non-object in UserFunctions.php:69"

Is it possible to use not in group?

1 (talkcontribs)

I would like to hide the edit tab if a user is not in a group

Reply to "Is it possible to use not in group?"