#1328 Posted in ‘Econa’

Latest post by Oliver Rockwell on Monday, 10 March 2025 15:07 EET

Oliver Rockwell

Hello Lefteris,

We've stumbled on an odd case where our editors try to do a 'Save as Copy' and encounter an error which than causes Econa to copy the entire JPATH_SITE to a new images/econa/'.$fieldName.'/'.$itemId.  I believe the error is in one of our own extensions but the Econa FieldTrait class doesn't seem to do proper data validation in this case.  I am having trouble recreating the scenario where this happens but even so the massive copy is not making our sys admin very happy.

this is the code block is in the FiledTrait afterSave method that seems to create the problem

// Handle copy
if ($itemId && $itemId != $item->id) {

$path = $this->getImagePath($field->name, $item->id);

$sourceFolder = JPATH_SITE.'/'.$data['com_fields'][$field->name]['path'];
$targetFolder = JPATH_SITE.'/'.$path;

if (Folder::exists($sourceFolder)) {
Folder::copy($sourceFolder, $targetFolder);
}
}

if $data['com_fields'][$field->name]['path'] is not set properly this will cause the whole JPATH_SITE tree to copy to $targetFolder. I noticed that above this block is a much tighter way of grabbing the $path

$path = isset($data['com_fields'][$field->name]['path']) && $data['com_fields'][$field->name]['path'] ? $data['com_fields'][$field->name]['path'] : $this->getImagePath($field->name, $item->id);

using the same approach could yield something safer if i understand the issue properly.

$sourcePath = isset($data['com_fields'][$field->name]['path']) && $data['com_fields'][$field->name]['path'] ? $data['com_fields'][$field->name]['path'] : $this->getImagePath($field->name, $itemId);
$targetPath
= $this->getImagePath($field->name, $item->id);

$sourceFolder = JPATH_SITE.'/'.$sourcePath;
$targetFolder = JPATH_SITE.'/'.$targetPath;

Since, again, I'm having trouble recreating this issue in my IDE I've only been able to test this by manually breaking the incoming $data values.

Let me know if I'm incorrect in how this outlier case should be handled.

Thanks,

Oliver



Lefteris Kavadas

Hi Oliver,

Thanks for the detailed report.

From the code you shared, it looks like you’re using an older version of Econa. This specific issue was addressed in version 2.1.3, as noted in the release notes:

Econa 2.1.3 Release Notes

Since that release, we haven’t received any further reports of this behavior, so it appears the issue has been resolved. I’d recommend updating to the latest version of Econa and checking if that eliminates the problem on your end.

If the issue persists after the update, feel free to get back to me and I’ll be happy to look into it further.

 

Best regards

Oliver Rockwell

Lefteris,

I've been so busy with J5 issues since we switched over 10 days ago that I did not even see the Econa upgrade from November.

Sorry about that!  

Thanks for the quick response.  I will resolve.

Oliver

Note: An active subscription is required in order to get support for our paid extensions. For our free extensions, if you don't have an account, register and then submit your support request.  In case you just want to ask a question, you can also use the contact form .

Firecoders
Are you using our extensions? Please post a review at the Joomla extensions directory!
Post a review