コード例 #1
0
/**
 * Cleanup handler, in case of a non caught DB transaction error
 * @return void
 */
function SQLIImportCleanupHandler()
{
    // Check if an error has occurred and report it if necessary
    $db = eZDB::instance();
    if ($db->errorNumber() > 0) {
        SQLIImportToken::cleanAll();
        $factory = SQLIImportFactory::instance();
        $currentItem = $factory->getCurrentImportItem();
        $currentItem->setAttribute('status', SQLIImportItem::STATUS_FAILED);
        $currentItem->store();
        SQLIImportLogger::logError('A DB transaction error occurred : #' . $db->errorNumber() . ' - "' . $db->errorMessage() . '"');
        SQLIImportLogger::logError('An error has occurred during import process. The import status has been updated.');
    }
}
コード例 #2
0
 function sigHandler($signo)
 {
     if (SQLIImportToken::importIsRunning()) {
         // Note : SIGKILL cannot be caught
         // So try to always send a SIGINT (kill -2) or SIGTERM (kill -15) to request interruption
         switch ($signo) {
             case SIGTERM:
             case SIGINT:
                 SQLIImportLogger::logNotice('Caught SIGTERM while importing. Demanding import interruption (might take a little while)');
                 $factory = SQLIImportFactory::instance();
                 $currentItem = $factory->getCurrentImportItem();
                 $currentItem->setAttribute('status', SQLIImportItem::STATUS_INTERRUPTED);
                 $currentItem->store();
                 break;
         }
     }
 }
コード例 #3
0
 /**
  * Sets {@link self::$isImportScript}
  * @param bool $val
  */
 public static function setIsImportScript($val)
 {
     self::$isImportScript = (bool) $val;
 }
コード例 #4
0
$options = $script->getOptions("[script-verbose;][script-verbose-level;]", "[node]", array('script-verbose' => 'Use this parameter to display verbose script output without disabling script iteration counting of images created or removed. Example: ' . "'--script-verbose'" . ' is an optional parameter which defaults to false', 'script-verbose-level' => 'Use only with ' . "'--script-verbose'" . ' parameter to see more of execution internals. Example: ' . "'--script-verbose-level=3'" . ' is an optional parameter which defaults to 1 and works till 5'), false, array('user' => true));
$script->initialize();
/** Test for required script arguments **/
$verbose = isset($options['script-verbose']) ? true : false;
$scriptVerboseLevel = isset($options['script-verbose-level']) ? $options['script-verbose-level'] : 1;
/** Script default values **/
$adminUserID = 14;
/** Display of execution time **/
function executionTimeDisplay($srcStartTime, $cli)
{
    /** Add a stoping timing point tracking and calculating total script execution time **/
    $srcStopTime = microtime();
    $startTime = @next(explode(" ", $srcStartTime)) + current(explode(" ", $srcStartTime));
    $stopTime = @next(explode(" ", $srcStopTime)) + current(explode(" ", $srcStopTime));
    $executionTime = round($stopTime - $startTime, 2);
    /** Alert the user to how long the script execution took place **/
    $cli->output("\n\nThis script execution completed in " . $executionTime . " seconds" . ".\n");
}
/** Login script to run as admin user  This is required to see past content tree permissions, sections and other limitations **/
$currentuser = eZUser::currentUser();
$currentuser->logoutCurrent();
$user = eZUser::fetch($adminUserID);
$user->loginCurrent();
/** Reset sqliimport import status **/
SQLIImportToken::cleanAll();
/** Inform the script user of the results **/
$cli->warning("\nThe ezsite_data table entry for sqliimport_status should now have been removed");
/** Call for display of execution time **/
// executionTimeDisplay( $srcStartTime, $cli );
/** Shutdown script **/
$script->shutdown();
コード例 #5
0
 /**
  * Cleans up import process
  */
 public function cleanup()
 {
     SQLIImportLogger::writeNotice('Now cleaning the import process');
     $this->token = null;
     SQLIImportToken::cleanAll();
     $this->restorePerformanceSettings();
     // Update scheduled imports
     if (is_array($this->scheduledImports)) {
         foreach ($this->scheduledImports as $scheduledImport) {
             if (!$scheduledImport instanceof SQLIScheduledImport) {
                 SQLIImportLogger::logError(__METHOD__ . '$scheduledImport is not an instance of SQLIScheduledImport !');
                 continue;
             }
             $scheduledImport->updateNextImport();
         }
     }
     unset($this->scheduledImports);
 }