eZ Community » Forums » eZ Publish 5 Platform » Update ContentType in a command...
expandshrink

Update ContentType in a command...

Update ContentType in a command...

Tuesday 08 April 2014 10:40:06 am - 3 replies

Hi guys !

I'm currently developping a website using eZ 5.2 Enterprise.

I have a problem after executing my command. This command updating ContentTypeIdentifier into parameters.

The command run without problems but when I return to the back-office, I have a exception detected :
Warning: mkdir(): Permission denied in /var/www/html/vendor/tedivm/stash/src/Stash/Driver/FileSystem.php line 185 

I clear cache brutally (rm -rf ezpublish/cache/*) and to the back-office is normal. So I can see my changes of ContentType

What is the good method for update my ContentTypeIdentifier ?

$contentTypeService->loadContentTypeByIdentifier( 'my_content_type_identifier' );
$contentTypeDraft = $contentTypeService->createContentTypeDraft( $contentType );

$fieldDefCreate = $contentTypeService->newFieldDefinitionUpdateStruct( 'my_field', 'ezstring' );
$fieldDefCreate->names = array(......)
$fieldDefCreate->descriptions = array (....)
..... fieldGroup + position + isTranslatable + isRequired + isInfoCollector + validatorConfiguration + fieldSettings + isSearchable + defaultValue

$contentTypeService->updateFieldDefinition( $contentTypeDraft, $contentTypeDraft->getFieldDefinition( 'my_field' ), $fieldDefCreate );

 $contentTypeService->publishContentTypeDraft( $contentTypeDraft );

Have you any idea ?

To try to solve the problem temporarily, I put the folder cache with permission 777 (chmod -R 777 ezpublish/cache/*) but it doesn't work.

Thanks !

Thursday 10 April 2014 11:16:06 am

Got the same problem when updating content types.

Any idea ?

Friday 11 April 2014 2:43:25 pm

From the top of my head, the most likely answer: permissions ! Sorry blunk.gif Emoticon

It should be quite simple: you run your command as your own user, most likely. Since caches aren't there anymore, they're generated by your own user, and the httpd/php user probably isn't allowed to write to  those.

You should always run such scripts with sudo and the httpd/php user.

A tip when it comes to dev environments: get rid of the whole problem, and make apache run with your own user. No permission issues anymore. But in production, any script that interacts with Sf2/eZ Publish files should be executed as the PHP user.

Monday 14 April 2014 2:31:26 pm

Bertrand is right.

All this problems come from permissions.
If it can helps, here is my way of doing:
Assume that my user is 'fab' and the apache group is 'www-data'
sudo chown -R fab:www-data .
sudo chown -R www-data ezpublish/cache/ ezpublish/logs/ ezpublish_legacy/var/ web/

And, when I ran command :
sudo -u www-data php ezpublish/console ca:c

All commands have to be fired with "sudo -u www-data php ....."

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from