Extension talk:UserFunctions

About this board

composer/installers 2.2.* support

1
MarB-96 (talkcontribs)

This is a duplicate of htt ps://phabricator. wikimedia.org/T343009 since it turned out that phabricator is the wrong place for this. I have to cripple the links with spaces, because I may not send them here.


Hello!

I tried to install many extensions with composer, but a few times I ran into a few issues, this one is about the requirement of composer v1.

Many other extensions depend on composer v2, so installing them together is not possible.

This can be changed like in this commit in a fork of mine: htt ps://github .com/markus-96/mediawiki-extensions-UserFunctions/commit/06fec0c8fb3e27650c10731b00efe8f321791d82

Or like this: htt ps://gerrit.wikimedia. org/r/c/mediawiki/extensions/PageForms/+/942478/

That resolves the same issue in the PageForms extension: htt ps://phabricator. wikimedia.org/T340818

Reply to "composer/installers 2.2.* support"
Summary by GregRundlett

The failure was related to a poorly structured composer.json which automatically loaded the 'php entry point' file all the time - even when running scripts like PHPCS which wouldn't have a defined "MediaWiki". Fixed in the most current branch (and possibly in the REL1_35 branch). There is no PHP entry point file anymore, and the class code is in a new file.

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.

Cavila (talkcontribs)

Your issue appears to have been fixed with this commit, although I'm not sure if the necessary commits are included in the REL_1_35 branch.

It's a highly annoying issue though, which I ran into myself and made it impossible for me to continue using Composer until I dug into the /vendor/composer folder and manually deleted a couple of lines from various autoload files - not usually the way to go, but Composer got stuck.

GregRundlett (talkcontribs)

Interesting, I think I took the same approach as you - manually inspecting/editing the autoload of Composer. It looks like the UserFunctions extension has gotten some recent love ❤️


Nice!

Adding a #displaydate function?

1
Yaron Koren (talkcontribs)

It would be great to have a parser function that takes in a date string - or a date/time - and then displays it based on the user's preferences: "1 January 2023", "January 1, 2023", etc. (If a time is included, there are even more options.) There are various ways to implement such a thing (maybe it should even be two parser functions), but before we get to any of the specifics: is that something that it would make sense to add to UserFunctions?

Reply to "Adding a #displaydate function?"

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

3
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'

Backtrace:

#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;

mw-config/index.php?page=ExistingWiki

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;

https://github.com/Universal-Omega/mediawiki-extensions-UserFunctions

That fixed the error I was experiencing.


I did have to change

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

to

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?

1
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

2
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 ?

Thanks

mw: 1.36.1 php: 7.4.22 smw: 3.2.3 userfunction: 2.8.0

83.255.155.133 (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"
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"

Upgrading to MW 1.31.7

1
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"

Suggesting new feature

2
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 :

{{#ifhaspermission:edit|then|else}}

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
213.57.135.184 (talkcontribs)

Hello,

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!

213.57.135.184 (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.

5.28.166.54 (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"