? Pending

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
18 Jan 2016

Description

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.

How to test

  1. Install patch
  2. Check javascript is working properly.

Observations

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.

avatar andrepereiradasilva andrepereiradasilva - open - 18 Jan 2016
avatar andrepereiradasilva andrepereiradasilva - change - 18 Jan 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 18 Jan 2016
Labels Added: ?
avatar andrepereiradasilva
andrepereiradasilva - comment - 18 Jan 2016

@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?

avatar Fedik
Fedik - comment - 19 Jan 2016

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 :smile:

avatar andrepereiradasilva
andrepereiradasilva - comment - 19 Jan 2016

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.

avatar Fedik
Fedik - comment - 19 Jan 2016

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

avatar andrepereiradasilva
andrepereiradasilva - comment - 19 Jan 2016

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

avatar Fedik
Fedik - comment - 19 Jan 2016

hm you are right I forgot about false

avatar andrepereiradasilva
andrepereiradasilva - comment - 19 Jan 2016

Well, as you can see is not as easy as the deprecated message says JHtml::getJSObject is deprecated. Use json_encode instead. :wink:

avatar Fedik
Fedik - comment - 19 Jan 2016

I tried to fix some there #6357 see behavior.js ... but that pull request is different topic

avatar brianteeman brianteeman - change - 20 Jan 2016
Category Code style
avatar anibalsanchez anibalsanchez - test_item - 5 Feb 2016 - Tested successfully
avatar anibalsanchez
anibalsanchez - comment - 5 Feb 2016

I have tested this item :white_check_mark: successfully on f122263

Test OK


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8935.

avatar andrepereiradasilva
andrepereiradasilva - comment - 12 Mar 2016

I will close this as that is yet no pure alternative to JHtml::getJSObject as comments above.

avatar andrepereiradasilva andrepereiradasilva - change - 12 Mar 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-03-12 15:01:59
Closed_By andrepereiradasilva
avatar andrepereiradasilva andrepereiradasilva - close - 12 Mar 2016

Add a Comment

Login with GitHub to post a comment