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
[email protected]
blog: http://blog.divdesigns.com
Granite Horizon / http://granitehorizon.com
|