Respond with valid JS/CSS on redirects when using action=raw&ctype=text/css or action=raw&ctype=text/javascript
OpenPublic

Description

This is a followup for bug 30074.

I think it would be better if the result of using "action=raw&ctype=text/javascript" or "action=raw&ctype=text/css" were changed to output nothing (or just an informative comment) if the target page is a redirect. This way the users who import a page which was moved will not have broken scripts and stylesheets.

Would that be feasible by some change similar to r94155 ?


Version: unspecified
Severity: normal
URL: https://en.wikipedia.org/w/index.php?title=MediaWiki:Sysop.css&diff=prev&oldid=456378679
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=34930

bzimport added a project: MediaWiki-Redirects.Via ConduitNov 21 2014, 11:56 PM
bzimport added a subscriber: Unknown Object (MLST).
bzimport set Reference to bz31827.
He7d3r created this task.Via LegacyOct 19 2011, 7:38 PM
brion added a comment.Via ConduitOct 19 2011, 10:12 PM

I'm pretty sure that would still by definition break their scripts/styles by removing them...?

He7d3r added a comment.Via ConduitOct 19 2011, 10:30 PM

At least it wouldn't cause syntax errors as currently happens, breaking other scripts as well.

brion added a comment.Via ConduitOct 19 2011, 10:33 PM

Syntax errors shouldn't be breaking other scripts unless they're being bundled together in ResourceLoader and somebody disabled the JS validity checks.

If they're coming from action=raw, then they're not going through ResourceLoader's bundling at all -- so a failure should only halt execution of that script, not any others.

An error message on your JS console will however alert you to the presence of an error, won't it? Seems like it would be useful for helping people to find their broken scripts.

He7d3r added a comment.Via ConduitOct 19 2011, 11:18 PM

(In reply to comment #2)

...breaking other scripts as well.

Er.. I just checked this with a code like the following on my /common.js

mw.loader.load( 'http://localhost/mw18/index.php?title=MediaWiki:Test1.js&action=raw&ctype=text/javascript' );
mw.loader.load( 'http://localhost/mw18/index.php?title=MediaWiki:Test2.js&action=raw&ctype=text/javascript' );

and then moving "MediaWiki:Test1.js" to another name. As you explained, this didn't break "MediaWiki:Test2.js", so never mind...

waldyrious added a comment.Via ConduitDec 5 2011, 12:11 PM

(In reply to comment #1)

I'm pretty sure that would still by definition break their scripts/styles by
removing them...?

Why not actually making redirects work in css and js pages? Is there anything that makes this fundamentally more complicated than other cases? By now we're using redirects for pages, images, templates, and it all works seamlessly.

He7d3r added a comment.Via ConduitJan 26 2012, 8:15 PM

(In reply to comment #5)

Why not actually making redirects work in css and js pages? Is there anything
that makes this fundamentally more complicated than other cases? By now we're
using redirects for pages, images, templates, and it all works seamlessly.

+1.

I've openned bug 33973 requesting that.

Krinkle added a comment.Via ConduitJul 22 2012, 3:03 AM

Example urls:

(In reply to comment #5)

(In reply to comment #1)
> I'm pretty sure that would still by definition break their scripts/styles by
> removing them...?

Why not actually making redirects work in css and js pages? Is there anything
that makes this fundamentally more complicated than other cases? By now we're
using redirects for pages, images, templates, and it all works seamlessly.

Because contrary to all of the above, CSS and javascript are not Wiki-specific objects. They are native scripts interpreted by the browser - while at the same time being an ordinary wikipage that should be editable, watchable, and... redirectable (when viewing normally).

I've wontfixed bug 33973 (see reason there), and re-opening this one.

We should make action=raw respond with valid CSS or JavaScript when requesting ctype=text/css or ctype=text/javascript on a redirect. Just like we used to do for non-existent ones (by reponding with HTTP 200 OK; Content: /* Empty */; - instead of HTTP 404 Not Found).

For redirects we can do something like HTTP 200 OK: Content: /* Redirect */

It is important that this only happens for those content types. In other cases it should respond with the original wikitext as expected, as other wise it could break bots and scripts.

He7d3r added a comment.Via ConduitJul 22 2012, 7:13 PM

(In reply to comment #7)

For redirects we can do something like HTTP 200 OK: Content: /* Redirect */

In that case, make sure the "Redirect" text is in site language (as in bug 28937).

Add Comment