Open a category bog view and inspect the event onContentPrepare function of content plugins:
public function onContentPrepare($context, &$article, &$params, $limitstart)
It's called more than once per each article included in the category blog and it receives an unexpected JCategoryNode object as $article reference
Called once for each article included in the category blog view and receiving a stdClass object as $article parameter
Called once for each article included in the category blog view but even for each category link showed in that view thus receiving a JCategoryNode object as $article parameter. This leads to errors when a content plugin deals for example with $article->catid that is not an available property in JCategoryNode
Labels |
Added:
?
|
Ok but at least it should be document to inform developers to add to all plugins:
if($context == 'com_content.categories') {
return;
}
That's nothing new.
Plugins should always at least either check for the context they want to fire from or check the presence of the needed properties. Many should also check for the document type (eg only run on HTML).
The same thing may happen when 3rd party extensions trigger those events.
I know. There is nothing new.
BUT i found a plugin checking the context as:
preg_match('/com_content/i', $context);
now failing because content.categories is still valid but getting a JCategoryNode.
Feel free to add something to https://docs.joomla.org/Category:Version_3.7.0_FAQ but I'm not seeing a bug in core.
Tried to add a FAQ but no success, i got blocked.
This action has been automatically identified as harmful, and it has been disallowed. In addition, as a security measure, some privileges routinely granted to established accounts have been temporarily revoked from your account. A brief description of the abuse rule which your action matched is: Stupid Tricks Check
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-03-01 14:41:17 |
Closed_By | ⇒ | Bakual |
I'm closing this issue as it is a bug in a 3rd party plugin.
@joeforjoomla sorry about that must've been all the $ signs in your edit.
Thank you very much @Hutchy68
I added it here: https://docs.joomla.org/J3.x:OnContentPrepare_called_with_JCategoryNode
Not sure if you need to approve it.
IMHO, as it seems to be a bug with a 3rd party plugin, I don't think JDocs is the right place for this article as the bug seems to not be present in the Core. JDocs is not here to give fix for bugs in 3rd party extensions.
The added event call is for the category itself so it supports for example custom fields. That's not a bug.
The bug is actually in hte plugin which doesn't do proper checks.
It needs to check the passed context or presence of the catid property in ypur plugin and if it doesn't match just return.