mirror of
https://github.com/friendica/friendica
synced 2025-04-28 03:50:17 +00:00
Merge remote-tracking branch 'upstream/develop' into item-delete
This commit is contained in:
commit
32c1c04a1c
7 changed files with 252 additions and 197 deletions
|
@ -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
71
src/Model/Process.php
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue