You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Offline

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

Please create a new Ticket and we will get back to you as soon as we can.

#110479 System plugin on J4 causes issue in JCE

Posted in ‘Editor’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by jjonker on Thursday, 03 March 2022 16:59 GMT

jjonker
Hi! We have created a system plugin (Joomla 4, PHP 8.0) to manipulate the article title. We discovered that this system plgun causes issues when JCE is uploading a file. We get this error: "The server returned an invalid JSON response."

We can solve this issue by making a change to the system plugin:

function onContentBeforeSave($context, &$article, $isNew, $data)

When we remove the $data variable, there are no issues. So this $data variable is causing the upload issue.

I am not sure why this is happening. The system plugin should not affect the JCE file upl;oad. Correct?

in the Joomal docs I read this regarding the $data parameter of onContentBeforeSave:

+++++
data: The data to save. Note this data should be already validated by the extension. Since Joomla 3.7. Required to be set by extensions as of Joomla 4.0 as the core joomla content plugin uses this property
+++++

Any thoughts? Should I just leave the $data variable out or should JCE handle this differently?

Kind regards,
Jip

Ryan
JCE triggers the onContentBeforeSave and onContentAfterSave events during a JCE file upload, so that the uploaded file can be manipulated by these events if required. As the $data variable is new in Joomla 4, and is not used on the upload trigger, it is not included, which is what is causing the error. Try adding it to the function with a default value, eg:

public function onContentBeforeSave($context, $item, $isNew, $data = array())
{
    /* code */
}

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

jjonker
Hi Ryan, yes that works. But I do wonder if maybe other extensions we will be using (in the future) will also cause issues when they don't use this variable. Should every extention (like JCE) that uses onContentBeforeSave create a $data variable or should plugin creators always use $data = array() to create this data varaible when it is not passed by the extenison?

Anyway, I al leat now know how and what. The system plugin works and JCE upload also. So thanks!

Ryan
Should every extention (like JCE) that uses onContentBeforeSave create a $data variable or should plugin creators always use $data = array() to create this data varaible when it is not passed by the extenison?


Fixed in the next update.

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

jjonker
Thanks Ryan!