-
Notifications
You must be signed in to change notification settings - Fork 84
"First arg must be a non empty string!" exception when deleting on cascade #122
Comments
Sorry, I was wrong when I tried to guess where the problem was. protected function _afterDeleteFile(Event $event) {
$this->_handleLegacyEvent($event);
$afterDeleteEvent = new Event('FileStorage.afterDeleteFile', $this, [
'entity' => $event->result,
'adapter' => $this->storageAdapter($event->result['adapter'])
]);
EventManager::instance()->dispatch($afterDeleteEvent);
} with this: protected function _afterDeleteFile(Event $event) {
$this->_handleLegacyEvent($event);
$afterDeleteEvent = new Event('FileStorage.afterDeleteFile', $this, [
// use passed entity here...
'entity' => $event->data['entity'],
'adapter' => $this->storageAdapter($event->data['entity']->adapter)
]);
EventManager::instance()->dispatch($afterDeleteEvent);
} And now it works for me. |
Hey, sorry for the delay but I'm very busy this week with work and private stuff. I'll review this in detail when I have the time. I understand the problem and see the fix but I need to review it more deeply and see if this doesn't have any side effects. |
I'm not sure if it is related to this bug, but I've noted that even when the files are deleted correctly, the container folders are not. So I end up with a lot of empty nested folders. Is this the way it is supposed to work? |
I'm aware of that but never gave it a priority because it doesn't hurt. The problem is you need to know if the file resides alone on this folder or not to delete the folder without accidentally deleting other files. The default config is that it should use one folder at the end of the nested path for each file which is using the uuid as name. But if you configure it different you can end up with many files in the same folder. |
@choma please try 1.1-dev I've fixed the code in the 1.1 branch. |
Nope! 'adapter' => $this->storageAdapter($event->data['entity']->adapter) There is where the bug is in fact, sorry if wasn't clear in my previous comments. |
No problem, I've made the change. Any reason you didn't do the change yourself and created a pull request? |
I'm sorry I didn't. I'm still trying to understand the code, I'm not sure how the change will affect the rest of it. And I never learned to do php tests, so I'm not sure how to handle them. Thanks for the great plugin! |
Welcome, I'm glad you like it. Let me know if you need something else. I can't admit that the plugin isn't the most easy one to use but I think it is the most powerful on with the best architecture. And I keep improving it. 2.0 will drop a lot of legacy code and make things more easy. I'm not happy with the image processing right now, it's still to tight coupled and interwoven with the storage related code. |
I'm having a "First arg must be a non empty string!" exception when trying to delete a post and its associated image on cascade.
I'm using cakephp v3.2.1, with cakephp-file-storage v1.1.4 and cakephp-imagine-plugin v2.1.1
As I understand the problem is here. It is trying to read
$event->result['adapter']
, but$event->result
is equal totrue
(I'm not sure, but I think that value comes from here)Here is my current configuration:
Table classes:
and
The controllers and templates are baked, and I'm using the posts/delete action to delete posts (and images on cascade).
Here is the full error log message:
The text was updated successfully, but these errors were encountered: