From: Michael Date: Fri, 19 Feb 2021 06:59:45 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/develop' into no-item X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=abcbbd2ec1247e4d144ac6500b383dafebe2f47d;p=friendica.git Merge remote-tracking branch 'upstream/develop' into no-item --- abcbbd2ec1247e4d144ac6500b383dafebe2f47d diff --cc database.sql index d87661e2a4,da32e1be6f..af254f3fe7 --- a/database.sql +++ b/database.sql @@@ -1,6 -1,6 +1,6 @@@ -- ------------------------------------------ -- Friendica 2021.03-dev (Red Hot Poker) ---- DB_UPDATE_VERSION 1403 ++-- DB_UPDATE_VERSION 1404 -- ------------------------------------------ @@@ -838,15 -959,17 +838,18 @@@ CREATE TABLE IF NOT EXISTS `openwebauth -- TABLE parsed_url -- CREATE TABLE IF NOT EXISTS `parsed_url` ( - `url` varbinary(255) NOT NULL COMMENT 'page url', + `url_hash` binary(64) NOT NULL COMMENT 'page url hash', `guessing` boolean NOT NULL DEFAULT '0' COMMENT 'is the \'guessing\' mode active?', `oembed` boolean NOT NULL DEFAULT '0' COMMENT 'is the data the result of oembed?', + `url` text NOT NULL COMMENT 'page url', `content` mediumtext COMMENT 'page data', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation', - PRIMARY KEY(`url`,`guessing`,`oembed`), - INDEX `created` (`created`) + `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of expiration', - PRIMARY KEY(`url_hash`,`guessing`,`oembed`), - INDEX `created` (`created`), - INDEX `expires` (`expires`) ++ PRIMARY KEY(`url_hash`,`guessing`,`oembed`), ++ INDEX `created` (`created`), ++ INDEX `expires` (`expires`) ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='cache for \'parse_url\' queries'; + -- -- TABLE pconfig -- diff --cc static/dbstructure.config.php index ae22470ae4,65959771df..8013b928f1 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@@ -55,7 -55,7 +55,7 @@@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { -- define('DB_UPDATE_VERSION', 1403); ++ define('DB_UPDATE_VERSION', 1404); } return [ diff --cc update.php index 7dd0369a3a,68e4fb4d3d..b8d357da22 --- a/update.php +++ b/update.php @@@ -818,61 -818,12 +818,70 @@@ function update_1400( return Update::SUCCESS; } - function update_1403() + function pre_update_1403() + { + // Necessary before a primary key change + if (!DBA::e("DROP TABLE `parsed_url`")) { + return Update::FAILED; + } + + return Update::SUCCESS; + } ++ ++function update_1404() +{ + $tasks = DBA::select('workerqueue', ['id', 'command', 'parameter'], ['command' => ['notifier', 'delivery', 'apdelivery', 'done' => false]]); + while ($task = DBA::fetch($tasks)) { + $parameters = json_decode($task['parameter'], true); + + if (in_array($parameters[0], [Delivery::MAIL, Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION])) { + continue; + } + + switch (strtolower($task['command'])) { + case 'notifier': + if (count($parameters) == 3) { + continue 2; + } + $item = DBA::selectFirst('item', ['uid', 'uri-id'], ['id' => $parameters[1]]); + if (!DBA::isResult($item)) { + continue 2; + } + + $parameters[1] = $item['uri-id']; + $parameters[2] = $item['uid']; + break; + case 'delivery': + if (count($parameters) == 4) { + continue 2; + } + $item = DBA::selectFirst('item', ['uid', 'uri-id'], ['id' => $parameters[1]]); + if (!DBA::isResult($item)) { + continue 2; + } + + $parameters[1] = $item['uri-id']; + $parameters[3] = $item['uid']; + break; + case 'apdelivery': + if (count($parameters) == 6) { + continue 2; + } + + if (empty($parameters[4])) { + $parameters[4] = []; + } + + $item = DBA::selectFirst('item', ['uri-id'], ['id' => $parameters[1]]); + if (!DBA::isResult($item)) { + continue 2; + } + + $parameters[5] = $item['uri-id']; + break; + default: + continue 2; + } + DBA::update('workerqueue', ['parameter' => json_encode($parameters)], ['id' => $task['id']]); + } - return Update::SUCCESS; +}