Page MenuHomePhabricator

Edit preview doesn't let you preview cite.php footnotes.
Closed, ResolvedPublic

Description

At present, if a section or article being edited does not contain the <references /> tag, then footnotes will not show up in page preview. This means you have to commit the edit, then examine the new saved page and re-edit instead.

Enhancement request -- if the page being rendered for preview contains cite.php footnotes, AND there is no <references /> tag in the previewed text that will cause footnotes to be displayed, then the preview code adds a horizontal line followed by <references /> after the existing text, so that users can see their proposed footnotes too.

Event Timeline

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

titoxd.wikimedia wrote:

Would adding <references/> to [[MediaWiki:Edittools]] accomplish the same thing?

contactbox wrote:

If the text to be rendered in preview is the whole
article, or certain sections, it might contain the
</references> tag already, in which case you don't
want to render it twice. So you have to check and
only add it if it won't be rendered as-is.

Example pathological cases to check for:

<nowiki><references /></nowiki>
<references /> tag included in a template
<ref> ... </ref> or <ref /> in a template

etc.

So you have to check in coding it, whether the
text as-is includes any renderable cite.php refs,
and whether in preview, the text will include a
rendered <references /> section if so.

contactbox wrote:

Afterthought...

I don't mean you have to "trial render". Rather I
mean, you have to have a way to flag during
rendering, whether a <ref> was rendered and
whether a <references /> was rendered. Possibly an
elegant solution might be that the call to the
render engine has a parameter "
AutoAddReferencesSection", set to TRUE for preview
and FALSE elsewhere, that adds a terminal <
references> section if it is needed, before
returning the rendered text.

But as Im not a coder, that may be a very naive
approach. I don't know how helpful that is.

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

rene.kijewski wrote:

I don't think using JavaScript is a proper solution.
Maybe it would be possible to give a preview in the “Templates used in this section”-section?

svippy wrote:

JavaScript certainly do not seem like a solution to this.

Though, personally, I do not consider this a problem. While editing, you might just add the <references/> tag at the bottom of the section, then preview it, see if those cites are all right, and move on.

You may obviously run into problems when you are reusing cites from earlier (or later) in the article, which are not declared in this section and thus <references/> will not know what to do, except tell you that it does not exist.

This sounds like a revisit of the entire article for this purpose to fulfil itself, which sort of renders the whole feat of using section editing fruitless. I would call this a simple issue you that should just work around. There seems to be no perfect solution. Also, isn't this an issue with the Cite extension rather than with MediaWiki itself?

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

RSYQFIOJGWZA wrote:

(In reply to comment #7)

Also, isn't this an issue with the Cite extension rather than with MediaWiki itself?

The "Component" is currently set to "Cite".

RSYQFIOJGWZA wrote:

There are two more javascript solutions mentioned at http://en.wikipedia.org/wiki/MediaWiki_talk:Edittools#References as follows (with absolute URLs):
The userscript at user:js/ajaxPreview http://en.wikipedia.org/wiki/User:Js/ajaxPreview provides a <references /> preview when editing sections. Possibly the code there, or someone at its talkpage, could help here? HTH. -- Quiddity (talk) 21:16, 9 August 2010 (UTC)
If you really care about references, user:Anomie/ajaxpreview.js http://en.wikipedia.org/wiki/User:Anomie/ajaxpreview.js does much more, it even checks for named references from other sections. Of course, JavaScript solutions have nothing to do with Edittols. — AlexSm 22:03, 9 August 2010 (UTC)

gfitzger wrote:

Seems to me a fairly simple way to solve this would be to include a "Preview Full Article" link, either for all previews or just section-edit previews.

ayg wrote:

Adding extra links is a bad solution to practically any problem. It would be better to just output the references automatically in section edits if there otherwise aren't any.

RSYQFIOJGWZA wrote:

(In reply to comment #12)

It would be
better to just output the references automatically in section edits if there
otherwise aren't any.

Yes, it would. Better still would be to:

  1. not limit that automatic output to section edits, but instead automatically *output* a references section (if there are ref tags but no references section) for the whole page or section (while displaying an existing page or section, to cover up the problem with existing pages) - we already have detection logic for this in the parser;
  2. and automatically *add* a references section (if there are ref tags but no references section) for the whole page to the wikitext (while editing, to fix the problem with existing pages).

An ambitious bot, set of bots, or database correction could automatically *add* a references section (if there are ref tags but no references section) for the whole page to the wikitext for every page in every project of every organization that uses this extension to fix the problem with existing pages, given approval by the developers of those projects.

(In reply to comment #13)

and automatically *add* a references section (if there are ref tags but no

references section) for the whole page to the wikitext (while editing, to fix
the problem with existing pages).

How exactly would that be done? What name would that section have? Where would that section go? What about references with group parameter?

On enwiki, {{references}} is usually used instead of <references />, the section name is either “Notes” or “References” and the section goes before the External links section.

I don't think logic should be implemented in MediaWiki, especially since consensus about those things can change and other wikis have other customs. And according to the text at [[Category:Pages with missing references list]], AWB already fixes this and at least enwiki has a bot that fixes those errors.

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

fredgandt wrote:

Comment in general support for this functionality. For reference (no pun intended), a discussion/proposal on en:WP is here --> [[Wikipedia:Village_pump_(proposals)#Reflist_should_be_shown_when_previewing_a_section_edit]] (first comment for me on Bugzilla and no preview, please excuse if messy).

s.vanslyck wrote:

When editing a section the footnote text never appears, at least not if the {{references}} or <references /> is not within that section. Suggest this bug be restated as

"Enhancement request -- If the page OR SECTION being rendered for preview contains cite or php footnotes, then the preview code should add a
horizontal line followed by <references /> after the existing text, so that
users can see their proposed footnotes and examine potential errors without having to commit the edit."

This was brought up again at [[Wikipedia:Village_pump_(proposals)#Auto_reflist_when_previewing_whilst_section_editing]], FWIW.

(In reply to Steve from comment #17)

When editing a section the footnote text never appears, at least not if the
{{references}} or <references /> is not within that section. Suggest this
bug be restated as

"Enhancement request -- If the page OR SECTION being rendered for preview
contains cite or php footnotes, then the preview code should add a
horizontal line followed by <references /> after the existing text, so that
users can see their proposed footnotes and examine potential errors without
having to commit the edit."

I think it would probably sound better if you drop the "page" part.

Also, I don't think you can modify the Description in Bugzilla, only the Summary, so you'd need something much snappier, like "Section edit preview doesn't show cite.php footnotes". (https://bugzilla.wikimedia.org/docs/en/html/bug_page.html doesn't even mention the *existence* of the Description.)

Also, note that I find this quite annoying, too, and I'd be perfectly content if only the refs actually present in the section are actually included. If it's not in the section I'm editing, I can't possibly screw the reference itself up; the worst that could happen is that I do <ref name=... /> with the wrong name.

Can't a collapsed by default section at the bottom of an edit page be added that shows all of the references for the section being edited? https://en.wikipedia.org/wiki/Wikipedia:Village_pump_%28idea_lab%29#Section_editing_reflinks_idea is why I'm bumping this thread. I would think that if whole page references are really wanted, that could also be accomplished as well, and I can think of a detailed output method that I think would work great (although I could see others as disagreeing with me).

Change 129932 had a related patch set uploaded by Gerrit Patch Uploader:
Add reference list to section preview if missing

https://gerrit.wikimedia.org/r/129932

Change 129932 abandoned by Legoktm:
Add reference list to section preview if missing

https://gerrit.wikimedia.org/r/129932

wp.makyen wrote:

The abandonment of https://gerrit.wikimedia.org/r/129932 without explanation implies that the fix for https://bugzilla.wikimedia.org/show_bug.cgi?id=66860 solves this issue. Based on testing, the fix for that bug does not show references in section previews.

I can understand that [https://gerrit.wikimedia.org/r/129932 129932] might be incompatible with [https://gerrit.wikimedia.org/r/#/c/141583/ 141583]. However, if that is the reason for abandonment, then please say so. It is also unclear to me that abandonment would be the appropriate course of action if the issue was incompatibility with [https://gerrit.wikimedia.org/r/#/c/141583/ 141583]. In my opinion, the more appropriate course of action would have been to indicate the incompatibility and make additional updates to [https://gerrit.wikimedia.org/r/129932 129932].

Because of the lack of explanation, I am just guessing here as to the reason for the request to abandon those changes. However, at least to me the request implies that [https://gerrit.wikimedia.org/r/129932 129932] is being abandoned because [https://gerrit.wikimedia.org/r/#/c/141583/ 141583] fixes this issue when it does not.

Since the patch is abandoned, I am changing the status to NEW.

Change 129932 restored by TheDJ:
Add reference list to section preview if missing

Reason:
let's bring this back

https://gerrit.wikimedia.org/r/129932

Change 129932 had a related patch set uploaded (by TheDJ):
Add reference list to section preview if missing

https://gerrit.wikimedia.org/r/129932

I've updated this patch a bit. Anyone wanna try it out ?

fbstj set Security to None.

I've updated this patch a bit. Anyone wanna try it out ?

I've given it a shot.

@Cenarium looks better already I think. The only thing is that you will still have errors for groups though.. And if we were to meddle there, i'm not really sure if that would break caching.

Does the Patch also work if a ref isn't defined (with name=) in the section you see in preview, but anywhere else in the article, for example in an other section or within <references</references>?

Change 129932 merged by jenkins-bot:
Add reference list to section preview if missing

https://gerrit.wikimedia.org/r/129932

Does the Patch also work if a ref isn't defined (with name=) in the section you see in preview, but anywhere else in the article, for example in an other section or within <references</references>?

If an undefined named reference appears in the previewed section, an explanatory warning is shown in the generated references "<ref> tag with name $1 cannot be previewed because it is defined outside the current section or not defined at all".

matmarex edited projects, added User-notice; removed Patch-For-Review.
matmarex edited subscribers, added: matmarex; removed: wikibugs-l-list.

I don't think this bug is resolved completely. Yes, the basic functionality works well and as expected (thank you really muich for that!), but the behaivor if the reference is defined outside the section edited is quite disappointing. (this basically are two cases:

  1. defined inside <references></references>
  2. defined anywhere else outside the section that is edited

Is there a simple possibility to fix the issue to provide the full functionality?

@MGChecker no not a simple possibility. You cannot know what is inside 'the rest of the page', without parsing the whole page. And after you parsed the whole page, you wouldn't know where to 'cut' the page again to give only the fragment back to the user. This is one of the reasons why VE doesn't do 'section editing' in the same way as wikitext does section editing.

I'm not a coder, but I think it could work if MediaWiki tries to find the necessary definitions in the saved page (with some background proceess, so you don't have to cut later) and load the Definitions in the preview. But I wouldn't be surprised if this isn't so trivial as I think.

I'm not a coder, but I think it could work if MediaWiki tries to find the necessary definitions in the saved page (with some background proceess, so you don't have to cut later) and load the Definitions in the preview. But I wouldn't be surprised if this isn't so trivial as I think.

Inspired by Tim Starling's suggestion in T124379, and by T123290, I've been thinking about storing the references in wikitext form in page_props, so they can be retrieved in section preview. But on some pages, these references amount to more than 64KB of wikitext, too much for page_props...

@Cenarium, I think such an approach would be a nice general solution, but I don't think page_props is particularly suited for this purpose. Perhaps a memcached backed cache + restbase api in front of it ?

And even then, in the context of section editing, how would you deal with the problem of synchronizing the pre and post edited version of it ?

I've split any remaining functionality requests into: T124840: Section edit preview doesn't let you preview references defined outside the section being previewed

The German-Community-Wishlist and TCB-Team can decide if they want to pull that ticket into the purview of their projects.

To all who had (and are still having) part in fixing these problems, there have already been several thank you notes on my talk page for the developers who worked on this:
https://en.wikipedia.org/wiki/User_talk:TheDJ#Reference_Preview