Page MenuHomePhabricator

Detect the edit state for modules which help users and helpers
Closed, InvalidPublic

Description

Central modules can help users and helpers in some ways:

  • detect errors on arguments names or arguments values
  • report versions management
  • in user and wiki languages
  • display synthesis or tests for helpers, even in small wikis

But all these services must not disturb the simple readers.

Then the modules need the edit state to use specials modes only if edit is active.

See examples and the draft proposition of Central modules.

Details

Reference
bz51660

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:48 AM
bzimport set Reference to bz51660.
bzimport added a subscriber: Unknown Object (MLST).

Hi Rical,
unfortunately this report is not very useful because it does not describe the problem well. If you have time and can still reproduce the problem, please read https://www.mediawiki.org/wiki/How_to_report_a_bug and add a more useful description to this report, by providing good steps to reproduce, a minimal testcase, actual outcome, and expected outcome. Thanks!

In complex templates, users can use bad arguments names, or mistake about the value of a century, and so on.
Scribunto permit to detect these errors to assist the user.
This is a new service to users, at Lua level.
The module https://test2.wikipedia.org/wiki/Module:Auteur
can display messages like :
⦁ Error: Wikidata element is not found.
⦁ Error: This argument is required but absent : initiale. Should define it.
⦁ Error: The parameter BirthYear is unknown in this template. The known argument birthyear is it the one you need ?
⦁ Error: The life of the author is too long.
These messages are usefull when a user modify the page, but must disappear for simple readers.
To hide messages, the module must know if the page is in edit state.
I search some hours and ask in some places, but I don't find how to detect the edit state and nobody answers.

I am sory, I changed the state to normal, but now I correct by revert it to enhancement.

This bug is not only about data from Wikidata. It's about any edit in any wiki. The result is a value that a scribunto module can read to adapt its work in the edit state of the page. The module must display error messages only in edit mode.

If someone cares enough about this to actually implement it, it should be easy enough to do along the lines of Gerrit change 93019, using $this->getParser()->getOptions()->getIsPreview(). And you could as well throw in access to $this->getParser()->getOptions()->getIsSectionPreview() too.

Personally, though, I don't really see the point of modules changing their output based on whether it's a preview or not.

I think it would be a bad idea to allow the previewed version of a page to look different from what it will save to. It could confuse users who see a bunch of changes when they just make one little one, not to mention the field day vandals could have with it.

(In reply to Jackmcbarn from comment #6)

I think it would be a bad idea to allow the previewed version of a page to
look different from what it will save to.

1 - Each time a user edit any page in any wiki, he sees some alert panels. The module:Auteur do the same one alert panel, just before the normal output.

2 - The goal of the info "edit-state" is exactly to permit to automatic mask this panel to not disturb simple readers, without the risk to keep the panel.

3 - Without the info "edit-state" and the automatic masking, the editing user can forget to mask the panel, which is not so easy. Then the module must catégorize the page to help admins to correct the page and mask the panel.

Okay, a few new things to consider:

  • It's already possible to see if a page is being previewed by looking at {{REVISIONID}}. (I'm not sure this is a good thing, but it's true).
  • Some issues are severe enough that they should be displayed even if the page is saved, like a missing required template parameter.
  • In your use case, you say that the purpose is to keep readers from being confused if the page is saved with errors still in it. However, this would lead to the next editor being confused, since they'd have no idea why errors suddenly appeared when they made some unrelated change.
Lydia_Pintscher removed a subscriber: Unknown Object (MLST).

I think this is not Wikidata-specific. @Lydia_Pintscher?

It's not Wikidata specific (at all), but I guess it concerns us as our Lua functions also throw errors...

Rical renamed this task from Detect the edit state to adapt help messages to user errors to Detect the edit state for modules which help users and helpers.May 23 2016, 4:51 PM
Rical updated the task description. (Show Details)

I seen your work in gerrit. return '' seems a good way. Big thanks @aaron.

Izno closed this task as Invalid.EditedDec 23 2020, 2:58 PM
Izno subscribed.

I'm going to close this invalid. Detecting whether a page is being previewed, the sensible case for this, is already supported in wikitext and in Lua. If you need the exact syntax for Lua, see https://en.wikipedia.org/wiki/Template:If_preview or search for REVISIONID in module namespace (I do not know the wikitext version offhand). My understanding is that this method of detecting preview will continue to be supported.

It is not obvious to me if other edit states need warnings. If they do, please feel free to reopen and clearly layout how and why. (Particularly, perhaps in the edit without preview state it would be nice to provide a warning; that is a very hard problem not likely to be solved any time soon but otherwise a valid task.)