sonata-project / SonataMediaBundle

Symfony SonataMediaBundle
https://docs.sonata-project.org/projects/SonataMediaBundle
MIT License
451 stars 495 forks source link

Media Block gets updated when callin $em->flush() in controller #1095

Closed hug963 closed 4 years ago

hug963 commented 8 years ago

Environment

Sonata packages

sonata-project/admin-bundle 3.4.0 The missing Symfony Admin Generator sonata-project/block-bundle 3.1.1 Symfony SonataBlockBundle sonata-project/cache 1.0.7 Cache library sonata-project/cache-bundle 2.2.5 This bundle provides caching services sonata-project/classification-bundle 3.1.0 Symfony SonataClassificationBundle sonata-project/core-bundle 3.0.3 Symfony SonataCoreBundle sonata-project/datagrid-bundle 2.2 Symfony SonataDatagridBundle sonata-project/doctrine-extensions 1.0.2 Doctrine2 behavioral extensions sonata-project/doctrine-orm-admin-bundle 3.0.5 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle sonata-project/easy-extends-bundle 2.1.10 Symfony SonataEasyExtendsBundle sonata-project/exporter 1.6.0 Lightweight Exporter library sonata-project/formatter-bundle 3.0.1 Symfony SonataFormatterBundle sonata-project/google-authenticator 1.0.2 Library to integrate Google Authenticator into a PHP project sonata-project/intl-bundle 2.2.4 Symfony SonataIntlBundle sonata-project/media-bundle 3.1.0 Symfony SonataMediaBundle sonata-project/notification-bundle 3.0.0 Symfony SonataNotificationBundle sonata-project/page-bundle 3.1.0 This bundle provides a Site and Page management through container and block services sonata-project/seo-bundle 2.0.2 Symfony SonataSeoBundle sonata-project/user-bundle 3.0.1 Symfony SonataUserBundle

Symfony packages

symfony/monolog-bundle 2.11.1 Symfony MonologBundle symfony/phpunit-bridge v2.8.9 Symfony PHPUnit Bridge symfony/polyfill-apcu v1.2.0 Symfony polyfill backporting apcu_* functions to lower PHP versions symfony/polyfill-intl-icu v1.2.0 Symfony polyfill for intl's ICU-related data and classes symfony/polyfill-mbstring v1.2.0 Symfony polyfill for the Mbstring extension symfony/polyfill-php54 v1.2.0 Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions symfony/polyfill-php55 v1.2.0 Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions symfony/polyfill-php56 v1.2.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions symfony/polyfill-php70 v1.2.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions symfony/polyfill-util v1.2.0 Symfony utilities for portability of PHP codes symfony/security-acl v3.0.0 Symfony Security Component - ACL (Access Control List) symfony/swiftmailer-bundle v2.3.11 Symfony SwiftmailerBundle symfony/symfony v2.8.9 The Symfony PHP framework

PHP version

PHP 7.0.9 (cli) (built: Jul 21 2016 14:50:47) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.9, Copyright (c) 1999-2016, by Zend Technologies with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

Subject

I use a sonata.media.block.media on a page where I render a controller with a form. When the form is submitted I call $em->flush(), the media in my media block gets updated and deleted.

This is because load() is always called, even when rendering the block. https://github.com/sonata-project/SonataMediaBundle/blob/3.x/Block/MediaBlockService.php#L149

It is called manually here, so I don't think this is the expected behaviour: https://github.com/sonata-project/SonataMediaBundle/blob/3.x/Block/MediaBlockService.php#L102

Renaming load() seems to fix the issue on my install.

bartosz-malec commented 8 years ago

Are you logged into admin? I had the same problem when I was logged to admin in ver 2.*

hug963 commented 8 years ago

I just tried, and you are right, it only happens when logged in as an admin.

I guess this is less of an issue then, but could someone have a look?

OskarStark commented 7 years ago

still a problem @hug963 or can we close this issue?

stale[bot] commented 4 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.