X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=src%2FModel%2FProcess.php;h=f70b12ba7c64ba387ef24d9ae5177a3d5b190f39;hb=2b0610eaf5ea67cc6b6a8e59b4f9c08249f90370;hp=fbc844c8d2d0fc4985ce1089714e2a9de1dc4184;hpb=f193f01a7d6ed4946b5ec4a4b92294bb75b294cb;p=friendica.git diff --git a/src/Model/Process.php b/src/Model/Process.php index fbc844c8d2..f70b12ba7c 100644 --- a/src/Model/Process.php +++ b/src/Model/Process.php @@ -5,9 +5,8 @@ namespace Friendica\Model; use Friendica\BaseObject; -use dba; - -require_once 'include/dba.php'; +use Friendica\Database\DBA; +use Friendica\Util\DateTimeFormat; /** * @brief functions for interacting with a process @@ -20,18 +19,23 @@ class Process extends BaseObject * @param string $command * @param string $pid * @return bool + * @throws \Exception */ public static function insert($command, $pid = null) { $return = true; - dba::transaction(); + if (is_null($pid)) { + $pid = getmypid(); + } + + DBA::transaction(); - if (!dba::exists('process', ['pid' => getmypid()])) { - $return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => datetime_convert()]); + if (!DBA::exists('process', ['pid' => $pid])) { + $return = DBA::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]); } - dba::commit(); + DBA::commit(); return $return; } @@ -41,6 +45,7 @@ class Process extends BaseObject * * @param string $pid * @return bool + * @throws \Exception */ public static function deleteByPid($pid = null) { @@ -48,7 +53,7 @@ class Process extends BaseObject $pid = getmypid(); } - return dba::delete('process', ['pid' => $pid]); + return DBA::delete('process', ['pid' => $pid]); } /** @@ -56,15 +61,15 @@ class Process extends BaseObject */ public static function deleteInactive() { - dba::transaction(); + DBA::transaction(); - $processes = dba::select('process', ['pid']); - while($process = dba::fetch($processes)) { + $processes = DBA::select('process', ['pid']); + while($process = DBA::fetch($processes)) { if (!posix_kill($process['pid'], 0)) { self::deleteByPid($process['pid']); } } - dba::commit(); + DBA::commit(); } }