Closed cbleek closed 7 years ago
@kilip can you take a look at this?
@cbleek I am working on this issue now
Sorry @cbleek looks like I can't fix this issue, I don't have a good understanding with doctrine mongodb relation. Looks like this problem caused by doctrine reference issue. Organizations\Entity\OrganizationImage
entity always have null value on $organization
property, that's why the OrganizationImage::preRemove
code never executed:
/**
* Tells Doctrine to delete the image reference, if the image is deleted.
*
* @ODM\PreRemove()
*/
public function preRemove()
{
if ($org = $this->getOrganization()) {
$this->getOrganization()->setImage(null);
}
}
OK. @TiSiE can you help?
Shouldn't the listener be mentioned in our documentation? http://yawik.readthedocs.io/en/latest/modules/core/index.html#events
@cbleek @kilip Yes, I can!
Organizations do not use a single image anymore, but ImageSets instead. (That was implemented to be able to store images in different sizes like thumbnail and original).
The code quoted above is for backwards compatibility and is not used anymore for new organization entities.
The removing of references for ImageSets is done by DeleteImageSetListener, which is registered in the event manager with the key 'Core/File/Events'. (Core/module.config.php#502).
However, that listener was removed in 2a516cb350ed8b0561324cfcdb23add04ac0a127, effectively caused this issue.
@kilip is to blame here for removing the lines :stuck_out_tongue_winking_eye: , as well as myself for approving the changes :angry: . We (and by we, I mean mostly me) need to improve on pull request reviews.. :confused:
Anyway, it's working again :smile:
@cbleek probably....
@cbleek , @TiSiE
Looks like this issue still not fixed. If possible please reopen the issue and assign me to fix this issue
It WAS fixed.
However, it's broken again.
Because of the LazyControllerFactory. When creating the FileController, the wrong EventManager gets injected! Must be the 'Core/File/Events', but instead is the 'Core/Ajax/Events'.
So, I say using LazyControllerFactory MAY NOT be a good idea, especially in this case! We should always create dedicated factories. (which is the recommend way in ZF anyway.)
Still, there will be a new issue for that!
@tisie
To prevent this happening again I will create a behat feature to test this add and remove logo functionality
If the organization logo is deleted, you'll get an error like
it only happens on the ZF3 branch