Extension talk:PageAuthors

About this board

Summary by Sophivorus

The names of the authors are cached and the database won't be queried again until the page is changed or purged.

צמא לדעת (talkcontribs)

Hi,

I'm just wondering: is the information cached, or will this extension add some DB queries every time a page calling it is loaded?

Thanks!

Sophivorus (talkcontribs)

The information is cached.

Summary by Sophivorus

Seems a local issue and user stopped replying.

Stefahn (talkcontribs)

First of all thanks for your good work and the helpful extension!

I have a strange thing going on: On one of my wikis the extension works fine, on the other it doesn't generate any output. I don't see any error messages in the console nor in php_errors.log. On my test install with $wgShowExceptionDetails = true; $wgShowDBErrorBacktrace = true; there is no error either.

Both the working and the not working wiki run with MW 1.35.7 and PageAuthors 1.4 (f63a4b4). The two wikis are different in terms of installed extensions and different versions (for example SMW). Could another extension interfere with PageAuthors?

Maybe you have another hint that is causing the issue?

Sophivorus (talkcontribs)

Hi! Maybe no one that edited the page you're viewing qualifies as an author? In other words, no one reaches the default criteria (or the criteria you configured) for being an author? This often happens with test pages with placeholder text, or the main page of a new wiki where the only author is a system user that gets ignored by the default config.

Stefahn (talkcontribs)

Hi. Thanks for your quick reply. I also tested it on big pages that have 10 authors and hundreds of edits, still no luck.

I used the extension Contributors before and I deleted the SQL table "Contributors" manually. Could that interfere with PageAuthors?

I still have the extension ContributionsScores running. I disabled it for testing but still no output from PageAuthors.

Maybe I can run some database cleanup?

Could I somehow debug my issue?

Sophivorus (talkcontribs)

Hm, none of that should affect the list of page authors. Can you share a link to a page containing the {{PAGEAUTHORS}} call that should definitely return something but doesn't? Also are you using the default config? If not, could you share your config? Thanks!

Stefahn (talkcontribs)

Thanks for your reply. I use the default config - I have no line except wfLoadExtension.

Here's a page that was heavily edited. See "Authors" above the yellow box towards the bottom of the page: https://secret-wiki.de/wiki/Empathie

Sophivorus (talkcontribs)

Hi, I'm a bit baffled by this bug. Perhaps it's something about that particular page? Did you try other pages? Could you create a test page and simulate a few edits that should definitely produce an author list? Perhaps the cause of the error is that secret-wiki.de is using MySQL 5.7.28 while marketingunited.org is using MySQL 8.0.25 (appropedia.org uses MariaDB 10.3.35)? But MediaWiki supports MySQL 5.7.28 and this extension just uses selectFieldValues and other standard methods to query the database, so it should work... Can you add the code below to the LocalSettings.php of secret-wiki.de, then visit https://secret-wiki.de/wiki/Empathie?debug=1 and let me know of any clues?

$debug = $_GET['debug'] ?? false;
if ( $debug ) {
	error_reporting( E_ALL );
	ini_set( 'display_errors', 1 );
	$wgShowSQLErrors = true;
	$wgShowExceptionDetails = true;
	$wgDebugToolbar = true;
	$wgDevelopmentWarnings = true;
}

We'll get to the bottom of this!

Stefahn (talkcontribs)

Thanks a lot for diving into this!

I added the debugging code. It throws some deprecated warning because I don't use wfLoadExtension for some extensions. Do you think this could cause the problem?

Regarding MySQL: On my test install for secret-wiki.de I already upgraded to MySQL 8. But this didn't change things.

Already tried it on other pages too, yes.

Is there any way to clean up database trash? Maybe something is wrong with some tables...

Sophivorus (talkcontribs)

Hmm, the only table this extension consults is the core revision table, so I doubt this is a database trash issue, and in any case I wouldn't know how to clean that up. Try editing https://secret-wiki.de/wiki/Empathie, replace everything for just {{PAGEAUTHORS}} and then preview the changes, to rule out that some other element in the page is causing conflict. Then, try editing the main PageAuthors.php file and replace each "continue;" statement for "return 1;", "return 2;" etc. This could give us a clue of what conditional is falsely firing.

Stefahn (talkcontribs)

Thanks for your efforts, much appreciated! I did everything you suggested but there was still no output at all.

I also added <code>echo "Something";</code> within the function <code>getPageAuthors</code> but this was not printed too. So it seems the function is not called at all?

I not only tried it in preview mode, but also with saving the page.

Another information: When adding ?debug=1 I also get this warning by the way:

A ParserGetVariableValueSwitch hook handler bypassed the cache, this is deprecated since MediaWiki 1.35 in
/html/website/mediawiki/includes/debug/MWDebug.php
on line 430
Sophivorus (talkcontribs)

Hmm! Could you try adding return 1; to the very beginning of getPageAuthors? This is to make sure it isn't firing, because using echo like you did is not definitive. Then, could you try adding {{PAGEAUTHORS:{{FULLPAGENAME}}}} to the page? This is to see if the problem is with the PAGEAUTHORS magic word only, or with the PAGEAUTHORS parser function too. Thanks again, this is a tricky bug!!

Stefahn (talkcontribs)

We're making progress. {{PAGEAUTHORS:{{FULLPAGENAME}}}} is working fine. At least when I remove the return statements. If I let it run with return, it goes into the conditional if ( $wgPageAuthorsIgnoreMinorEdits && $revision->isMinor() ). But that might be not a problem.

{{PAGEAUTHORS}} itself still doesn't output anything at all. Also if I add a return directly below <?php there is no output of that number.

Does that help?

Sophivorus (talkcontribs)

Hmm! Why is the PAGEAUTHORS magic word not returning anything? It seems to be recognizing the magic word, else MediaWiki would treat PAGEAUTHORS as a non-existent template and show a red link. Adding a return statement below <?php won't work (you can try adding echo 1; exit; instead) but in any case we're sure the file is loading because the PAGEAUTHORS parser function works fine. I double checked the code of the extension against the patterns at Manual:Variable and elsewhere and everything looks super ok. Furthermore, the extension works at Appropedia and even at your other wiki, so it seems a local issue. I checked your installed extensions and none seems able to cause a conflict. Perhaps it's related to MediaWiki's variable cache system? Try adding echo $ret; exit; right before the return statement of onParserGetVariableValueSwitch to rule out this possibility. Meanwhile, I guess you can use {{PAGEAUTHORS:{{FULLPAGENAME}}}} for your purposes!

Summary by Sophivorus

Version 1.4+ introduces config options for showing the full name and for linking to the user pages (see documentation).

For more advanced behavior, use Extension:Arrays (or the {{#arraymap:}} parser function of Extension:PageForms) plus the {{REALNAME:}} parser function of Extension:MyVariables.

InnerCitadel (talkcontribs)

@Sophivorus Thanks for sharing this extension. Is there any way to configure it to show the "Real name" value of the User?

Sophivorus (talkcontribs)

@InnerCitadel Hi! Not really but on appropedia.org what I do is use the {{#arraymap:}} parser function of Extension:PageForms (or you could use Extension:Arrays too) plus the {{REALNAME:}} parser function of Extension:MyVariables to show the real name when available. It may seem a bit complicated but the upside is that you have full control of what to do if the user doesn't have a real name, or if the user doesn't have a user page, etc. See https://www.appropedia.org/Template:databox/name?action=edit for the code of my current approach. Finally, I may end up adding the functionality you mention to this extension, but not today. I'll let you know if I do. Cheers!

Sophivorus (talkcontribs)

As promised, I'm letting you know that I just added a configuration option to show the real names, and another to link to the user pages. Cheers!

Summary last edited by Devaroo 01:14, 11 August 2022 1 year ago

Fixed in version 1.3+

Devaroo (talkcontribs)

Hi Felipe!

I just installed version 1.2 of your PageAuthors extention in order to fix the "call to undefined method" error (reported a few weeks ago), which appears to have been successfully solved. However, now I get the following error message:

"A ParserGetVariableValueSwitch hook handler bypassed the cache, this is deprecated since MediaWiki 1.35. In /mediawiki/en-gb/includes/debug/MWDebug.php on line 377."

Software version information:

Installed software

Product Version
MediaWiki 1.38.0
PHP 7.3.33-nmm2 (fpm-fcgi)
MariaDB 10.5.16-MariaDB-1:10.5.16+maria~focal-log
ICU 66.1
Lua 5.1.5
Pygments 2.11.2

Installed skins

Skin Version License Description Authors
Tweeki 2.0.1 GPL-2.0-or-later A skin based on Bootstrap Tobias Haider

Besides the error, the extension seems to work as intended. Thanks for bringing us this nice, simple and useful extension!! I look forward to seeing it do its thing in the future :)

Cheers,

Devaroo

Sophivorus (talkcontribs)

Thanks for the report! This should be fixed now in version 1.3+, but please reopen and let me know if it isn't!

Devaroo (talkcontribs)

Wow that was fast! Just re--opening to say the new version seems to have fixed the issue, the error message has disappeared and everything works like a charm. ¡Muchas gracias!

Call to undefined method MediaWiki\User\UserIdentityValue::isSystemUser()

5
Summary by Sophivorus

Fixed in version 1.2+

AdamMillerchip (talkcontribs)

When attempting to preview a page after adding {{PAGEAUTHORS}} on MW 1.37.2 the UI displays the following error: Fatal exception of type "Error". I'm currently trying to see if I can get a better error from the logs.

I'm not sure if this is a problem with this extension or MediaWiki.

AdamMillerchip (talkcontribs)

Here's a stacktrace:

[exception] [YnEax3VZBTnpsbdGF5gDiwAAACg] index.php?title=Test&action=submit   Error: Call to undefined method MediaWiki\User\UserIdentityValue::isSystemUser()
#0 /extensions/PageAuthors/PageAuthors.php(37): PageAuthors::getPageAuthors(Parser)
#1 /includes/HookContainer/HookContainer.php(338): PageAuthors::onParserGetVariableValueSwitch(Parser, array, string, NULL, PPFrame_Hash)
#2 /includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#3 /includes/HookContainer/HookRunner.php(2898): MediaWiki\HookContainer\HookContainer->run(string, array)
#4 /includes/parser/Parser.php(2830): MediaWiki\HookContainer\HookRunner->onParserGetVariableValueSwitch(Parser, array, string, NULL, PPFrame_Hash)
#5 /includes/parser/Parser.php(3053): Parser->expandMagicVariable(string, PPFrame_Hash)
#6 /includes/parser/PPFrame_Hash.php(273): Parser->braceSubstitution(array, PPFrame_Hash)
#7 /includes/parser/Parser.php(2930): PPFrame_Hash->expand(PPNode_Hash_Tree, integer)
#8 /includes/parser/Parser.php(1598): Parser->replaceVariables(string)
#9 /includes/parser/Parser.php(656): Parser->internalParse(string)
#10 /includes/content/WikitextContent.php(327): Parser->parse(string, Title, ParserOptions, boolean, boolean, NULL)
#11 /includes/content/AbstractContent.php(548): WikitextContent->fillParserOutput(Title, NULL, ParserOptions, boolean, ParserOutput)
#12 /includes/EditPage.php(4214): AbstractContent->getParserOutput(Title, NULL, ParserOptions)
#13 /includes/EditPage.php(4117): EditPage->doPreviewParse(WikitextContent)
#14 /includes/EditPage.php(2895): EditPage->getPreviewText()
#15 /includes/EditPage.php(722): EditPage->showEditForm()
#16 /includes/actions/EditAction.php(71): EditPage->edit()
#17 /includes/actions/SubmitAction.php(38): EditAction->show()
#18 /includes/MediaWiki.php(543): SubmitAction->show()
#19 /includes/MediaWiki.php(320): MediaWiki->performAction(Article, Title)
#20 /includes/MediaWiki.php(930): MediaWiki->performRequest()
#21 /includes/MediaWiki.php(564): MediaWiki->main()
#22 /index.php(53): MediaWiki->run()
#23 /index.php(46): wfIndexMain()
#24 {main}
AdamMillerchip (talkcontribs)

Just reproduced this on Mediawiki 1.38.2

My knowledge of PHP is not really good enough to diagnose further. Have confirmed that there is indeed no isSystemUser method on the UserIdentityValue class. There is one on User though.

This post was hidden by AdamMillerchip (history)
AdamMillerchip (talkcontribs)

I got it working by adding a lookup of the User object. I'm not sure if that's a reasonable solution though.

$revisionUserIdentity = $revision->getUser();
$revisionUser = $userFactory->newFromId($revisionUserIdentity->getId());
There are no older topics