Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MediaBundle]: check if file exists #1396

Merged
merged 1 commit into from
Dec 9, 2016
Merged

[MediaBundle]: check if file exists #1396

merged 1 commit into from
Dec 9, 2016

Conversation

sandergo90
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Fixed tickets

When deleting a file that no longer exists on the filesystem you will get an error that the file does not exists. This check will verify that the file exists on the filesystem and will not do the rename action when it does not exists. This way the delete process can continue.

@@ -80,7 +80,7 @@ public function preUpdate(PreUpdateEventArgs $eventArgs)
if ($deleted || $reverted) {
$oldFileUrl = $entity->getUrl();
$newFileName = ($reverted ? $entity->getOriginalFilename() : uniqid());
$newFileUrl = dirname($oldFileUrl) . '/' . $newFileName . '.' . pathinfo($oldFileUrl, PATHINFO_EXTENSION);
$newFileUrl = dirname($oldFileUrl).'/'.$newFileName.'.'.pathinfo($oldFileUrl, PATHINFO_EXTENSION);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we are changing code style fort dot operand wrapping? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that's the coding standard ;)

Add a single space around binary operators (==, &&, ...), with the exception of the concatenation (.) operator;

if ($handler->fileSystem->has($originalFileName)) {
$handler->fileSystem->rename(
$originalFileName,
preg_replace('~^'.preg_quote($handler->mediaPath, '~').'~', '/', $url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code duplication

Remove duplicate entries
@jockri jockri merged commit ae8702e into Kunstmaan:master Dec 9, 2016
@jockri jockri added this to the 3.6.1 milestone Dec 9, 2016
jockri pushed a commit that referenced this pull request Dec 13, 2016
* master:
  fix branch alias
  Site map view adjustments for generator bundle (#1409)
  [MediaBundle]: check if file exists (#1396)
  [Composer]: lock fos-user version (#1394)
@sandergo90 sandergo90 deleted the fix/media-delete branch July 4, 2017 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants