I am currently facing a new issue where I need some help.
To avoid import of the same image, I tried the following:
$sha1 = sha1_file($src);
$resource = $this->resourceManager->getResourceBySha1($sha1);
if ($resource === null) {
$resource = $this->resourceManager->importResource($src);
}
$image = new \TYPO3\Media\Domain\Model\Image($resource);
$this->view->assign('image', $image);
But after the image is imported, the site crashes with the error:
An exception was thrown while Neos tried to render your page
Node workspace not found in allowed workspaces, this could result from a detached workspace entity in the context.
page<TYPO3.Neos:Page>/
body<TYPO3.TypoScript:Template>/
content/
commonSidebar<TYPO3.TypoScript:Collection>/
For a full stacktrace, open Data/Logs/Exceptions/20151012124120158262.txt
And the system_development.log shows the following:
15-10-12 12:41:21 13371 DEBUG Flow Session: Resumed session with id P0KrCzr6TwPategnqnvvv2z59R1UptSh which was inactive for 3 minutes. (218s)
15-10-12 12:41:21 13371 DEBUG Flow Router route(): A cached Route with the cache identifier "f86901d39c73b00257d482911385aa8a" matched the path "index.html".
15-10-12 12:41:21 13371 DEBUG Flow CSRF: No token required, safe request
15-10-12 12:41:21 13371 DEBUG Flow CSRF: No token required, safe request
15-10-12 12:41:22 13371 DEBUG Flow Successfully imported file "/var/www/Neos-2.0/Data/Temporary/Development/ProcessedImage-561baa725f5f8.jpg?oh=7dd00b577204d7c66995e8f3c6287b56&oe=5699a55b" into the resource collection "persistent" (storage: defaultPersistentResourcesStorage, a TYPO3\Flow\Resource\Collection. SHA1: 51ce9774471a46611bb42447e846f998f7d5d544)
15-10-12 12:41:22 13371 DEBUG Flow FileSystemSymlinkTarget: Published file. (target: localWebDirectoryPersistentResourcesTarget, file: 51ce9774471a46611bb42447e846f998f7d5d544/12140842_1017635598256867_3362333541560488648_n-150x113.jpg?oh=7dd00b577204d7c66995e8f3c6287b56&oe=5699a55b)
15-10-12 12:41:22 13371 CRITICAL DBAL Uncaught exception in line 116 of /var/www/Neos-2.0/Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php: An exception occurred while executing 'INSERT INTO typo3_media_domain_model_asset (persistence_object_identifier, lastmodified, title, caption, resource, dtype) VALUES (?, ?, ?, ?, ?, ?)' with params ["d2d15d84-e330-cd60-287a-066c30bed2e3", "2015-10-12 12:41:22", "", "", "145535aa-63d6-fa10-2a18-58976eb11258", "typo3_media_image"]:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '145535aa-63d6-fa10-2a18-58976eb11258' for key 'UNIQ_B8306B8EBC91F416' - See also: 2015101212412044fe0d.txt
previousException => Uncaught exception #23000 in line 165 of /var/www/Neos-2.0/Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/Statement.php: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '145535aa-63d6-fa10-2a18-58976eb11258' for key 'UNIQ_B8306B8EBC91F416'
15-10-12 12:41:22 13371 CRITICAL TYPO3CR Uncaught exception #1413902143 in line 208 of /var/www/Neos-2.0/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/TYPO3_TYPO3CR_Domain_Repository_NodeDataRepository.php: Node workspace not found in allowed workspaces, this could result from a detached workspace entity in the context. - See also: 20151012124120717eff.txt
15-10-12 12:41:22 13371 CRITICAL TYPO3CR Uncaught exception #1413902143 in line 484 of /var/www/Neos-2.0/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/TYPO3_TYPO3CR_Domain_Repository_NodeDataRepository.php: Node workspace not found in allowed workspaces, this could result from a detached workspace entity in the context. - See also: 20151012124120f0e8aa.txt
15-10-12 12:41:22 13371 CRITICAL TYPO3CR Uncaught exception #1413902143 in line 484 of /var/www/Neos-2.0/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/TYPO3_TYPO3CR_Domain_Repository_NodeDataRepository.php: Node workspace not found in allowed workspaces, this could result from a detached workspace entity in the context. - See also: 20151012124120158262.txt
15-10-12 12:41:22 13371 ERROR Flow persistAll() skipped flushing data, the Doctrine EntityManager is closed. Check the logs for error message.
15-10-12 12:41:22 13371 DEBUG Flow Not removing storage data of resource 12140842_1017635598256867_3362333541560488648_n-150x113.jpg?oh=7dd00b577204d7c66995e8f3c6287b56&oe=5699a55b (51ce9774471a46611bb42447e846f998f7d5d544) because it is still in use by 2 other Resource object(s).
15-10-12 12:41:22 13371 CRITICAL ORM Uncaught exception in line 708 of /var/www/Neos-2.0/Packages/Libraries/doctrine/orm/lib/Doctrine/ORM/EntityManager.php: The EntityManager is closed. - See also: 201510121241203fa471.txt
I found out, that this only occurs, if I try to generate a thumbnail from the returned image.
{media:uri.image(asset: image, maximumHeight: 150, maximumWidth: 150)}
This drives me crazy. I don’t have a glue, why this fails. Please give me some assistance.