A database transaction in eZ Publish failed when i try to remove of an ezcontentobject

Author Message

Seb Gaillard

Tuesday 13 July 2010 7:39:47 am

Hi I have an Fatal error: A database transaction in eZ Publish failed when itry to remove an ezcontentobject.

Here is the extract of var/log/error.log:

[ Jul 13 2010 15:22:09 ] [] eZMySQLDB:
Query error: Timeout sur l'obtention du verrou. Query: UPDATE ezsearch_word SET object_count=( object_count - 1 ) WHERE id in ( 63585,773,742,5034,638,1237,668,742,5034,638,1237,668,1610,10428650,63585,773,742,5034,638,1237,668,639,10591032,4477869,847,731,668,9569,1423,10591033 )
[ Jul 13 2010 15:22:09 ] [] eZDBInterface::commit TRANSID-7e0f17b65db2ee5ec41ef1b80fd664f2:
Transaction in progress failed due to DB error, transaction was rollbacked. Transaction ID is TRANSID-7e0f17b65db2ee5ec41ef1b80fd664f2.

And the part of the code:

$paramsDelete = array(
'ClassFilterType' => 'include',
'ClassFilterArray' => array ($params['class_identifier']),
'Offset' => 0,
'MainNodeOnly'=>true,
);
$testsDelete = eZContentObjectTreeNode::subTreeByNodeID( $paramsDelete, 2);
$log->write('Nb objets tests a supprimer: '.count($testsDelete) , 'psychoTestImport.log', $logFolder);
foreach($testsDelete as $test)
{
$cli->output( " ACTION: suppression du test ".$test->ContentObjectID);
$contentObject = eZContentObject::fetch( (int)($test->ContentObjectID) );
foreach($contentObject->attribute( 'assigned_nodes' ) as $assignedNode){
$cli->output( " ACTION: suppression du noeud ".$assignedNode->NodeID." du test".$test->ContentObjectID);
eZContentObjectTreeNode::removeNode($assignedNode->NodeID);
$cptDel++;
}
if($contentObject)
{
$cptDelNodes += count($contentObject->attribute( 'assigned_nodes' ));
$cptDelObjs++;
$contentObject->purge();
}
}

Have somebody an idea how to solve this problem.

Thank's,

Seb

Brandon Chambers

Wednesday 14 July 2010 9:35:08 am

I can't be sure as I am fairly new to dabbling in the eZ API but this might help. There was an extra ',' in your first array.

Also when accessing attributes of a node or object, I think it's standard practice to use:

$object->attribute('node_id');

Also, it's best to check the object or node to see if it is set or empty before looping over it.

I added some log writes. I would have typed them in French but it is quite rusty. Good luck!

Lastly, try looking at the kernel code, that is usually the best way to find out about standards for now until the API is more completely documented. (crosses fringers)

$paramsDelete = array(
    'ClassFilterType'      => 'include',
    'ClassFilterArray'     => array ( $params['class_identifier'] ),
    'Offset'               => 0,
    'MainNodeOnly'         => true
);

$testsDelete = eZContentObjectTreeNode::subTreeByNodeID( $paramsDelete, 2 );

$log->write( 'Nb objets tests a supprimer: '.count($testsDelete), 'psychoTestImport.log', $logFolder);

if ( isset( $testsDelete ) )
{
    foreach( $testsDelete as $test )
    {
        $cli->output( " ACTION: suppression du test " . $test->attribute('object_id') );
        $contentObject = eZContentObject::fetch( $test->attribute('object_id' );
        if ( isset( $contentObject ) )
        {
            foreach( $contentObject->attribute( 'assigned_nodes' ) as $assignedNode ){
                $cli->output( " ACTION: suppression du noeud ".$assignedNode->attribute('node_id')." du test".$test->ContentObjectID );
                eZContentObjectTreeNode::removeNode( $assignedNode->attribute('node_id') );
                $cptDel++;
            }
            $cptDelNodes += count($contentObject->attribute( 'assigned_nodes' ));
            $cptDelObjs++;
            $contentObject->purge();
        }
        else
        {
            $log->write( 'Failed to fetch object for deletion.', 'psychoTestImport.log', $logFolder );
        }
    }
}
else
{
    $log->write( 'Failed to fetch parent objects.', 'psychoTestImport.log', $logFolder);
}

Brandon Chambers
brandon@granitehorizon.com
blog: http://blog.divdesigns.com
Granite Horizon / http://granitehorizon.com

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:14:39
Script start
Timing: Jan 18 2025 02:14:39
Module start 'layout'
Timing: Jan 18 2025 02:14:39
Module start 'content'
Timing: Jan 18 2025 02:14:41
Module end 'content'
Timing: Jan 18 2025 02:14:41
Script end

Main resources:

Total runtime1.2608 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.4063152.6875
Module start 'layout' 0.00600.0032 741.093839.5859
Module start 'content' 0.00921.2500 780.6797546.4609
Module end 'content' 1.25920.0015 1,327.140612.0625
Script end 1.2607  1,339.2031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2462160.0002
Check MTime0.00130.1034160.0001
Mysql Total
Database connection0.00070.053810.0007
Mysqli_queries1.209395.9177540.0224
Looping result0.00050.0390520.0000
Template Total1.225497.220.6127
Template load0.00210.165220.0010
Template processing1.223397.029420.6117
Template load and register function0.00020.017210.0002
states
state_id_array0.00110.089710.0011
state_identifier_array0.00260.207620.0013
Override
Cache load0.00180.1415460.0000
Sytem overhead
Fetch class attribute can translate value0.00050.037520.0002
Fetch class attribute name0.00100.080630.0003
XML
Image XML parsing0.00070.052020.0003
class_abstraction
Instantiating content class attribute0.00000.000630.0000
General
dbfile0.00070.0583160.0000
String conversion0.00000.000540.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs