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

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

eZ debug

Timing: Jan 29 2025 13:42:22
Script start
Timing: Jan 29 2025 13:42:22
Module start 'content'
Timing: Jan 29 2025 13:42:22
Module end 'content'
Timing: Jan 29 2025 13:42:22
Script end

Main resources:

Total runtime0.1268 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 589.4766180.7813
Module start 'content' 0.00470.0047 770.257898.1484
Module end 'content' 0.00940.1173 868.4063533.5000
Script end 0.1267  1,401.9063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00302.3610200.0001
Check MTime0.00120.9334200.0001
Mysql Total
Database connection0.00080.611410.0008
Mysqli_queries0.085267.22751410.0006
Looping result0.00100.81231390.0000
Template Total0.116992.210.1169
Template load0.00060.512710.0006
Template processing0.116291.658210.1162
Override
Cache load0.00050.366710.0005
Sytem overhead
Fetch class attribute can translate value0.00060.484310.0006
XML
Image XML parsing0.00020.169610.0002
General
dbfile0.00705.5546200.0004
String conversion0.00000.002330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs