Page MenuHomePhabricator

Can't dismiss banners on mobile due to $.toJSON not being defined
Closed, ResolvedPublic

Description

On my local machine, the hideBanner() function doesn't work in mobile because it throws the following JS error:

$.toJSON is not a function

in BannerController:
$.cookie(

'centralnotice_hide_' + mw.centralNotice.data.category,
$.toJSON( cookieVal ),
{ expires: d, path: '/' }

);

I'm not sure why $.toJSON isn't working on mobile, but it's deprecated anyway and is going to be removed from core in MW 1.25. You should use JSON.stringify instead.


Version: unspecified
Severity: major

Details

Reference
bz68064

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:34 AM
bzimport set Reference to bz68064.
bzimport added a subscriber: Unknown Object (MLST).

mwalker wrote:

According to Krinkle we do polyfill the JSON object on IE6/7 -- which was the reason we used the jQuery version.

If $.toJSON is undefined you forgot to declare a dependency on jquery.json.

In other news, jquery.json and its $.toJSON are deprecated. Use module 'json' and JSON.stringify instead.

There's a 'json' module that should be able to handle that. See resources/lib/json2/json2.js in core.

Change 146591 had a related patch set uploaded by Kaldari:
Adding missing jquery.json depenency needed for dismissing banners

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

Change 146591 merged by jenkins-bot:
Adding missing jquery.json depenency needed for dismissing banners

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

Change 146599 had a related patch set uploaded by Ejegg:
Adding missing jquery.json depenency needed for dismissing banners

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

Change 146599 merged by Ejegg:
Adding missing jquery.json depenency needed for dismissing banners

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

All patches merged - assuming this bug is FIXED.
If that is not the case: Please reopen and elaborate what is left to do here to get this report fixed.