Tuesday 01 May 2012 2:55:51 am - 6 replies
Hi
I'm trying the new api with an existing ez publish sample install with mysql, so I have changed my service.ini to use legacy handler api and added my db settings:
# Lots of stuff Here .... [repository] class=eZ\Publish\Core\Repository\Repository arguments[persistence_handler]=@persistence_handler arguments[io_handler]=@io_handler arguments[service_settings][contentType][field_type]=%:field_type #### Core\Io Services #### [io_handler] class=eZ\Publish\Core\IO\LegacyHandler [io_handler_legacy] class=eZ\Publish\Core\IO\LegacyHandler #### Core\Persistence Services #### ## Example for setting up Legacy Persistence Handler (Storage Engine): [persistence_handler] class=eZ\Publish\Core\Persistence\Legacy\Handler arguments[config][dsn]=mysql://root:root@localhost:3036/ez47 arguments[config][defer_type_update]=false arguments[config][external_storage][ezauthor]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezbinaryfile]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\BinaryFileStorage #arguments[config][external_storage][ezboolean]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezcountry]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezdatetime]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezemail]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezfloat]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezimage]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ImageStorage arguments[config][external_storage][ezinteger]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezkeyword]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\KeywordStorage arguments[config][external_storage][ezmedia]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\MediaStorage arguments[config][external_storage][ezobjectrelationlist]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ObjectRelationListStorage arguments[config][external_storage][ezpage]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezselection]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezstring]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezsrrating]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][eztext]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezurl]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\UrlStorage arguments[config][external_storage][ezuser]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][external_storage][ezxmltext]=eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\NullStorage arguments[config][field_converter][ezauthor]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezbinaryfile]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\BinaryFile #arguments[config][field_converter][ezboolean]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\CheckBox arguments[config][field_converter][ezcountry]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Country arguments[config][field_converter][ezdatetime]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Integer arguments[config][field_converter][ezemail]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezfloat]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Float #arguments[config][field_converter][ezimage]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Image arguments[config][field_converter][ezinteger]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Integer arguments[config][field_converter][ezkeyword]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezmedia]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Media #arguments[config][field_converter][ezobjectrelationlist]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ObjectRelationList arguments[config][field_converter][ezpage]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezselection]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Selection arguments[config][field_converter][ezstring]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezsrrating]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Rating arguments[config][field_converter][eztext]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezurl]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Url arguments[config][field_converter][ezuser]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Integer arguments[config][field_converter][ezxmltext]=eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\XmlText ... # Lots of stuff Here
Then I modified my blog class to just have one field, name, and added this code to the end of the index.php file:
$repository = $container->getRepository(); $contentService = $repository->getContentService(); $locationService = $repository->getLocationService(); $contentTypeService = $repository->getContentTypeService(); $contentType = $contentTypeService->loadContentTypeByIdentifier( 'blog' ); $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-US'); $contentCreateStruct->setField('name', 'Test'); $contentCreateStruct->sectionId=1; $contentCreateStruct->ownerId=14; $contentCreateStruct->alwaysAvailable = true; $parentLocationId = 2; $repository->beginTransaction(); $content = $contentService->createContent( $contentCreateStruct, array( $locationService->newLocationCreateStruct( $parentLocationId ) ) ); $contentService->publishVersion( $content->getVersionInfo() ); $repository->commit();
Note that my installation is based in eng-US, and what I'm trying to do is simple publish a content with the new API, but I get this error message:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: no parameters were bound' in /var/www/ezpublish/api/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/EzcDatabase.php:861
Stack trace:
#0 /var/www/ezpublish/api/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/EzcDatabase.php(861): PDOStatement->execute()
#1 /var/www/ezpublish/api/eZ/Publish/Core/Persistence/Legacy/Content/Handler.php(274): eZ\Publish\Core\Persistence\Legacy\Content\Gateway\EzcDatabase->loadVersionInfo('126', 1)
#2 /var/www/ezpublish/api/eZ/Publish/Core/Repository/ContentService.php(268): eZ\Publish\Core\Persistence\Legacy\Content\Handler->loadVersionInfo('126', 1)
#3 /var/www/ezpublish/api/eZ/Publish/Core/Repository/Values/Content/Content.php(86): eZ\Publish\Core\Repository\ContentService->loadVersionInfoById('126', 1)
#4 /var/www/ezpublish/api/index.php(74): eZ\Publish\Core\Repository\Values\Content\Content->getVersionInfo()
#5 {main}
thrown in /var/www/ezpublish/api/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/EzcDatabase.php on line 861
If I put the commit before the publish version function I see that it lefts some garbage in some db tables, like ezcontentobject_name, so, is it a bug?
Modified on Tuesday 01 May 2012 3:02:50 am by Thiago Campos Viana
Tuesday 01 May 2012 3:58:41 pm
Content and ContentType service is still work in progress, so it is probably a bug in getVersionInfo() or one of the other functions mentioned in the stack trace.
From a quick look I'm not sure what is wrong in EzcDatabase->loadVersionInfo(), but the second query ($qName), seem to use $q to generate where condition and not $qName as it should.
Modified on Tuesday 01 May 2012 4:27:19 pm by André R
Tuesday 01 May 2012 4:49:13 pm
Reproduced.
Put the following in settings/override/service.ini:
## Override settings [io_handler] class=eZ\Publish\Core\IO\LegacyHandler [persistence_handler] class=eZ\Publish\Core\Persistence\Legacy\Handler arguments[config][dsn]=mysql://root:password@127.0.0.1/ezp_temp arguments[config][defer_type_update]=false arguments[config][external_storage][ezbinaryfile]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\BinaryFileStorage #arguments[config][external_storage][ezimage]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ImageStorage arguments[config][external_storage][ezkeyword]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\KeywordStorage arguments[config][external_storage][ezmedia]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\MediaStorage arguments[config][external_storage][ezobjectrelationlist]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ObjectRelationListStorage arguments[config][external_storage][ezurl]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\UrlStorage arguments[config][field_converter][ezauthor]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezbinaryfile]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\BinaryFile arguments[config][field_converter][ezboolean]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\CheckBox arguments[config][field_converter][ezcountry]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Country arguments[config][field_converter][ezdatetime]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Integer arguments[config][field_converter][ezemail]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezfloat]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Float #arguments[config][field_converter][ezimage]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Image arguments[config][field_converter][ezinteger]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Integer arguments[config][field_converter][ezkeyword]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezmedia]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Media #arguments[config][field_converter][ezobjectrelationlist]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ObjectRelationList arguments[config][field_converter][ezpage]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezselection]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Selection arguments[config][field_converter][ezstring]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezsrrating]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Rating arguments[config][field_converter][eztext]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\TextLine arguments[config][field_converter][ezurl]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Url arguments[config][field_converter][ezuser]=\eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\Integer arguments[config][field_converter][ezxmltext]=eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\XmlText
And the following simplified php in end of index.php:
$repository = $container->getRepository(); $contentService = $repository->getContentService(); $content = $contentService->loadContent( 63 ); $content->getVersionInfo();
And the issue was in fact what I mentioned above, and hence fixed as of: https://github.com/ezsystems/ezp-next/commit/a0a4a18ba1c28dbefb2c7f0f1dafcb19b9d6d55a
But after that there is a $contentCreateStruct issue caused by content service not creating all fields with default values it seems:
Fatal error: Uncaught exception 'eZ\Publish\Core\Base\Exceptions\InvalidArgumentType' with message 'Argument '$inputValue->text' is invalid: expected value to be of type 'string'' in /ezpnext/eZ/Publish/Core/Content/FieldType/XmlText/Type.php:118
Stack trace:
#0 /ezpnext/eZ/Publish/Core/Repository/ContentService.php(558): eZ\Publish\Core\Content\FieldType\XmlText\Type->acceptValue(Object(eZ\Publish\Core\Content\FieldType\XmlText\Value))
#1 /ezpnext/index.php(66): eZ\Publish\Core\Repository\ContentService->createContent(Object(eZ\Publish\Core\Repository\Values\Content\ContentCreateStruct), Array)
#2 {main} thrown in /ezpnext/eZ/Publish/Core/Content/FieldType/XmlText/Type.php on line 118
Modified on Tuesday 01 May 2012 5:09:37 pm by André R
Tuesday 01 May 2012 6:55:08 pm
It worked! I mean, more or less, anyway, it's a wip:
eZ\Publish\Core\Repository\ContentService line 589 has:
"name" => array( "eng-US" => "Some name" ),
So this is why I got "Some name" as the name for the created content object. It isn't creating url alias also.
About the default value problem, this is why I tried to do with a class with just one attribute, and I commented some lines in service.ini because this was causing non-existing class errors.
Anyway, main problem has been solved.
You must be logged in to post messages in this topic!