No time limit for long operations like: Bulk delete, CSV import (interactive) and Bulk modify

SVN:trunk[2946]
This commit is contained in:
Romain Quetiez
2013-10-22 08:09:34 +00:00
parent 015919702b
commit 20ba6242e7
4 changed files with 34 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
<?php
// Copyright (C) 2010-2012 Combodo SARL
// Copyright (C) 2010-2013 Combodo SARL
//
// This file is part of iTop.
//
@@ -3212,8 +3212,10 @@ EOF
}
utils::RemoveTransaction($sTransactionId);
}
$iPreviousTimeLimit = ini_get('max_execution_time');
foreach($aSelectedObj as $iId)
{
set_time_limit(5);
$oObj = MetaModel::GetObject($sClass, $iId);
$aErrors = $oObj->UpdateObjectFromPostedForm('');
$bResult = (count($aErrors) == 0);
@@ -3244,6 +3246,7 @@ EOF
$oObj->DBUpdate();
}
}
set_time_limit($iPreviousTimeLimit);
$oP->Table($aHeaders, $aRows);
if ($bPreview)
{

View File

@@ -1,5 +1,5 @@
<?php
// Copyright (C) 2010-2012 Combodo SARL
// Copyright (C) 2010-2013 Combodo SARL
//
// This file is part of iTop.
//
@@ -788,8 +788,10 @@ class BulkChange
{
$aVisited = array();
}
$iPreviousTimeLimit = ini_get('max_execution_time');
foreach($this->m_aData as $iRow => $aRowData)
{
set_time_limit(5);
if (isset($aResult[$iRow]["__STATUS__"]))
{
// An issue at the earlier steps - skip the rest
@@ -908,11 +910,13 @@ class BulkChange
$iObj = $oObj->GetKey();
if (!in_array($iObj, $aVisited))
{
set_time_limit(5);
$iRow++;
$this->UpdateMissingObject($aResult, $iRow, $oObj, $oChange);
}
}
}
set_time_limit($iPreviousTimeLimit);
// Fill in the blanks - the result matrix is expected to be 100% complete
//

View File

@@ -1,5 +1,5 @@
<?php
// Copyright (C) 2010-2012 Combodo SARL
// Copyright (C) 2010-2013 Combodo SARL
//
// This file is part of iTop.
//
@@ -1742,6 +1742,10 @@ abstract class DBObject
}
else
{
// Getting and setting time limit are not symetric:
// www.php.net/manual/fr/function.set-time-limit.php#72305
$iPreviousTimeLimit = ini_get('max_execution_time');
foreach ($oDeletionPlan->ListDeletes() as $sClass => $aToDelete)
{
foreach ($aToDelete as $iId => $aData)
@@ -1753,6 +1757,7 @@ abstract class DBObject
// As a temporary fix: delete only the objects that are still to be deleted...
if ($oToDelete->m_bIsInDB)
{
set_time_limit(5);
$oToDelete->DBDeleteSingleObject();
}
}
@@ -1766,10 +1771,13 @@ abstract class DBObject
foreach ($aData['attributes'] as $sRemoteExtKey => $aRemoteAttDef)
{
$oToUpdate->Set($sRemoteExtKey, $aData['values'][$sRemoteExtKey]);
set_time_limit(5);
$oToUpdate->DBUpdate();
}
}
}
set_time_limit($iPreviousTimeLimit);
}
return $oDeletionPlan;
@@ -2236,10 +2244,17 @@ abstract class DBObject
$oDeletionPlan->SetDeletionIssues($this, $this->m_aDeleteIssues, $this->m_bSecurityIssue);
$aDependentObjects = $this->GetReferencingObjects(true /* allow all data */);
// Getting and setting time limit are not symetric:
// www.php.net/manual/fr/function.set-time-limit.php#72305
$iPreviousTimeLimit = ini_get('max_execution_time');
foreach ($aDependentObjects as $sRemoteClass => $aPotentialDeletes)
{
foreach ($aPotentialDeletes as $sRemoteExtKey => $aData)
{
set_time_limit(5);
$oAttDef = $aData['attribute'];
$iDeletePropagationOption = $oAttDef->GetDeletionPropagationOption();
$oDepSet = $aData['objects'];
@@ -2269,6 +2284,7 @@ abstract class DBObject
}
}
}
set_time_limit($iPreviousTimeLimit);
}
/**

View File

@@ -1,5 +1,5 @@
<?php
// Copyright (C) 2010-2012 Combodo SARL
// Copyright (C) 2010-2013 Combodo SARL
//
// This file is part of iTop.
//
@@ -20,7 +20,7 @@
/**
* Algorithm to delete object(s) and maintain data integrity
*
* @copyright Copyright (C) 2010-2012 Combodo SARL
* @copyright Copyright (C) 2010-2013 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
@@ -107,10 +107,15 @@ class DeletionPlan
}
}
// Getting and setting time limit are not symetric:
// www.php.net/manual/fr/function.set-time-limit.php#72305
$iPreviousTimeLimit = ini_get('max_execution_time');
foreach($this->m_aToUpdate as $sClass => $aToUpdate)
{
foreach($aToUpdate as $iId => $aData)
{
set_time_limit(5);
$this->m_iToUpdate++;
$oObject = $aData['to_reset'];
@@ -134,9 +139,9 @@ class DeletionPlan
$this->m_bFoundSecurityIssue = true;
}
}
}
}
set_time_limit($iPreviousTimeLimit);
}
public function GetIssues()