Page MenuHomePhabricator

When using preview, the edit link and protection status is lost in "Template used in this preview"
Closed, ResolvedPublic5 Estimated Story Points

Description

When using Realtime Preview and Live preview, the templates listed at "Template used in this preview" at the bottom of the page lose the edit link and protection status on the right
See screenshot:

Screenshot 2022-10-18 at 15-10-37 Editing REVISIONTIMESTAMP test_1 - Test Wikipedia.png (204×440 px, 8 KB)

Event Timeline

Shizhao renamed this task from When using preview, the edit link is lost in "Template used in this preview" to When using preview, the edit link and protection status is lost in "Template used in this preview".Oct 18 2022, 7:24 AM
Shizhao updated the task description. (Show Details)

One issue with this is that the existing edit link says 'edit' or 'show source' as appropriate given the current user's rights. To do this in live preview I think will require a separate API call to find out if the templates are editable. That's not too bad is it?

Change 844318 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Dynamically update template list for live preview

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

This comment was removed by Shizhao.

Change 844318 merged by jenkins-bot:

[mediawiki/core@master] Dynamically update template list for live preview

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

@Samwilson I got a (⧼restriction-level-templateeditor⧽) when I went to RTP. It was (template editor protected) before as seen in the screenshots below.

Test link: https://en.wikipedia.beta.wmflabs.org/w/index.php?title=T327354:Real-time_preview_(and_live_preview)_don%E2%80%99t_highlight_redirects_in_italic;_Bug_Report&action=edit
OS: macOS 13.0
Browser: Chrome 109

RTP

T321032_RTP_Beta_W:Preview.png (1×1 px, 399 KB)

No RTP

T321032_RTP_Beta_NonPreview.png (1×1 px, 373 KB)

Good catch, thanks! This is because the restriction-level-templateeditor message is not available on the front end, so needs to be loaded separately.

Dom pointed out another issue here (from T327354#8620988):

@Samwilson I am getting errors when I have a lot of templates on a page. I think due to the length of the URL/number of titles when making the API request to look up page protections.

For example:

We can fix the 414 error by POSTing the prop=info call, but we'll also need to handle multiple calls when the number of templates is over 50/500.

Change 890226 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Template list in previews: Look up missing restriction level messages

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

在T321032#8620480中,@Samwilson写道:

Good catch, thanks! This is because the restriction-level-templateeditor message is not available on the front end, so needs to be loaded separately.

In zhwiki, “MediaWiki:Template-protected” message displayed as wikitext when previewing, not parsed as HTML. Seems to be the same problem?

Screenshot 2023-03-03 at 10-49-40 编辑“Template Tracked” - 维基百科,自由的百科全书.png (472×838 px, 62 KB)

In zhwiki, “MediaWiki:Template-protected” message displayed as wikitext when previewing, not parsed as HTML. Seems to be the same problem?

Good catch, I've updated the above patch to also fix that.

Change 890226 merged by jenkins-bot:

[mediawiki/core@master] Template list in previews: Look up missing restriction level messages

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

@Samwilson I have found a few articles on production with over 500 templates (List_of_protected_areas_of_South_Africa, Shanghai, Foreign_relations_of_Taiwan). Should we limit and paginate the request to handle this? Otherwise RTP/Live preview won't show newly added templates in the list.

@dom_walden Thanks, those are useful examples. I think you're right, it should be paginated. For most cases, there will only be one page required, so it won't be any worse performance.

Change 901329 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Live preview: batch requests for template list with max 500 titles

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

Test wiki on Patch demo by Shizhao using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/7a50bbe023/w/

Change 901329 merged by jenkins-bot:

[mediawiki/core@master] page.preview: batch requests for template list with max 50 titles

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

@Samwilson Please see the following below.

在T321032#8620480中,@Samwilson写道:

Good catch, thanks! This is because the restriction-level-templateeditor message is not available on the front end, so needs to be loaded separately.

In zhwiki, “MediaWiki:Template-protected” message displayed as wikitext when previewing, not parsed as HTML. Seems to be the same problem?

Screenshot 2023-03-03 at 10-49-40 编辑“Template Tracked” - 维基百科,自由的百科全书.png (472×838 px, 62 KB)

Test link: https://zh.wikipedia.org/w/index.php?title=%E6%A2%85%E5%84%92%E7%91%9E&action=edit

T321032_RTP_ZHTemplate.png (1×1 px, 392 KB)

Dom pointed out another issue here (from T327354#8620988):

@Samwilson I am getting errors when I have a lot of templates on a page. I think due to the length of the URL/number of titles when making the API request to look up page protections.

For example:

We can fix the 414 error by POSTing the prop=info call, but we'll also need to handle multiple calls when the number of templates is over 50/500.

The links above do not get those errors anymore but if the speed to load is fine for https://en.wikipedia.beta.wmflabs.org/wiki/TemplateUsageArticle678 with you, then I can move this to Done.

Thanks!

The links above do not get those errors anymore but if the speed to load is fine for https://en.wikipedia.beta.wmflabs.org/wiki/TemplateUsageArticle678 with you, then I can move this to Done.

I think a large number of templates like on that page will likely always be slow. We can revisit if need be, but for now I'd say it's okay.

@Samwilson Since this ticket is regarding "Template used in this preview", I created T334518: Hidden Categories below the templates in edit isn't greyed out while loading since the "This page is a member of a hidden category:" dropdown is not greyed during loading. I will move this ticket to "Done" though. Thanks for everyone's help!

Test link: https://en.wikipedia.beta.wmflabs.org/wiki/TemplateUsageArticle678

GMikesell-WMF moved this task from QA 🐛 to Done 🏁 on the Community-Tech (CommTech-Kanban) board.

As mentioned from above.

Why is T334518 the parent task? Did you mean the other way around?