Writing Import scrip Ez 4 problems

Author Message

Pierre Tissot

Wednesday 14 May 2008 8:16:30 am

Hi,

I'm importing some information from another mysql database to ez publish, i'm doing this by script but somehow the data in the table ez_contentobject_tree is not being writen, all the rest seems to be okay.

Can anybody tell me what is wrong, here a summary of the most important parts of my script:

                    $class = eZContentClass::fetchByIdentifier( $class );
          
                    $user =& eZUser::currentUser();
                    $userID =& $user->attribute( 'contentobject_id' );
                    $sectionID = $parentContentObject->attribute( 'section_id' );
                       
                    $contentObject =& $class->instantiate( $userID, $sectionID);                    
                    $contentObject->store();

                    
                    $nodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $contentObject->attribute( 'id' ),
                                               'contentobject_version' => $contentObject->attribute( 'current_version' ),
                                               'parent_node' => $parentNodeId,
                                               'is_main' => 1
                                               ) );
                    
                    $nodeAssignment->store();
                    

                    $version = $contentObject->version( 1 );
                    $version->setAttribute( 'modified', eZDateTime::currentTimeStamp() );
                    $version->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
                    $version->store();                                                           

                    $contentObjectID = $contentObject->attribute( 'id' );
                    $attributes = $contentObject->attribute( 'contentobject_attributes' );
                 
                    // Setting the attributes with the data under array fields
                    while ( list( $key, $attribute ) = each( $attributes ) )
                    {
                        
                        if($fields[$attribute->contentClassAttributeIdentifier()]){
                            $value=$fields[$attribute->contentClassAttributeIdentifier()];
                            $attribute->setAttribute( 'data_text', $value );
                            $attribute->store();
                        }
                    }
   
                    eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ),
                                                              'version'   => 1 ) );

Maxime Thomas

Sunday 18 May 2008 10:31:40 pm

Hi,

I've you checked in the database if the data are stored ? If yes, it's maybe a cache issue. You can use the ezcontentcachemanager to clear the cache if needed.
You can also put some code like the following :

eZDebug::writeDebug(eZContentObject::fetch( $contentObjectID));

And then when you are running your script, enable the debug to see what is inside your object.

Hope it helps.

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Pierre Tissot

Monday 19 May 2008 1:28:16 am

Hi

Thanks for the tip, but still I have no clues. The data is missing on the database only on the ezcontentobject_tree table all the rest is there.

My code is generating this output on error.log:

[ May 19 2008 09:53:42 ] [linux-isfb1] eZModuleOperationInfo::loadDefinition:
Missing operation definition file for module: content

[ May 19 2008 09:53:42 ] [linux-isfb1] eZOperationHandler::execute:
Cannot execute operation 'publish' in module 'content', no valid data

André R.

Monday 19 May 2008 2:21:30 am

Are you running this without the autoload.php file included or something?

I have seen a similar error so you can try adding this in the start of your script:

// Work around for:
// #012782: Invalid argument supplied for foreach() in ezmoduleoperationinfo.php
if ( eZModule::globalPathList( ) === null  )
{
    $moduleRepositories = eZModule::activeModuleRepositories();
    eZModule::setGlobalPathList( $moduleRepositories );
}

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Pierre Tissot

Monday 19 May 2008 8:42:19 am

Bingo!!!!!!!!

Thanks a lot folks

PiR

Ole Morten Halvorsen

Thursday 03 July 2008 2:20:29 am

If you get these kinds of messages in your script:

[ May 19 2008 09:53:42 ] [linux-isfb1] eZModuleOperationInfo::loadDefinition:
Missing operation definition file for module: content

[ May 19 2008 09:53:42 ] [linux-isfb1] eZOperationHandler::execute:
Cannot execute operation 'publish' in module 'content', no valid data

you do not need to add the code André posted, just make sure to initialize eZScript with 'use-modules' and eZScript will do the job for you.

$script = eZScript::instance( array( 'description' => "my description",
                                      'use-session' => true,
                                      'use-modules' => true,
                                      'use-extensions' => true ) );

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Jitesh Rana

Wednesday 27 July 2011 3:56:37 am

"

Are you running this without the autoload.php file included or something?

I have seen a similar error so you can try adding this in the start of your script:

// Work around for:
// #012782: Invalid argument supplied for foreach() in ezmoduleoperationinfo.php
if ( eZModule::globalPathList( ) === null  )
{
    $moduleRepositories = eZModule::activeModuleRepositories();
    eZModule::setGlobalPathList( $moduleRepositories );
}
"

It works like a charm. It is the solution what i am looking for since last 6 months.

Thanks a lot André for your helpful snippet.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:45:40
Script start
Timing: Jan 18 2025 02:45:40
Module start 'layout'
Timing: Jan 18 2025 02:45:40
Module start 'content'
Timing: Jan 18 2025 02:45:41
Module end 'content'
Timing: Jan 18 2025 02:45:41
Script end

Main resources:

Total runtime0.8431 sec
Peak memory usage4,096.0000 KB
Database Queries75

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0082 587.9219152.6250
Module start 'layout' 0.00830.0037 740.546939.4609
Module start 'content' 0.01200.8292 780.0078716.2188
Module end 'content' 0.84120.0018 1,496.226620.1563
Script end 0.8430  1,516.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4246160.0002
Check MTime0.00150.1769160.0001
Mysql Total
Database connection0.00160.192310.0016
Mysqli_queries0.766390.8989750.0102
Looping result0.00100.1239730.0000
Template Total0.803895.320.4019
Template load0.00260.304720.0013
Template processing0.801295.033620.4006
Template load and register function0.00040.045110.0004
states
state_id_array0.00100.116810.0010
state_identifier_array0.00140.164720.0007
Override
Cache load0.00180.2184440.0000
Sytem overhead
Fetch class attribute can translate value0.00060.077050.0001
Fetch class attribute name0.00180.214190.0002
XML
Image XML parsing0.00140.169950.0003
class_abstraction
Instantiating content class attribute0.00000.001590.0000
General
dbfile0.00120.1459230.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs