namespace Friendica\Util;
/**
* @file src/Util/Lock.php
* @brief Functions for preventing parallel execution of functions
namespace Friendica\Util;
/**
* @file src/Util/Lock.php
* @brief Functions for preventing parallel execution of functions
/**
* @brief Check for memcache and open a connection if configured
*
* @return object|boolean The memcache object - or "false" if not successful
*/
/**
* @brief Check for memcache and open a connection if configured
*
* @return object|boolean The memcache object - or "false" if not successful
*/
- $lock = dba::select('locks', array('locked', 'pid'), array('name' => $fn_name), array('limit' => 1));
+ $lock = dba::selectFirst('locks', ['locked', 'pid'], ['name' => $fn_name]);
if ($lock['locked']) {
// When the process id isn't used anymore, we can safely claim the lock for us.
if (!posix_kill($lock['pid'], 0)) {
if ($lock['locked']) {
// When the process id isn't used anymore, we can safely claim the lock for us.
if (!posix_kill($lock['pid'], 0)) {
- dba::update('locks', array('locked' => true, 'pid' => getmypid()), array('name' => $fn_name));
+ dba::update('locks', ['locked' => true, 'pid' => getmypid()], ['name' => $fn_name]);
- } elseif (!dbm::is_result($lock)) {
- dba::insert('locks', array('name' => $fn_name, 'locked' => true, 'pid' => getmypid()));
+ } elseif (!DBM::is_result($lock)) {
+ dba::insert('locks', ['name' => $fn_name, 'locked' => true, 'pid' => getmypid()]);
if (function_exists('sem_get') && version_compare(PHP_VERSION, '5.6.1', '>=')) {
if (empty(self::$semaphore[$fn_name])) {
return false;
if (function_exists('sem_get') && version_compare(PHP_VERSION, '5.6.1', '>=')) {
if (empty(self::$semaphore[$fn_name])) {
return false;
- dba::update('locks', array('locked' => false, 'pid' => 0), array('name' => $fn_name, 'pid' => getmypid()));
+ dba::update('locks', ['locked' => false, 'pid' => 0], ['name' => $fn_name, 'pid' => getmypid()]);
$memcache = self::connectMemcache();
if (is_object($memcache)) {
// We cannot delete all cache entries, but this doesn't matter with memcache
return;
}
$memcache = self::connectMemcache();
if (is_object($memcache)) {
// We cannot delete all cache entries, but this doesn't matter with memcache
return;
}
- dba::update('locks', array('locked' => false, 'pid' => 0), array('pid' => getmypid()));
+ dba::update('locks', ['locked' => false, 'pid' => 0], ['pid' => getmypid()]);