mirror of
https://github.com/friendica/friendica
synced 2025-04-27 11:10:12 +00:00
Use short form array syntax everywhere
- Add short form array syntax to po2php.php generation
This commit is contained in:
parent
77dfbaa0bf
commit
e36f2bb1fb
212 changed files with 5160 additions and 5160 deletions
|
@ -146,8 +146,8 @@ class Cache
|
|||
$memcache->set(get_app()->get_hostname().":".$key, serialize($value), MEMCACHE_COMPRESSED, self::duration($duration));
|
||||
return;
|
||||
}
|
||||
$fields = array('v' => serialize($value), 'expire_mode' => $duration, 'updated' => datetime_convert());
|
||||
$condition = array('k' => $key);
|
||||
$fields = ['v' => serialize($value), 'expire_mode' => $duration, 'updated' => datetime_convert()];
|
||||
$condition = ['k' => $key];
|
||||
dba::update('cache', $fields, $condition, true);
|
||||
}
|
||||
|
||||
|
@ -163,68 +163,68 @@ class Cache
|
|||
// Clear long lasting cache entries only once a day
|
||||
if (Config::get("system", "cache_cleared_day") < time() - self::duration(CACHE_DAY)) {
|
||||
if ($max_level == CACHE_MONTH) {
|
||||
$condition = array("`updated` < ? AND `expire_mode` = ?",
|
||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
||||
datetime_convert('UTC', 'UTC', "now - 30 days"),
|
||||
CACHE_MONTH);
|
||||
CACHE_MONTH];
|
||||
dba::delete('cache', $condition);
|
||||
}
|
||||
|
||||
if ($max_level <= CACHE_WEEK) {
|
||||
$condition = array("`updated` < ? AND `expire_mode` = ?",
|
||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
||||
datetime_convert('UTC', 'UTC', "now - 7 days"),
|
||||
CACHE_WEEK);
|
||||
CACHE_WEEK];
|
||||
dba::delete('cache', $condition);
|
||||
}
|
||||
|
||||
if ($max_level <= CACHE_DAY) {
|
||||
$condition = array("`updated` < ? AND `expire_mode` = ?",
|
||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
||||
datetime_convert('UTC', 'UTC', "now - 1 days"),
|
||||
CACHE_DAY);
|
||||
CACHE_DAY];
|
||||
dba::delete('cache', $condition);
|
||||
}
|
||||
Config::set("system", "cache_cleared_day", time());
|
||||
}
|
||||
|
||||
if (($max_level <= CACHE_HOUR) && (Config::get("system", "cache_cleared_hour")) < time() - self::duration(CACHE_HOUR)) {
|
||||
$condition = array("`updated` < ? AND `expire_mode` = ?",
|
||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
||||
datetime_convert('UTC', 'UTC', "now - 1 hours"),
|
||||
CACHE_HOUR);
|
||||
CACHE_HOUR];
|
||||
dba::delete('cache', $condition);
|
||||
|
||||
Config::set("system", "cache_cleared_hour", time());
|
||||
}
|
||||
|
||||
if (($max_level <= CACHE_HALF_HOUR) && (Config::get("system", "cache_cleared_half_hour")) < time() - self::duration(CACHE_HALF_HOUR)) {
|
||||
$condition = array("`updated` < ? AND `expire_mode` = ?",
|
||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
||||
datetime_convert('UTC', 'UTC', "now - 30 minutes"),
|
||||
CACHE_HALF_HOUR);
|
||||
CACHE_HALF_HOUR];
|
||||
dba::delete('cache', $condition);
|
||||
|
||||
Config::set("system", "cache_cleared_half_hour", time());
|
||||
}
|
||||
|
||||
if (($max_level <= CACHE_QUARTER_HOUR) && (Config::get("system", "cache_cleared_quarter_hour")) < time() - self::duration(CACHE_QUARTER_HOUR)) {
|
||||
$condition = array("`updated` < ? AND `expire_mode` = ?",
|
||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
||||
datetime_convert('UTC', 'UTC', "now - 15 minutes"),
|
||||
CACHE_QUARTER_HOUR);
|
||||
CACHE_QUARTER_HOUR];
|
||||
dba::delete('cache', $condition);
|
||||
|
||||
Config::set("system", "cache_cleared_quarter_hour", time());
|
||||
}
|
||||
|
||||
if (($max_level <= CACHE_FIVE_MINUTES) && (Config::get("system", "cache_cleared_five_minute")) < time() - self::duration(CACHE_FIVE_MINUTES)) {
|
||||
$condition = array("`updated` < ? AND `expire_mode` = ?",
|
||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
||||
datetime_convert('UTC', 'UTC', "now - 5 minutes"),
|
||||
CACHE_FIVE_MINUTES);
|
||||
CACHE_FIVE_MINUTES];
|
||||
dba::delete('cache', $condition);
|
||||
|
||||
Config::set("system", "cache_cleared_five_minute", time());
|
||||
}
|
||||
|
||||
if (($max_level <= CACHE_MINUTE) && (Config::get("system", "cache_cleared_minute")) < time() - self::duration(CACHE_MINUTE)) {
|
||||
$condition = array("`updated` < ? AND `expire_mode` = ?",
|
||||
$condition = ["`updated` < ? AND `expire_mode` = ?",
|
||||
datetime_convert('UTC', 'UTC', "now - 1 minutes"),
|
||||
CACHE_MINUTE);
|
||||
CACHE_MINUTE];
|
||||
dba::delete('cache', $condition);
|
||||
|
||||
Config::set("system", "cache_cleared_minute", time());
|
||||
|
|
|
@ -49,7 +49,7 @@ class Config
|
|||
|
||||
$a = get_app();
|
||||
|
||||
$r = dba::select('config', array('v', 'k'), array('cat' => $family));
|
||||
$r = dba::select('config', ['v', 'k'], ['cat' => $family]);
|
||||
while ($rr = dba::fetch($r)) {
|
||||
$k = $rr['k'];
|
||||
if ($family === 'config') {
|
||||
|
@ -161,7 +161,7 @@ class Config
|
|||
// manage array value
|
||||
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
||||
|
||||
$ret = dba::update('config', array('v' => $dbvalue), array('cat' => $family, 'k' => $key), true);
|
||||
$ret = dba::update('config', ['v' => $dbvalue], ['cat' => $family, 'k' => $key], true);
|
||||
|
||||
if ($ret) {
|
||||
self::$in_db[$family][$key] = true;
|
||||
|
@ -188,7 +188,7 @@ class Config
|
|||
unset(self::$in_db[$family][$key]);
|
||||
}
|
||||
|
||||
$ret = dba::delete('config', array('cat' => $family, 'k' => $key));
|
||||
$ret = dba::delete('config', ['cat' => $family, 'k' => $key]);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class NotificationsManager extends BaseObject
|
|||
*/
|
||||
private function _set_extra($notes)
|
||||
{
|
||||
$rets = array();
|
||||
$rets = [];
|
||||
foreach ($notes as $n) {
|
||||
$local_time = datetime_convert('UTC', date_default_timezone_get(), $n['date']);
|
||||
$n['timestamp'] = strtotime($local_time);
|
||||
|
@ -63,9 +63,9 @@ class NotificationsManager extends BaseObject
|
|||
*
|
||||
* @return array of results or false on errors
|
||||
*/
|
||||
public function getAll($filter = array(), $order = "-date", $limit = "")
|
||||
public function getAll($filter = [], $order = "-date", $limit = "")
|
||||
{
|
||||
$filter_str = array();
|
||||
$filter_str = [];
|
||||
$filter_sql = "";
|
||||
foreach ($filter as $column => $value) {
|
||||
$filter_str[] = sprintf("`%s` = '%s'", $column, dbesc($value));
|
||||
|
@ -75,7 +75,7 @@ class NotificationsManager extends BaseObject
|
|||
}
|
||||
|
||||
$aOrder = explode(" ", $order);
|
||||
$asOrder = array();
|
||||
$asOrder = [];
|
||||
foreach ($aOrder as $o) {
|
||||
$dir = "asc";
|
||||
if ($o[0] === "-") {
|
||||
|
@ -165,43 +165,43 @@ class NotificationsManager extends BaseObject
|
|||
*/
|
||||
public function getTabs()
|
||||
{
|
||||
$tabs = array(
|
||||
array(
|
||||
$tabs = [
|
||||
[
|
||||
'label' => t('System'),
|
||||
'url' => 'notifications/system',
|
||||
'sel' => ((self::getApp()->argv[1] == 'system') ? 'active' : ''),
|
||||
'id' => 'system-tab',
|
||||
'accesskey' => 'y',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'label' => t('Network'),
|
||||
'url' => 'notifications/network',
|
||||
'sel' => ((self::getApp()->argv[1] == 'network') ? 'active' : ''),
|
||||
'id' => 'network-tab',
|
||||
'accesskey' => 'w',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'label' => t('Personal'),
|
||||
'url' => 'notifications/personal',
|
||||
'sel' => ((self::getApp()->argv[1] == 'personal') ? 'active' : ''),
|
||||
'id' => 'personal-tab',
|
||||
'accesskey' => 'r',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'label' => t('Home'),
|
||||
'url' => 'notifications/home',
|
||||
'sel' => ((self::getApp()->argv[1] == 'home') ? 'active' : ''),
|
||||
'id' => 'home-tab',
|
||||
'accesskey' => 'h',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'label' => t('Introductions'),
|
||||
'url' => 'notifications/intros',
|
||||
'sel' => ((self::getApp()->argv[1] == 'intros') ? 'active' : ''),
|
||||
'id' => 'intro-tab',
|
||||
'accesskey' => 'i',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
@ -223,8 +223,8 @@ class NotificationsManager extends BaseObject
|
|||
*/
|
||||
private function formatNotifs($notifs, $ident = "")
|
||||
{
|
||||
$notif = array();
|
||||
$arr = array();
|
||||
$notif = [];
|
||||
$arr = [];
|
||||
|
||||
if (DBM::is_result($notifs)) {
|
||||
foreach ($notifs as $it) {
|
||||
|
@ -272,7 +272,7 @@ class NotificationsManager extends BaseObject
|
|||
// Transform the different types of notification in an usable array
|
||||
switch ($it['verb']) {
|
||||
case ACTIVITY_LIKE:
|
||||
$notif = array(
|
||||
$notif = [
|
||||
'label' => 'like',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
|
@ -281,11 +281,11 @@ class NotificationsManager extends BaseObject
|
|||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
);
|
||||
];
|
||||
break;
|
||||
|
||||
case ACTIVITY_DISLIKE:
|
||||
$notif = array(
|
||||
$notif = [
|
||||
'label' => 'dislike',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
|
@ -294,11 +294,11 @@ class NotificationsManager extends BaseObject
|
|||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
);
|
||||
];
|
||||
break;
|
||||
|
||||
case ACTIVITY_ATTEND:
|
||||
$notif = array(
|
||||
$notif = [
|
||||
'label' => 'attend',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
|
@ -307,11 +307,11 @@ class NotificationsManager extends BaseObject
|
|||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
);
|
||||
];
|
||||
break;
|
||||
|
||||
case ACTIVITY_ATTENDNO:
|
||||
$notif = array(
|
||||
$notif = [
|
||||
'label' => 'attendno',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
|
@ -320,11 +320,11 @@ class NotificationsManager extends BaseObject
|
|||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
);
|
||||
];
|
||||
break;
|
||||
|
||||
case ACTIVITY_ATTENDMAYBE:
|
||||
$notif = array(
|
||||
$notif = [
|
||||
'label' => 'attendmaybe',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
|
@ -333,7 +333,7 @@ class NotificationsManager extends BaseObject
|
|||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
);
|
||||
];
|
||||
break;
|
||||
|
||||
case ACTIVITY_FRIEND:
|
||||
|
@ -341,7 +341,7 @@ class NotificationsManager extends BaseObject
|
|||
$obj = parse_xml_string($xmlhead . $it['object']);
|
||||
$it['fname'] = $obj->title;
|
||||
|
||||
$notif = array(
|
||||
$notif = [
|
||||
'label' => 'friend',
|
||||
'link' => System::baseUrl(true) . '/display/' . $it['pguid'],
|
||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||
|
@ -350,11 +350,11 @@ class NotificationsManager extends BaseObject
|
|||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
);
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
$notif = array(
|
||||
$notif = [
|
||||
'label' => $default_item_label,
|
||||
'link' => $default_item_link,
|
||||
'image' => $default_item_image,
|
||||
|
@ -363,7 +363,7 @@ class NotificationsManager extends BaseObject
|
|||
'when' => $default_item_when,
|
||||
'ago' => $default_item_ago,
|
||||
'seen' => $it['seen']
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$arr[] = $notif;
|
||||
|
@ -420,7 +420,7 @@ class NotificationsManager extends BaseObject
|
|||
{
|
||||
$ident = 'network';
|
||||
$total = $this->networkTotal($seen);
|
||||
$notifs = array();
|
||||
$notifs = [];
|
||||
$sql_seen = "";
|
||||
|
||||
if ($seen === 0) {
|
||||
|
@ -496,7 +496,7 @@ class NotificationsManager extends BaseObject
|
|||
{
|
||||
$ident = 'system';
|
||||
$total = $this->systemTotal($seen);
|
||||
$notifs = array();
|
||||
$notifs = [];
|
||||
$sql_seen = "";
|
||||
|
||||
if ($seen === 0) {
|
||||
|
@ -532,7 +532,7 @@ class NotificationsManager extends BaseObject
|
|||
{
|
||||
$myurl = System::baseUrl(true) . '/profile/' . self::getApp()->user['nickname'];
|
||||
$myurl = substr($myurl, strpos($myurl, '://') + 3);
|
||||
$myurl = str_replace(array('www.', '.'), array('', '\\.'), $myurl);
|
||||
$myurl = str_replace(['www.', '.'], ['', '\\.'], $myurl);
|
||||
$diasp_url = str_replace('/profile/', '/u/', $myurl);
|
||||
$sql_extra = sprintf(
|
||||
" AND ( `item`.`author-link` regexp '%s' OR `item`.`tag` regexp '%s' OR `item`.`tag` regexp '%s' ) ",
|
||||
|
@ -594,7 +594,7 @@ class NotificationsManager extends BaseObject
|
|||
$ident = 'personal';
|
||||
$total = $this->personalTotal($seen);
|
||||
$sql_extra = $this->personalSqlExtra();
|
||||
$notifs = array();
|
||||
$notifs = [];
|
||||
$sql_seen = "";
|
||||
|
||||
if ($seen === 0) {
|
||||
|
@ -619,11 +619,11 @@ class NotificationsManager extends BaseObject
|
|||
$notifs = $this->formatNotifs($r, $ident);
|
||||
}
|
||||
|
||||
$arr = array(
|
||||
$arr = [
|
||||
'notifications' => $notifs,
|
||||
'ident' => $ident,
|
||||
'total' => $total,
|
||||
);
|
||||
];
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ class NotificationsManager extends BaseObject
|
|||
{
|
||||
$ident = 'home';
|
||||
$total = $this->homeTotal($seen);
|
||||
$notifs = array();
|
||||
$notifs = [];
|
||||
$sql_seen = "";
|
||||
|
||||
if ($seen === 0) {
|
||||
|
@ -752,7 +752,7 @@ class NotificationsManager extends BaseObject
|
|||
{
|
||||
$ident = 'introductions';
|
||||
$total = $this->introTotal($all);
|
||||
$notifs = array();
|
||||
$notifs = [];
|
||||
$sql_extra = "";
|
||||
|
||||
if (!$all) {
|
||||
|
@ -807,7 +807,7 @@ class NotificationsManager extends BaseObject
|
|||
if ($it['fid']) {
|
||||
$return_addr = bin2hex(self::getApp()->user['nickname'] . '@' . self::getApp()->get_hostname() . ((self::getApp()->path) ? '/' . self::getApp()->path : ''));
|
||||
|
||||
$intro = array(
|
||||
$intro = [
|
||||
'label' => 'friend_suggestion',
|
||||
'notify_type' => t('Friend Suggestion'),
|
||||
'intro_id' => $it['intro_id'],
|
||||
|
@ -821,7 +821,7 @@ class NotificationsManager extends BaseObject
|
|||
'knowyou' => $knowyou,
|
||||
'note' => $it['note'],
|
||||
'request' => $it['frequest'] . '?addr=' . $return_addr,
|
||||
);
|
||||
];
|
||||
|
||||
// Normal connection requests
|
||||
} else {
|
||||
|
@ -833,7 +833,7 @@ class NotificationsManager extends BaseObject
|
|||
$it['gabout'] = "";
|
||||
$it['ggender'] = "";
|
||||
}
|
||||
$intro = array(
|
||||
$intro = [
|
||||
'label' => (($it['network'] !== NETWORK_OSTATUS) ? 'friend_request' : 'follower'),
|
||||
'notify_type' => (($it['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')),
|
||||
'dfrn_id' => $it['issued-id'],
|
||||
|
@ -854,7 +854,7 @@ class NotificationsManager extends BaseObject
|
|||
'network' => $it['gnetwork'],
|
||||
'knowyou' => $it['knowyou'],
|
||||
'note' => $it['note'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$arr[] = $intro;
|
||||
|
|
|
@ -41,7 +41,7 @@ class PConfig
|
|||
{
|
||||
$a = get_app();
|
||||
|
||||
$r = dba::select('pconfig', array('v', 'k'), array('cat' => $family, 'uid' => $uid));
|
||||
$r = dba::select('pconfig', ['v', 'k'], ['cat' => $family, 'uid' => $uid]);
|
||||
if (DBM::is_result($r)) {
|
||||
while ($rr = dba::fetch($r)) {
|
||||
$k = $rr['k'];
|
||||
|
@ -140,7 +140,7 @@ class PConfig
|
|||
// manage array value
|
||||
$dbvalue = (is_array($value) ? serialize($value) : $dbvalue);
|
||||
|
||||
$ret = dba::update('pconfig', array('v' => $dbvalue), array('uid' => $uid, 'cat' => $family, 'k' => $key), true);
|
||||
$ret = dba::update('pconfig', ['v' => $dbvalue], ['uid' => $uid, 'cat' => $family, 'k' => $key], true);
|
||||
|
||||
if ($ret) {
|
||||
self::$in_db[$uid][$family][$key] = true;
|
||||
|
@ -170,7 +170,7 @@ class PConfig
|
|||
unset(self::$in_db[$uid][$family][$key]);
|
||||
}
|
||||
|
||||
$ret = dba::delete('pconfig', array('uid' => $uid, 'cat' => $family, 'k' => $key));
|
||||
$ret = dba::delete('pconfig', ['uid' => $uid, 'cat' => $family, 'k' => $key]);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
@ -54,12 +54,12 @@ class System extends BaseObject
|
|||
array_shift($trace);
|
||||
array_shift($trace);
|
||||
|
||||
$callstack = array();
|
||||
$callstack = [];
|
||||
$counter = 0;
|
||||
$previous = array('class' => '', 'function' => '');
|
||||
$previous = ['class' => '', 'function' => ''];
|
||||
|
||||
// The ignore list contains all functions that are only wrapper functions
|
||||
$ignore = array('get_config', 'get_pconfig', 'set_config', 'set_pconfig', 'fetch_url', 'probe_url');
|
||||
$ignore = ['get_config', 'get_pconfig', 'set_config', 'set_pconfig', 'fetch_url', 'probe_url'];
|
||||
|
||||
while ($func = array_pop($trace)) {
|
||||
if (!empty($func['class'])) {
|
||||
|
@ -75,7 +75,7 @@ class System extends BaseObject
|
|||
}
|
||||
}
|
||||
|
||||
$callstack2 = array();
|
||||
$callstack2 = [];
|
||||
while ((count($callstack2) < $depth) && (count($callstack) > 0)) {
|
||||
$callstack2[] = array_pop($callstack);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class UserImport
|
|||
if (self::IMPORT_DEBUG) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return dba::lastInsertId();
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class UserImport
|
|||
$query = sprintf("SHOW COLUMNS IN `%s`", dbesc($table));
|
||||
logger("uimport: $query", LOGGER_DEBUG);
|
||||
$r = q($query);
|
||||
$tcols = array();
|
||||
$tcols = [];
|
||||
// get a plain array of column names
|
||||
foreach ($r as $tcol) {
|
||||
$tcols[] = $tcol['Field'];
|
||||
|
@ -156,7 +156,7 @@ class UserImport
|
|||
unset($account['user']['expire_notification_sent']);
|
||||
|
||||
$callback = function (&$value) use ($oldbaseurl, $oldaddr, $newbaseurl, $newaddr) {
|
||||
$value = str_replace(array($oldbaseurl, $oldaddr), array($newbaseurl, $newaddr), $value);
|
||||
$value = str_replace([$oldbaseurl, $oldaddr], [$newbaseurl, $newaddr], $value);
|
||||
};
|
||||
|
||||
array_walk($account['user'], $callback);
|
||||
|
@ -177,8 +177,8 @@ class UserImport
|
|||
|
||||
foreach ($account['profile'] as &$profile) {
|
||||
foreach ($profile as $k => &$v) {
|
||||
$v = str_replace(array($oldbaseurl, $oldaddr), array($newbaseurl, $newaddr), $v);
|
||||
foreach (array("profile", "avatar") as $k) {
|
||||
$v = str_replace([$oldbaseurl, $oldaddr], [$newbaseurl, $newaddr], $v);
|
||||
foreach (["profile", "avatar"] as $k) {
|
||||
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ class UserImport
|
|||
if ($r === false) {
|
||||
logger("uimport:insert profile " . $profile['profile-name'] . " : ERROR : " . dba::errorMessage(), LOGGER_NORMAL);
|
||||
info(t("User profile creation error"));
|
||||
dba::delete('user', array('uid' => $newuid));
|
||||
dba::delete('user', ['uid' => $newuid]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -196,8 +196,8 @@ class UserImport
|
|||
foreach ($account['contact'] as &$contact) {
|
||||
if ($contact['uid'] == $olduid && $contact['self'] == '1') {
|
||||
foreach ($contact as $k => &$v) {
|
||||
$v = str_replace(array($oldbaseurl, $oldaddr), array($newbaseurl, $newaddr), $v);
|
||||
foreach (array("profile", "avatar", "micro") as $k) {
|
||||
$v = str_replace([$oldbaseurl, $oldaddr], [$newbaseurl, $newaddr], $v);
|
||||
foreach (["profile", "avatar", "micro"] as $k) {
|
||||
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ class Worker
|
|||
*/
|
||||
private static function highestPriority()
|
||||
{
|
||||
$condition = array("`executed` <= ? AND NOT `done`", NULL_DATE);
|
||||
$condition = ["`executed` <= ? AND NOT `done`", NULL_DATE];
|
||||
$workerqueue = dba::selectFirst('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
|
||||
if (DBM::is_result($workerqueue)) {
|
||||
return $workerqueue["priority"];
|
||||
|
@ -182,7 +182,7 @@ class Worker
|
|||
*/
|
||||
private static function processWithPriorityActive($priority)
|
||||
{
|
||||
$condition = array("`priority` <= ? AND `executed` > ? AND NOT `done`", $priority, NULL_DATE);
|
||||
$condition = ["`priority` <= ? AND `executed` > ? AND NOT `done`", $priority, NULL_DATE];
|
||||
return dba::exists('workerqueue', $condition);
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ class Worker
|
|||
|
||||
if ($age > 1) {
|
||||
$stamp = (float)microtime(true);
|
||||
dba::update('workerqueue', array('executed' => datetime_convert()), array('pid' => $mypid, 'done' => false));
|
||||
dba::update('workerqueue', ['executed' => datetime_convert()], ['pid' => $mypid, 'done' => false]);
|
||||
self::$db_duration += (microtime(true) - $stamp);
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ class Worker
|
|||
self::execFunction($queue, $include, $argv, true);
|
||||
|
||||
$stamp = (float)microtime(true);
|
||||
if (dba::update('workerqueue', array('done' => true), array('id' => $queue["id"]))) {
|
||||
if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
|
||||
Config::set('system', 'last_poller_execution', datetime_convert());
|
||||
}
|
||||
self::$db_duration = (microtime(true) - $stamp);
|
||||
|
@ -257,7 +257,7 @@ class Worker
|
|||
|
||||
if (!validate_include($include)) {
|
||||
logger("Include file ".$argv[0]." is not valid!");
|
||||
dba::delete('workerqueue', array('id' => $queue["id"]));
|
||||
dba::delete('workerqueue', ['id' => $queue["id"]]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -276,20 +276,20 @@ class Worker
|
|||
|
||||
if ($age > 1) {
|
||||
$stamp = (float)microtime(true);
|
||||
dba::update('workerqueue', array('executed' => datetime_convert()), array('pid' => $mypid, 'done' => false));
|
||||
dba::update('workerqueue', ['executed' => datetime_convert()], ['pid' => $mypid, 'done' => false]);
|
||||
self::$db_duration += (microtime(true) - $stamp);
|
||||
}
|
||||
|
||||
self::execFunction($queue, $funcname, $argv, false);
|
||||
|
||||
$stamp = (float)microtime(true);
|
||||
if (dba::update('workerqueue', array('done' => true), array('id' => $queue["id"]))) {
|
||||
if (dba::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
|
||||
Config::set('system', 'last_poller_execution', datetime_convert());
|
||||
}
|
||||
self::$db_duration = (microtime(true) - $stamp);
|
||||
} else {
|
||||
logger("Function ".$funcname." does not exist");
|
||||
dba::delete('workerqueue', array('id' => $queue["id"]));
|
||||
dba::delete('workerqueue', ['id' => $queue["id"]]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -330,7 +330,7 @@ class Worker
|
|||
$a->performance["parser"] = 0;
|
||||
$a->performance["marktime"] = 0;
|
||||
$a->performance["markstart"] = microtime(true);
|
||||
$a->callstack = array();
|
||||
$a->callstack = [];
|
||||
}
|
||||
|
||||
// For better logging create a new process id for every worker call
|
||||
|
@ -528,27 +528,27 @@ class Worker
|
|||
{
|
||||
$entries = dba::select(
|
||||
'workerqueue',
|
||||
array('id', 'pid', 'executed', 'priority', 'parameter'),
|
||||
array('`executed` > ? AND NOT `done` AND `pid` != 0', NULL_DATE),
|
||||
array('order' => array('priority', 'created'))
|
||||
['id', 'pid', 'executed', 'priority', 'parameter'],
|
||||
['`executed` > ? AND NOT `done` AND `pid` != 0', NULL_DATE],
|
||||
['order' => ['priority', 'created']]
|
||||
);
|
||||
|
||||
while ($entry = dba::fetch($entries)) {
|
||||
if (!posix_kill($entry["pid"], 0)) {
|
||||
dba::update(
|
||||
'workerqueue',
|
||||
array('executed' => NULL_DATE, 'pid' => 0),
|
||||
array('id' => $entry["id"])
|
||||
['executed' => NULL_DATE, 'pid' => 0],
|
||||
['id' => $entry["id"]]
|
||||
);
|
||||
} else {
|
||||
// Kill long running processes
|
||||
// Check if the priority is in a valid range
|
||||
if (!in_array($entry["priority"], array(PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE))) {
|
||||
if (!in_array($entry["priority"], [PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE])) {
|
||||
$entry["priority"] = PRIORITY_MEDIUM;
|
||||
}
|
||||
|
||||
// Define the maximum durations
|
||||
$max_duration_defaults = array(PRIORITY_CRITICAL => 720, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 720);
|
||||
$max_duration_defaults = [PRIORITY_CRITICAL => 720, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 720];
|
||||
$max_duration = $max_duration_defaults[$entry["priority"]];
|
||||
|
||||
$argv = json_decode($entry["parameter"]);
|
||||
|
@ -572,8 +572,8 @@ class Worker
|
|||
}
|
||||
dba::update(
|
||||
'workerqueue',
|
||||
array('executed' => NULL_DATE, 'created' => datetime_convert(), 'priority' => $new_priority, 'pid' => 0),
|
||||
array('id' => $entry["id"])
|
||||
['executed' => NULL_DATE, 'created' => datetime_convert(), 'priority' => $new_priority, 'pid' => 0],
|
||||
['id' => $entry["id"]]
|
||||
);
|
||||
} else {
|
||||
logger("Worker process ".$entry["pid"]." (".implode(" ", $argv).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG);
|
||||
|
@ -610,7 +610,7 @@ class Worker
|
|||
|
||||
if (Config::get('system', 'worker_debug')) {
|
||||
// Create a list of queue entries grouped by their priority
|
||||
$listitem = array();
|
||||
$listitem = [];
|
||||
|
||||
// Adding all processes with no workerqueue entry
|
||||
$processes = dba::p(
|
||||
|
@ -636,8 +636,8 @@ class Worker
|
|||
}
|
||||
dba::close($entries);
|
||||
|
||||
$intervals = array(1, 10, 60);
|
||||
$jobs_per_minute = array();
|
||||
$intervals = [1, 10, 60];
|
||||
$jobs_per_minute = [];
|
||||
foreach ($intervals as $interval) {
|
||||
$jobs = dba::p("SELECT COUNT(*) AS `jobs` FROM `workerqueue` WHERE `done` AND `executed` > UTC_TIMESTAMP() - INTERVAL ".intval($interval)." MINUTE");
|
||||
if ($job = dba::fetch($jobs)) {
|
||||
|
@ -707,7 +707,7 @@ class Worker
|
|||
if (!DBM::is_result($r)) {
|
||||
return false;
|
||||
}
|
||||
$priorities = array();
|
||||
$priorities = [];
|
||||
while ($line = dba::fetch($r)) {
|
||||
$priorities[] = $line["priority"];
|
||||
}
|
||||
|
@ -823,7 +823,7 @@ class Worker
|
|||
if ($found) {
|
||||
$condition = "`id` IN (".substr(str_repeat("?, ", count($ids)), 0, -2).") AND `pid` = 0 AND NOT `done`";
|
||||
array_unshift($ids, $condition);
|
||||
dba::update('workerqueue', array('executed' => datetime_convert(), 'pid' => $mypid), $ids);
|
||||
dba::update('workerqueue', ['executed' => datetime_convert(), 'pid' => $mypid], $ids);
|
||||
}
|
||||
|
||||
return $found;
|
||||
|
@ -840,7 +840,7 @@ class Worker
|
|||
$stamp = (float)microtime(true);
|
||||
|
||||
// There can already be jobs for us in the queue.
|
||||
$r = dba::select('workerqueue', array(), array('pid' => getmypid(), 'done' => false));
|
||||
$r = dba::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
|
||||
if (DBM::is_result($r)) {
|
||||
self::$db_duration += (microtime(true) - $stamp);
|
||||
return dba::inArray($r);
|
||||
|
@ -860,7 +860,7 @@ class Worker
|
|||
Lock::remove('poller_worker_process');
|
||||
|
||||
if ($found) {
|
||||
$r = dba::select('workerqueue', array(), array('pid' => getmypid(), 'done' => false));
|
||||
$r = dba::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
|
||||
return dba::inArray($r);
|
||||
}
|
||||
return false;
|
||||
|
@ -874,7 +874,7 @@ class Worker
|
|||
{
|
||||
$mypid = getmypid();
|
||||
|
||||
dba::update('workerqueue', array('executed' => NULL_DATE, 'pid' => 0), array('pid' => $mypid, 'done' => false));
|
||||
dba::update('workerqueue', ['executed' => NULL_DATE, 'pid' => 0], ['pid' => $mypid, 'done' => false]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -950,8 +950,8 @@ class Worker
|
|||
$timeout = Config::get("system", "frontend_worker_timeout", 10);
|
||||
|
||||
/// @todo We should clean up the corresponding workerqueue entries as well
|
||||
$condition = array("`created` < ? AND `command` = 'worker.php'",
|
||||
datetime_convert('UTC', 'UTC', "now - ".$timeout." minutes"));
|
||||
$condition = ["`created` < ? AND `command` = 'worker.php'",
|
||||
datetime_convert('UTC', 'UTC', "now - ".$timeout." minutes")];
|
||||
dba::delete('process', $condition);
|
||||
}
|
||||
|
||||
|
@ -981,7 +981,7 @@ class Worker
|
|||
*/
|
||||
public static function spawnWorker()
|
||||
{
|
||||
$args = array("scripts/worker.php", "no_cron");
|
||||
$args = ["scripts/worker.php", "no_cron"];
|
||||
get_app()->proc_run($args);
|
||||
}
|
||||
|
||||
|
@ -1005,7 +1005,7 @@ class Worker
|
|||
{
|
||||
$proc_args = func_get_args();
|
||||
|
||||
$args = array();
|
||||
$args = [];
|
||||
if (!count($proc_args)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1029,7 +1029,7 @@ class Worker
|
|||
// Now we add the run parameters back to the array
|
||||
array_unshift($args, $run_parameter);
|
||||
|
||||
$arr = array('args' => $args, 'run_cmd' => true);
|
||||
$arr = ['args' => $args, 'run_cmd' => true];
|
||||
|
||||
call_hooks("proc_run", $arr);
|
||||
if (!$arr['run_cmd'] || !count($args)) {
|
||||
|
@ -1058,7 +1058,7 @@ class Worker
|
|||
array_shift($argv);
|
||||
|
||||
$parameters = json_encode($argv);
|
||||
$found = dba::exists('workerqueue', array('parameter' => $parameters, 'done' => false));
|
||||
$found = dba::exists('workerqueue', ['parameter' => $parameters, 'done' => false]);
|
||||
|
||||
// Quit if there was a database error - a precaution for the update process to 3.5.3
|
||||
if (dba::errorNo() != 0) {
|
||||
|
@ -1066,7 +1066,7 @@ class Worker
|
|||
}
|
||||
|
||||
if (!$found) {
|
||||
dba::insert('workerqueue', array('parameter' => $parameters, 'created' => $created, 'priority' => $priority));
|
||||
dba::insert('workerqueue', ['parameter' => $parameters, 'created' => $created, 'priority' => $priority]);
|
||||
}
|
||||
|
||||
// Should we quit and wait for the worker to be called as a cronjob?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue