This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » Check attributes before custom php...

Check attributes before custom php object creation

Check attributes before custom php object creation

Tuesday 30 November 2010 7:05:54 am - 6 replies

Hello eZ riders !

I use the great eZContentFunctions::createAndPublishObject method to create new objects. It works fine but there is a major problem. It does not check content attributes according to attributes and datatype configuration.

I want to perform the same verification that when editing object. Do you know where i can find the tools ?

Thank you very much.


Tuesday 30 November 2010 9:53:55 am

Hi Paul

Unfortunately it does not seem to be possible at that time, because validation is only made by the content/edit module.

However, every datatype has a validateObjectAttributeHTTPInput() method, but as its name indicates it, it is based on HTTP. I guess you could fake it by using eZHTTPTool and provide fake POST variables, while this is not the cleanest thing I could advise...

Anyway, instead of using eZContentFunctions::createAndPublishObject(), you might want to use SQLIImport extension which contains a simplified content API. It does not allow (yet) to validate data, but this is an interesting idea happy.gif Emoticon

Tuesday 30 November 2010 10:17:02 am

Hello Jérôme.

Thanks for your reply. I guess you have a gazillion kilometers long todo list but it would great to be able to easily check attributes.

Meanwhile, i'll do it "manually".


Tuesday 30 November 2010 10:51:55 am

Having attribute validation decoupled from HTTP is imho one one of the most important advancements we need at this point in time in the eZP content model:

- it prevents creation of webservices / cli scripts / other APIS that create content without going through the monster that content/edit is

- it makes creation and validation of import scripts a chore. Almost every website I have audited where import scripts had been developed had some inconsistent data in the db

So I'd rather push to fix this in the kernel than add it to an extension...

Tuesday 30 November 2010 10:53:52 am

ps: this is also true for content imported via packages. Just test this: set an object-relation attribute as required in a class, create an obj, export it in a package (but omit its related obj), import it. You end up with an object that does not comply with your class spec...

Tuesday 30 November 2010 10:58:38 am

Hello Gaeano,

Good to hear that. I guess many people would love to check attributes easily.

Do you think it is a lot of work to fix this in the kernel ?

Tuesday 30 November 2010 11:25:13 am

So I'd rather push to fix this in the kernel than add it to an extension...

Sure, this is also the case for the simplified content API btw blunk.gif Emoticon.

The main advantage to add this into an extension is that you can have it now happy.gif Emoticon. Besides, SQLIImport is compatible 4.1+


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

36 542 Users on board!

Forums menu

Proudly Developed with from