? ?
avatar dgt41
dgt41
17 Oct 2016

Steps to reproduce the issue

What are the plans for JObject for joomla 4?

Expected result

Actual result

System information (as much as possible)

Additional comments

avatar dgt41 dgt41 - open - 17 Oct 2016
avatar zero-24
zero-24 - comment - 17 Oct 2016

As per deprecation notice it should be removed and replaced with stdclass

avatar zero-24
zero-24 - comment - 17 Oct 2016

But it is not a drop in replacement so ther is more work that need to be done than just removing that class

avatar dgt41
dgt41 - comment - 17 Oct 2016

that will break all xtd-buttons, which will need to be rewritten...

avatar zero-24
zero-24 - comment - 17 Oct 2016

Correct and the updater is also extending JObject

avatar mbabker
mbabker - comment - 17 Oct 2016

Anything relying on its error handling capabilities should be refactored to use native PHP 5 error handling mechanisms (as in STOP USING JError ALREADY)

Anything using it as a data store either should be replaced with stdClass or a Registry object; part of it I believe is going to depend on how the objects are used and the keys the object uses.

Native PHP doesn't allow a property named core.create, so instead of $object->core.create you have to use $object->{'core.create'}. Stuff already looking for data in object notation would probably be best suited to go from JObject to stdClass but you need to account for the key names and make changes appropriately.

Registry implements ArrayAccess so its data is accessible in array notation, but not object notation. But, it does have get/set with similar APIs as JObject. Its difference though is how the data is stored; JObject essentially creates object properties for each key whereas Registry uses an internal a key-value store.

This part answers using JObject as a data store. All of that hasn't covered using it as the base class for a lot of the API.

Anything subclassing JObject basically gets a lot of lazy magic. You don't have to declare class properties, give them proper scope, handle their access or storage, and has a bit of an error handling mechanism in place (see the long outdated JError). Using JControllerLegacy as an example, one could easily do something like JControllerLegacy::getInstance()->get('views'); to access the protected $views property and get all of the JViewLegacy objects the controller is aware of through that property. Totally legal with the existing API. A more common use of it though is in accessing the properties of a JUser object, and there have been issues reported on that object when protected property data changed yet someone was using it because it is accessible through the JObject API (the only way to block it is to privatize all your class properties). That part's going to be tricky to deal with.

avatar mbabker
mbabker - comment - 17 Oct 2016

All that to say, I very much doubt it's going anywhere in 4.0. I'd almost be willing to bet it lives into 5.0 too. Like JError, it is deeply tied into the internal APIs of a lot of base classes (MVC layer, JTable, the updater library, and JUser), and for at least the MVC layer and JTable to stop extending from it they'll either need to inline the error handling properties or fully refactor to a non-JError based handling mechanism.

avatar dgt41
dgt41 - comment - 17 Oct 2016

Thanks @mbabker!

avatar mbabker
mbabker - comment - 17 Oct 2016

Just to close off, some of the inheritance from JObject has already gone away in the 4.0 branch (JInstallerAdapter, JEditor, JAuthentication, JCaptcha, and JControllerLegacy being a few examples). The controller one will be interesting to see if it stays that way or gets reverted simply because that one potentially affects so much code; the others are more isolated classes and the odds those were being used with the JObject API is more minimal. I do intend on breaking the inheritance in JInstaller as well depending on how tight of a code coupling there is to that (I know some of the adapters make use of the JObject API to push data back to the installer, so it's a little trickier). Either way it's going to be a drawn out process.

avatar brianteeman brianteeman - change - 17 Oct 2016
Status New Discussion
avatar zero-24 zero-24 - change - 18 Oct 2016
Labels Added: ? ?
avatar zero-24 zero-24 - change - 18 Oct 2016
Labels Added: ? ?
avatar wilsonge
wilsonge - comment - 18 Oct 2016

Basically we're going to remove it as we can. But as Michael says it's unlikely we'll be able to fully remove it - especially in JTable and JModelLegacy....

avatar Fedik
Fedik - comment - 19 Oct 2016

if talk only about xtd-buttons, it simply can be replaced with Registry, without B/C, I think.

avatar brianteeman brianteeman - change - 26 Oct 2016
Labels
avatar brianteeman brianteeman - change - 26 Oct 2016
Category Libraries
avatar dgt41 dgt41 - change - 21 Mar 2017
The description was changed
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2017-03-21 18:58:27
Closed_By dgt41
Labels
avatar dgt41 dgt41 - close - 21 Mar 2017

Add a Comment

Login with GitHub to post a comment