Page MenuHomePhabricator

References are not shown to Anons when they don't have edit permissions
Closed, DeclinedPublic

Description

Author: faruq

Description:
When setting the edit permission for anonymous users to false they are not longer able to see the references, the <references/> tag just gives out a line break.


Version: unspecified
Severity: normal

Details

Reference
bz11224

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:52 PM
bzimport added a project: Cite.
bzimport set Reference to bz11224.
bzimport added a subscriber: Unknown Object (MLST).

I cannot reproduce the bug you mentioned. I restrict the edit permission and enable the Cite extensions with this code:

require_once("../extensions/Cite/Cite.php");
$wgGroupPermissions['*']['edit'] = false;

And it still shows the references for anonymous users on my local wiki.

faruq wrote:

It seems that it is the following combination which causes the problem:
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['sysop']['edit'] = true;

Cite works fine when changing one of these two values from false to true or vice versa, but in this combination it does not show the references.

Yes I confirm that bug. I traced the code and figured that on this function on Cite.php file:

function referencesFormat() {

if ( count( $this->mRefs ) == 0 )
....

The condition of that IF is met, when viewing the page as anonymous, with the settings mentioned by Tarek above, while it goes to the "else" part, when logged in. The count of $this->mRefs depends on how they are populated in functino stack(); I added a line to the begining of the function as such:

function stack( $str, $key = null ) {

if ( $key === null ) {
// No key
$this->mRefs[] = $str;
echo count( $this->mRefs ); //ADDED LINE
...

It returned "12" when logged on, and "11" when anonymous. I played with the code more, understood that mInCnt is set to zero by clearState() function, so suspected that it is called incorrectly, for anonymous users. I commented the last line of setHooks() function temporarily:

function setHooks() {

  global $wgParser, $wgHooks;
			
  $wgParser->setHook( 'ref' , array( &$this, 'ref' ) );
  $wgParser->setHook( 'references' , array( &$this, 'references' ) );

  //$wgHooks['ParserClearState'][] = array( &$this, 'clearState' );

}

To stop the effect of clearState, and voila! It fixed the bug. Surely, it is not a solution, but I'm not yet good enough with MediaWiki code to track the problem more than this and propose a real solution. I thought sharing these would help other developers to fix it faster and sooner.

lionelbrits wrote:

I have the same problem, with the same combination of user rights. However, with identical versions of cite.php, the problem doesn't seem to occur on 1.9.3, while it occurs on 1.11.0
I don't know if this is relevant.

Fixed in r36333.

For some strange reason, the Parser decided to clearState() in mid-parse, clearing Cite's state too. I've worked around this by refusing to clear state if $this->mInCite is true, but there's probably a deeper problem. For those interested in further investigation, I've attached my backtrace.

Created attachment 4989
Backtrace

Attached:

temlakos wrote:

Gentlemen:

I just noticed, on two sites that I administer, that Cite.php does not show references to anonymous users if anonymous users are blocked from editing, while registered users are allowed to edit. This has nothing to do with sysops being able to edit and everything to do with creating a user class with higher editing privileges.

The sites are:

http://creationwiki.org/
http://www.conservapedia.com/

Both of them use MediaWiki 1.12.0.

I realize that you thought you had that thing fixed. Just to make sure, I checked-out the latest version from the subversion "trunk." And still I couldn't get anonymous users to see the references. Specifically, when I log out of my sysop account, I cannot see the references, and the reference superscripts change to all 1's.

webboy wrote:

Probably strongly related to bug 13841.

jon.1234 wrote:

I exactly the same problem but downloaded r44219 today and it solves it (previously I'd been using r36333).

[The problem I had was that, while logged-in and sysop users could see citations properly, anon users could only see [1]'s and no <references> block.]

svemir wrote:

Running MediaWiki 1.13.3, non-logged-in users see the list of references correctly UNLESS there is a gallery tag BEFORE the final "references" tag on the page. Logged-in users always see the references correctly. Non-logged-in users see the list of references if there is no gallery tag on the page, or if the gallery is moved after that references tag. The problem seems to happen due to clearState being called before the list of references has been rendered.

aaronshaf wrote:

I'm running the latest SVN of both MediaWiki and Cite but I'm still having the same problem: anonymous users see the footnote numbering but not the list. Only when logged in can I see it.

(In reply to comment #10)

Running MediaWiki 1.13.3, non-logged-in users see the list of references
correctly UNLESS there is a gallery tag BEFORE the final "references" tag on
the page. Logged-in users always see the references correctly. Non-logged-in
users see the list of references if there is no gallery tag on the page, or if
the gallery is moved after that references tag. The problem seems to happen due
to clearState being called before the list of references has been rendered.

I can't reproduce this with 1.15+

*** Bug 16767 has been marked as a duplicate of this bug. ***