bugfix: async service "sometimes" misses jobs (db-class was not cloned but copied)

This commit is contained in:
Ralf Becker 2007-06-10 08:47:14 +00:00
parent b6a28b8090
commit 3ddd4a7d17

View File

@ -1,41 +1,31 @@
<?php
/**************************************************************************\
* eGroupWare API - Timed Asynchron Services for eGroupWare *
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
* Class for creating cron-job like timed calls of eGroupWare methods *
* -------------------------------------------------------------------------*
* This library is part of the eGroupWare API *
* http://www.eGroupWare.org *
* ------------------------------------------------------------------------ *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/**
* API - Timed Asynchron Services for eGroupWare
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright Ralf Becker <RalfBecker-AT-outdoor-training.de>
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api
* @access public
* @version $Id$
*/
/* $Id$ */
/**
/**
* The class implements a general eGW service to execute callbacks at a given time.
*
* see http://www.egroupware.org/wiki/TimedAsyncServices
*
* @author Ralf Becker
* @copyright GPL - GNU General Public License
*/
class asyncservice
{
var $public_functions = array(
'set_timer' => True,
'check_run' => True,
'cancel_timer' => True,
'read' => True,
'install' => True,
'installed' => True,
'last_check_run' => True
);
class asyncservice
{
var $php = '';
var $crontab = '';
/**
* Our instance of the db-class
*
* @var egw_db
*/
var $db;
var $db_table = 'egw_async';
var $debug = 0;
@ -45,7 +35,14 @@
*/
function asyncservice()
{
$this->db = is_object($GLOBALS['egw']->db) ? $GLOBALS['egw']->db : $GLOBALS['phpgw_setup']->db;
if (is_object($GLOBALS['egw']->db))
{
$this->db = clone($GLOBALS['egw']->db);
}
else
{
$this->db = clone($GLOBALS['egw_setup']->db);
}
$this->db->set_app('phpgwapi');
$this->cronline = EGW_SERVER_ROOT . '/phpgwapi/cron/asyncservices.php '.$GLOBALS['egw_info']['user']['domain'];
@ -402,7 +399,7 @@
{
foreach($jobs as $id => $job)
{
// checking / setting up phpgw_info/user
// checking / setting up egw_info/user
//
if ($GLOBALS['egw_info']['user']['account_id'] != $job['account_id'])
{
@ -430,7 +427,6 @@
}
list($app) = explode('.',$job['method']);
$GLOBALS['egw']->translation->add_app($app);
ExecMethod($job['method'],$job['data']);
// re-read job, in case it had been updated or even deleted in the method
@ -591,16 +587,15 @@
}
//echo "<p>$name = '".$this->$name."'</p>\n";
}
if ($this->php4[0] == '/') // we found a php4 binary
if ($this->php4{0} == '/') // we found a php4 binary
{
$this->php = $this->php4;
}
if ($this->php5[0] == '/') // we found a php5 binary
if ($this->php5{0} == '/') // we found a php5 binary
{
$this->php = $this->php5;
}
}
}
/**
@ -630,10 +625,10 @@
if ($this->debug) echo 'line '.++$n.": $line<br>\n";
$parts = split(' ',$line,6);
if ($line[0] == '#' || count($parts) < 6 || ($parts[5][0] != '/' && substr($parts[5],0,3) != 'php'))
if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5],0,3) != 'php'))
{
// ignore comments
if ($line[0] != '#')
if ($line{0} != '#')
{
$times['error'] .= $line;
}
@ -699,4 +694,4 @@
}
return $times !== False ? $this->installed() : ' ';
}
}
}