Last modified: 2014-06-19 16:57:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T64982, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 62982 - mw.html Scribunto library methods such as css, cssText and attr should not generate errors when passed a nil value
mw.html Scribunto library methods such as css, cssText and attr should not ge...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
unspecified
All All
: Unprioritized normal with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-03-23 15:17 UTC by hlmzgy
Modified: 2014-06-19 16:57 UTC (History)
9 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description hlmzgy 2014-03-23 15:17:52 UTC
After inserting the nil argument to cssText() function in the HTML library, an exception "Invalid CSS Given: Must be Either a string or a number." is thrown. Strangely, this bug is not present in the [[:en:Module:HtmlBuilder]] (cf. [//en.wikipedia.org/w/index.php?title=Module:HtmlBuilder/testcases&diff=600781294&oldid=573508575 testcases]).
Comment 1 Andre Klapper 2014-03-23 17:56:08 UTC
Is there a minimal, self-contained testcase for this?
Comment 2 Brad Jorsch 2014-03-24 16:14:33 UTC
Note that [[:en:Module:HtmlBuilder]] doesn't do a lot of error checking that it probably should. I'm inclined to say that this error is entirely appropriate (and therefore this bug INVALID), since nil is not valid CSS.
Comment 3 Marius Hoch 2014-03-24 16:19:33 UTC
This is expected behavior which we built in on purpose. You should check your arguments before passing them.
Comment 4 Jackmcbarn 2014-04-21 12:03:40 UTC
When a user passes a nil value specifically, the intended (and useful) behavior would be a no-op, to avoid filling code with "if(foo.bar) baz:cssText(foo.bar) end" constructs. See https://en.wikipedia.org/wiki/Module_talk:Message_box#Protected_edit_request_on_9_April_2014 for more. I don't see any benefit in throwing an error rather than a no-op in this case.
Comment 5 Jackmcbarn 2014-04-21 18:20:43 UTC
Why was this re-WONTFIXed?
Comment 6 Marius Hoch 2014-04-21 20:03:58 UTC
Because "This is expected behavior": nil is not a valid css string!
Comment 7 Jackmcbarn 2014-04-21 20:37:40 UTC
That doesn't make it expected. For nil, expected behavior is a no-op, just like ordinarily appending a nil element to a table is.
Comment 8 Mr. Stradivarius 2014-04-22 02:07:17 UTC
(In reply to Jackmcbarn from comment #7)
> That doesn't make it expected. For nil, expected behavior is a no-op, just
> like ordinarily appending a nil element to a table is.

Agreed - not silently accepting nil feels unexpected, mostly because it kills call-chaining. (Personally I would also like false values to be silently ignored, as it makes it easier to use the "and" and "or" operators when call-chaining, but I can understand if others feel this is too permissive.)
Comment 9 Marius Hoch 2014-04-22 11:23:27 UTC
I guess I can be made to agree with such changes if there is a wider consensus for such things AND if all mw.html functions act in a consistent manner. It's not acceptable that some take nil values etc. while others don't.
Comment 10 Mr. Stradivarius 2014-04-22 12:11:50 UTC
Yes, I meant to say that this should work consistently across all the mw.html methods, not just cssText. I've changed the summary of this bug accordingly. Also, I'll start a discussion on enwiki's Lua project page to get some more opinions.
Comment 11 Mr. Stradivarius 2014-04-22 14:42:42 UTC
Discussion link: [[Wikipedia talk:Lua#mw.html library nil behaviour]].
Comment 12 Ricordisamoa 2014-04-23 22:07:23 UTC
Would anyone support a configuration flag?
It could be set as `mw.html.acceptNilCSS = false`
I would suggest keeping it `true` by default, just for the sake of call chaining, but it could also be set for a single element only, as:
`el = mw.html.create('div'); el.acceptNilCSS = false`
Just in those cases the library will throw an error, otherwise it won't do anything.
Comment 13 Jackmcbarn 2014-04-23 22:48:31 UTC
That seems like unnecessary complexity. What's the benefit?
Comment 14 Ricordisamoa 2014-04-23 23:43:05 UTC
(In reply to Jackmcbarn from comment #13)
> That seems like unnecessary complexity. What's the benefit?

I would rather support comment #0, but not everyone agrees...
Comment 15 Ricordisamoa 2014-04-23 23:44:03 UTC
(In reply to Ricordisamoa from comment #14)
> I would rather support comment #0, but not everyone agrees...

comment #7, of course.
Comment 16 Jackmcbarn 2014-06-05 14:21:58 UTC
*** Bug 66166 has been marked as a duplicate of this bug. ***
Comment 17 Gerrit Notification Bot 2014-06-05 15:01:37 UTC
Change 137659 had a related patch set uploaded by Jackmcbarn:
Allow passing nils to mw.html

https://gerrit.wikimedia.org/r/137659
Comment 18 Gerrit Notification Bot 2014-06-19 16:57:04 UTC
Change 137659 merged by jenkins-bot:
Allow passing nils to mw.html

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links