Page MenuHomePhabricator

Previewing a Page: page appends unwanted newlines to each section
Closed, ResolvedPublicBUG REPORT

Description

This bug was first reported in Janurary 2019 at English Scriptorium

If a page is previewed multiple times, you can end up with large amounts of whitespace at the bottom, which is annoying. This didn't used to happen either.

I looked over the changes to ProofreadPage before then and these looked like they might be relevant, but IDK:

Steps to Reproduce:

  • go to a page in the Page: namespace e.g. https://en.wikisource.org/wiki/Page:Sandbox.djvu/9
  • edit it using the source editor (I have not check if this is a problem also in VE)
  • remove all trailing whitespace from the header, body and footer
  • preview the page
  • observe, a newline has been appended to each section (this should not happen)
  • preview again
  • observe, extra newlines have again been added to the body and the footer
  • remove the extra newlines and click "show changes"
  • note newlines have again been appended
  • remove the newlines, make a non-whitespace change and save
  • edit the again, and note the appended newlines

Event Timeline

@WMDE-Fisch Doesn't this just hide the problem? These newlines are coming from somewhere, and I can't think of a valid reason for them, so the root cause really should be fixed imo.

Incidentally, anywhere you add such things it'd be really helpful for others reading the code after the fact if there was a comment explaining why non-obvious stuff like the rtrim() is there. If it's a workaround for a given Phab, then just something like "// rtrim() is needed to work around T 241889".

@WMDE-Fisch Doesn't this just hide the problem? These newlines are coming from somewhere, and I can't think of a valid reason for them, so the root cause really should be fixed imo.

Incidentally, anywhere you add such things it'd be really helpful for others reading the code after the fact if there was a comment explaining why non-obvious stuff like the rtrim() is there. If it's a workaround for a given Phab, then just something like "// rtrim() is needed to work around T 241889".

You're right, this needs more explanation. I very briefly tried to do that in the patch commit message, but it should probably also be in the code ( and I could extend the commit message):

All textboxes used on the edit page ( and also the three textboxes used by ProofreadPage [0] ) are build with the EditPage::showTextbox() method [1]. That method will add an "extra" empty line to the end of text in the editor[2]. As mentioned in the patch commit message this is done for convenience. Afaik it's assumed that it feels better to expand a text in a textbox at the bottom if there's an empty line you can start putting your cursor in to start writing.

This "artificial" empty line must at least be removed again when working with the text later. Furthermore it conceptually does not make sense to allow empty lines at the end of an article text ( and also not at the end of the header main or footer sections in ProofreadPage ) I would say. So even if there would be no "artificial" empty line make sense to trim any empty lines added by the user.

But like I've said the trimming should probably be done in a more transparent explanatory way. I'll see what I can do and what makes most sense. Thanks for your feedback here. :-)

[0] https://gerrit.wikimedia.org/g/mediawiki/extensions/ProofreadPage/+/d74f0ca26746492ddac0f1eefadab2ffb6db91c7/includes/Page/EditPagePage.php#142
[1] https://gerrit.wikimedia.org/g/mediawiki/core/+/f7f069936752d0c97d6266a6976a731bf3952ec4/includes/EditPage.php#3504
[2] https://gerrit.wikimedia.org/g/mediawiki/core/+/f7f069936752d0c97d6266a6976a731bf3952ec4/includes/EditPage.php#3514

The patch that solves the problem described in T245154: Edit conflicts in the page namspace show unintended newlines in footer diff got merged and was deployed to All-and-every-Wikisource yesterday. Could you please check if the issues is fixed now? Thanks! :-)

@WMDE-Fisch I tested it on a couple of pages where I have seen the issue before, and I do not see it now. I will post to the Scriptorium and let them know so that the whole community can test.

PS I think this ticket is a duplicate of T188844 ?

After testing, this appears to be resolved.

Tpt assigned this task to WMDE-Fisch.

Fixed according to @beleg_tal