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

[cookbook][doctrine] The update of the entity is not secure. #5448

Closed
yceruto opened this issue Jun 26, 2015 · 1 comment
Closed

[cookbook][doctrine] The update of the entity is not secure. #5448

yceruto opened this issue Jun 26, 2015 · 1 comment
Labels
hasPR A Pull Request has already been submitted for this issue.

Comments

@yceruto
Copy link
Member

yceruto commented Jun 26, 2015

Doctrine launches the PreUpdate event when there is a change in the mapped fields of the entity. Otherwise does nothing. We agree?

Then in this case, the file field it's not a mapped field, Using the id as the Filename:

/**
 * Sets file.
 *
 * @param UploadedFile $file
 */
public function setFile(UploadedFile $file = null)
{
    $this->file = $file;
    // check if we have an old image path
    if (is_file($this->getAbsolutePath())) {
        // store the old name to delete after the update
        $this->temp = $this->getAbsolutePath();
    } else {
        $this->path = 'initial';
    }
}

when the file exists previously the condition,

if (is_file($this->getAbsolutePath())) is true

but the path field is not changed and therefore Doctrine does not detect any change in the entity and not triggers the events. (Suppose that the form has only a file field)

I think which is the goal too of the sentence,

$this->path = 'initial';

the first time.

yceruto added a commit to yceruto/symfony-docs that referenced this issue Jun 26, 2015
| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | All
| Fixed tickets | symfony#5448
@yceruto yceruto changed the title [cookbook][doctrine] The Doctrine events are not triggered. [cookbook][doctrine] The update of the entity is not secure. Jun 26, 2015
@xabbuh xabbuh added the hasPR A Pull Request has already been submitted for this issue. label Jul 28, 2015
@yceruto
Copy link
Member Author

yceruto commented Aug 5, 2015

the problem lies in this commit 15ccf24

weaverryan pushed a commit that referenced this issue Aug 8, 2015
| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | All
| Fixed tickets | #5448
weaverryan added a commit that referenced this issue Aug 8, 2015
This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes #5449).

Discussion
----------

Ensure that the entity is updated.

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | All
| Fixed tickets | #5448

Commits
-------

f44cccf Ensure that the entity is updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hasPR A Pull Request has already been submitted for this issue.
Projects
None yet
Development

No branches or pull requests

3 participants