?
avatar brianteeman
brianteeman
6 Oct 2020

As requested I am running various test updates to J4.
One custom extension has the following code which I think might have been created by https://www.component-creator.com/

	public function __construct(&$db)
	{
		JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'GridsTablecell', array('typeAlias' => 'com_grids.cell'));
		parent::__construct('#__grid_cells', 'id', $db);
	}

This is resulting in

An error has occurred.
0 Class 'JObserverMapper' not found

I have checked the backwards compatibility issues page on the docs site and I dont see any mention of this.

I have checked the j3 code and I dont see any mention of it being deprecated or removed https://github.com/joomla/joomla-cms/tree/staging/libraries/joomla/observer

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar brianteeman brianteeman - open - 6 Oct 2020
avatar joomla-cms-bot joomla-cms-bot - change - 6 Oct 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 6 Oct 2020
avatar zero-24
zero-24 - comment - 6 Oct 2020

hmm the only thing i found is this:

The JTableObserver pattern (and corresponding classes) has been removed from JTable. JTable now triggers events and Tags, Content History (and any other custom uses of this pattern) should move to standard plugins.

https://docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_4#Table

I'm not sure why it hasn't be deprecated in the code too maybe @wilsonge knows more details here so we can get them tagged correctly.

avatar brianteeman
brianteeman - comment - 6 Oct 2020

a bit late to tag the code as deprecated isnt it?

avatar zero-24
zero-24 - comment - 6 Oct 2020

Well yes and no it is removed and I personally dont expect it is comming back so we should atleast tag it correctly. But thats why i called George to give his word on that question too.

avatar brianteeman
brianteeman - comment - 6 Oct 2020

All I can I find is
https://github.com/joomla/joomla-cms/blob/staging/libraries/classmap.php#L70-73

I can't find any deprecation notes anywhere for JTableObserver - maybe I am looking in the wrong places?

avatar zero-24
zero-24 - comment - 6 Oct 2020

Well i bet there are'nt any so it is not your foult in not finding it. That classmapper is deprecating most "J" aliases with Joomla 5.0 so i think it just was overlooked to propertly add the deprecated tag to the code.

https://github.com/joomla/joomla-cms/blob/staging/libraries/classmap.php#L70-73

Seems that got changed as a batch form 4.0 to 5.0 here: #16353

avatar brianteeman
brianteeman - comment - 6 Oct 2020

I can't even find the PR where the code was removed :( so I would have a clue what to write instead.

avatar zero-24
zero-24 - comment - 6 Oct 2020

That might be the reasone there is no deprecation tag in 3.x:

Thanks! Actually that isn't actually a PR. That was some code by Nic in the early days of pythag which I ported across to the 4 branch here. It's a good point though, because all that needs to be written up

#16299 (comment)

avatar brianteeman
brianteeman - comment - 6 Oct 2020

And it got removed and then put back in the classmap ?

avatar zero-24
zero-24 - comment - 6 Oct 2020

And it got removed and then put back in the classmap ?

No I guess the classmap was merged up from 3.x where that class was namespaced.

avatar brianteeman
brianteeman - comment - 6 Oct 2020

sorry I had so many windows open I looked in the wrong version of the classmap - at least that part is correct.

avatar wilsonge
wilsonge - comment - 7 Oct 2020

joomla-x/joomla-pythagoras#17 This was the original PR from the old J4 repo (what was then pythag). I then cherry-picked this into J4. It was literally the first commit to the J4 branch in the official repo

avatar brianteeman
brianteeman - comment - 7 Oct 2020

Anything depending on custom JTable observers. They have been superseded by the Event system.

But no explanation or even hint at how to replace this in your own code :(

avatar wilsonge
wilsonge - comment - 8 Oct 2020

Still need docs per the issue you linked to Tobias linked to in #16299 (comment)

But generally speaking you can just remove that code for J4. The JTable class now throws events so as long as all the Table methods call their parent method (for example in weblinks there was a single place where they didn't - joomla-extensions/weblinks@2247d9b#diff-8fef9122b821128ac867388496eb53b4R202)

https://github.com/joomla-extensions/weblinks/blob/4.0-dev/src/administrator/components/com_weblinks/Table/WeblinkTable.php#L43-L47

avatar brianteeman brianteeman - change - 7 Aug 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-08-07 08:20:00
Closed_By brianteeman
Labels Added: ?
Removed: ?
avatar brianteeman
brianteeman - comment - 7 Aug 2021

Closed - nothing to see here

avatar brianteeman brianteeman - close - 7 Aug 2021
avatar Aleksing
Aleksing - comment - 20 Aug 2021

Deleting the line helped me:
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'GridsTablecell', array('typeAlias' => 'com_grids.cell'));

Add a Comment

Login with GitHub to post a comment