Page MenuHomePhabricator

CSS error should be displayed while trying to save, not only when previewing
Closed, ResolvedPublic

Description

When you create a CSS page which contains syntax errors (e.g. a missing bracket or RGBA-color code (T265675)), you cannot save the page.

This may be expected behavior (even if it is problematic for false positive like T265675), however a warning should explain what is problematic.

In order to see the warning, you have to preview. It seems to be a regression (since the warning used to be displayed while saving according to T190114).

Event Timeline

Tgr added a subscriber: Tgr.

Displaying parser errors is a MediaWiki core feature so this is probably not TemplateStyles specific. It uses Content::prepareSave so maybe there was a regression in how that's handled? Other things that rely on it include ProofreadPage, Jade, Wikibase, Scribunto, Wikilambda, so maybe someone could cross-check whether some of those work.

I was hitting warnings in editing user CSS sheets just the other day (lots of 'are you sure at least', not sure if it was a 2-step process off the cuff). I think it may possibly be just TStyles/sanitized CSS...?

TemplateStyles uses Content::prepareSave to reject invalid CSS; if you try to save it, you get an error (much like how you cannot save invalid Lua code). There is no such thing for user CSS - it's not sanitized, it's not parsed, any string is valid. (ResourceLoader might error out when you try to use it, not sure how that would go, but nothing prevents saving it.)

CodeEditor has its own JS-based linter which might warn you about saving invalid CSS (as long as you have JS enabled, the wiki has CodeEditor installed, and the linter agrees with css-sanitizer on what is considered valid).

I assumed this task was about the former, as it shows errors on preview (and, theoretically, save) while the latter gives feedback in real time.

I assumed this task was about the former, as it shows errors on preview (and, theoretically, save) while the latter gives feedback in real time.

Indeed, I tried to reproduce T265675: CodeEditor do not warn (because the syntax is correct) and no error message is displayed: you can’t save, but you don’t know why (until you show preview).

Seems this is resolved somehow.

In order to see the warning, you have to preview.

I am seeing the warning without previewing. (The one for previewing is still there though, and styled differently)

Warning Warning shown for PublishWarning shown for Preview
Screen Shot 2021-10-22 at 12.52.38 PM.png (448×1 px, 56 KB)
Screen Shot 2021-10-22 at 12.53.00 PM.png (560×1 px, 74 KB)

Yes, I confirm I can’t reproduce anymore.