Merge remote-tracking branch 'upstream/develop' into item-delete

This commit is contained in:
Michael 2018-01-17 06:12:11 +00:00
commit 32c1c04a1c
7 changed files with 252 additions and 197 deletions

View file

@ -14,6 +14,7 @@ use dba;
require_once 'include/tags.php';
require_once 'include/threads.php';
require_once 'include/items.php';
class Item
{
@ -244,13 +245,11 @@ class Item
$item = dba::selectFirst('item', [], ['id' => $itemid]);
if (count($item) && ($item["allow_cid"] == '') && ($item["allow_gid"] == '') &&
if (DBM::is_result($item) && ($item["allow_cid"] == '') && ($item["allow_gid"] == '') &&
($item["deny_cid"] == '') && ($item["deny_gid"] == '')) {
if (!dba::exists('item', ['uri' => $item['uri'], 'uid' => 0])) {
// Preparing public shadow (removing user specific data)
require_once("include/items.php");
unset($item['id']);
$item['uid'] = 0;
$item['origin'] = 0;
@ -305,8 +304,6 @@ class Item
}
// Preparing public shadow (removing user specific data)
require_once("include/items.php");
unset($item['id']);
$item['uid'] = 0;
$item['origin'] = 0;

71
src/Model/Process.php Normal file
View file

@ -0,0 +1,71 @@
<?php
/**
* @file src/Model/Process.php
*/
namespace Friendica\Model;
use Friendica\BaseObject;
use dba;
require_once 'include/dba.php';
require_once 'include/datetime.php';
/**
* @brief functions for interacting with a process
*/
class Process extends BaseObject
{
/**
* Insert a new process row. If the pid parameter is omitted, we use the current pid
*
* @param string $command
* @param string $pid
* @return bool
*/
public static function insert($command, $pid = null)
{
$return = true;
dba::transaction();
if (!dba::exists('process', ['pid' => getmypid()])) {
$return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => datetime_convert()]);
}
dba::commit();
return $return;
}
/**
* Remove a process row by pid. If the pid parameter is omitted, we use the current pid
*
* @param string $pid
* @return bool
*/
public static function deleteByPid($pid = null)
{
if ($pid === null) {
$pid = getmypid();
}
return dba::delete('process', ['pid' => $pid]);
}
/**
* Clean the process table of inactive physical processes
*/
public static function deleteInactive()
{
dba::transaction();
$processes = dba::select('process', ['pid']);
while($process = dba::fetch($processes)) {
if (!posix_kill($process['pid'], 0)) {
self::deleteByPid($process['pid']);
}
}
dba::commit();
}
}