User tests: Successful: Unsuccessful:
This PR removes deprecated getJSObject (used for javascript).
This removes a lot of deprecated messages from Joomla core.
#8935, #8925 and #8932 removes most of deprecated log messages in Joomla core.
getJSObject
has some more operations than just json_encode (see https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/html/html.php#L1064-L1109), but the deprecated message just says: JHtml::getJSObject is deprecated. Use json_encode instead.
I tried to just replace one by another and most convertions didn't work (they throw javascript errors) because the json also saves the null values, so i had to strip the null values from the arrays before using json_encode.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
json_encode(array_filter($opt, 'strlen'))
should be enough,
but I would not bother with this deprecated stuff, because I would trash whole thing here
i understand that.
But IMHO, if you want developers to follow Joomla! core and remove deprecated calls, Joomla! core should lead by example.
The way it is now we have a LOT of Joomla core deprecated calls (some pages have more than 300!!). So the way it is, is very difficult to find the deprecated calls of developer extensions, which leaves the log console almost useless, and also very slow (because of the call stack sliders from #8899).
With that in mind, i made this 3 PR to reduce around 90% of Joomla! core deprecated calls that appear in the log console.
I mean behavior.php part,
also be aware, stuff like this array('x' => '\\jQuery(window).width() - 80', 'y' => '\\jQuery(window).height() - 80');
will not work with json_encode
json_encode(array_filter($opt, 'strlen'))
should be enough,
That removes NULL
, FALSE
and Empty Strings but leaves 0
(zero) values.
We just want to remove NULL
right?
Check http://php.net/manual/en/function.array-filter.php#111091
hm you are right I forgot about false
Well, as you can see is not as easy as the deprecated message says JHtml::getJSObject is deprecated. Use json_encode instead.
Category | ⇒ | Code style |
I have tested this item successfully on f122263
Test OK
I will close this as that is yet no pure alternative to JHtml::getJSObject as comments above.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-03-12 15:01:59 |
Closed_By | ⇒ | andrepereiradasilva |
@Fedik since you deprecated the getJSObject (in d5dbf90) do you think this is the best way to do this? Or did you had other idea in mind?