Comments (3)
I am having the same problem with Entities having a relationship with a media entity.
If you try to remove a linked media, integrity constraint will pop and refuse to remove media, but it is too late, file has been deleted.
Then, as you said, media still exists but file doesn't, which makes unable to delete media forever (with admin interface).
Solution would be to check integrity constraint BEFORE deleting the file
from sulu.
Depending on your implementation, you may use these annotations to unlink media from your custom entity onDelete:
/**
* @Orm\OneToOne(targetEntity=Media::class)
* @Orm\JoinColumn(onDelete="SET NULL")
*/
/**
* @Orm\ManyToOne(targetEntity=Media::class)
* @Orm\JoinColumn(name="media_id", referencedColumnName="id", onDelete="SET NULL")
*/
/**
* @Orm\OneToMany(targetEntity=ExampleEntityMedia::class, mappedBy="example_entity", orphanRemoval=true, cascade={"persist", "remove"})
* @Orm\OrderBy({"position" = "ASC"})
* @Orm\JoinColumn(name="example_entity_id", referencedColumnName="id", onDelete="CASCADE")
*/
from sulu.
Wouldn't it maybe make sense to swap the deletion from the database and the file system removal. So that if the constraint gets triggered the media doesn't get deleted?
from sulu.
Related Issues (20)
- Symfony\Component\Cache\Psr16Cache is incompatible with jackalope-doctrine-dbal HOT 10
- Reference query in media does not work HOT 2
- Using Symfony tagged_iterator instead of compiler passes HOT 3
- Admin UI: Changing (logged-in) user system language has no (immediate) effect HOT 1
- Convert existing PHPUnit DataProvider to not longer use mocks HOT 1
- [BC Break] Sulu 2.6: Possible bug and/or documentation needed? How to migrate to new global blocks? HOT 21
- Symfony 7 compatibililty HOT 4
- A global block in a global block leads to 500 errors HOT 6
- Symlink not longer working on Window CMD Shell
- Migrate rest routings to default symfony routing files
- UPGRADE.md for the 2.6 release has a typo in the DDL for the new reference bundle HOT 1
- Last used webspace captures user if webspace does not exist anymore HOT 2
- Set shared_max_age: 0 / s-maxage: 0 disable whole serverside http cache HOT 1
- [Feature Request] Access currently used page localization in template HOT 2
- OpenId SSO default locale user HOT 2
- Contacts list cannot be sorted by categories
- Wrong url when copying content from one language to another (type="link") HOT 2
- [BC break v2.6] SingleSignOnLoginRequestSubscriber breaks Password reset HOT 7
- Preview for file versions from history not working HOT 1
- Custom Admin Build errors with: Module not found: Error: Can't resolve 'node:url' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sulu.