define('FRIENDICA_CODENAME', 'Asparagus');
define('FRIENDICA_VERSION', '3.6-dev');
define('DFRN_PROTOCOL_VERSION', '2.23');
-define('DB_UPDATE_VERSION', 1252);
+define('DB_UPDATE_VERSION', 1253);
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
/**
-- ------------------------------------------
-- Friendica 3.6-dev (Asparagus)
--- DB_UPDATE_VERSION 1250
+-- DB_UPDATE_VERSION 1253
-- ------------------------------------------
--
CREATE TABLE IF NOT EXISTS `user` (
`uid` mediumint NOT NULL auto_increment COMMENT '',
+ `parent-uid` mediumint NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user',
`guid` varchar(64) NOT NULL DEFAULT '' COMMENT '',
`username` varchar(255) NOT NULL DEFAULT '' COMMENT '',
`password` varchar(255) NOT NULL DEFAULT '' COMMENT '',
--
CREATE TABLE IF NOT EXISTS `workerqueue` (
`id` int NOT NULL auto_increment COMMENT 'Auto incremented worker task id',
- `parameter` mediumtext COMMENT 'Task command',
+ `parameter` mediumblob COMMENT 'Task command',
`priority` tinyint NOT NULL DEFAULT 0 COMMENT 'Task priority',
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'Creation date',
`pid` int NOT NULL DEFAULT 0 COMMENT 'Process id of the worker',
if (is_array($a->hooks) && array_key_exists($name, $a->hooks)) {
foreach ($a->hooks[$name] as $hook) {
- Worker::add($priority, 'ForkHook', $name, json_encode($hook), json_encode($data));
+ Worker::add($priority, 'ForkHook', $name, $hook, $data);
}
}
}
return false;
}
- $argv = json_decode($queue["parameter"]);
+ $argv = json_decode($queue["parameter"], true);
// Check for existance and validity of the include file
$include = $argv[0];
$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"]);
+ $argv = json_decode($entry["parameter"], true);
$argv[0] = basename($argv[0]);
// How long is the process already running?
*/
public static function add($cmd)
{
- $proc_args = func_get_args();
+ $args = func_get_args();
- $args = [];
- if (!count($proc_args)) {
+ if (!count($args)) {
return false;
}
- // Preserve the first parameter
- // It could contain a command, the priority or an parameter array
- // If we use the parameter array we have to protect it from the following function
- $run_parameter = array_shift($proc_args);
-
- // expand any arrays
- foreach ($proc_args as $arg) {
- if (is_array($arg)) {
- foreach ($arg as $n) {
- $args[] = $n;
- }
- } else {
- $args[] = $arg;
- }
- }
-
- // Now we add the run parameters back to the array
- array_unshift($args, $run_parameter);
-
$arr = ['args' => $args, 'run_cmd' => true];
Addon::callHooks("proc_run", $arr);
}
}
- $argv = $args;
- array_shift($argv);
+ array_shift($args);
- $parameters = json_encode($argv);
+ $parameters = json_encode($args);
$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
"comment" => "Background tasks queue entries",
"fields" => [
"id" => ["type" => "int", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "Auto incremented worker task id"],
- "parameter" => ["type" => "mediumtext", "comment" => "Task command"],
+ "parameter" => ["type" => "mediumblob", "comment" => "Task command"],
"priority" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Task priority"],
"created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => "Creation date"],
"pid" => ["type" => "int", "not null" => "1", "default" => "0", "comment" => "Process id of the worker"],
use Friendica\Core\Addon;
Class ForkHook {
- public static function execute($name, $hook_json, $data_json) {
+ public static function execute($name, $hook, $data) {
global $a;
- $hook = json_decode($hook_json, true);
- $data = json_decode($data_json, true);
-
Addon::callSingleHook($a, $name, $hook, $data);
}
}