mirror of
https://github.com/friendica/friendica
synced 2024-12-23 04:40:15 +00:00
post update function added
This commit is contained in:
parent
098ba4a667
commit
1a4beaf061
2 changed files with 57 additions and 3 deletions
|
@ -72,6 +72,9 @@ class PostUpdate
|
|||
if (!self::update1342()) {
|
||||
return false;
|
||||
}
|
||||
if (!self::update1345()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -559,7 +562,6 @@ class PostUpdate
|
|||
|
||||
Logger::info('Start', ['item' => $id]);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
|
||||
$items = DBA::p("SELECT `uri-id`,`body` FROM `item-content` WHERE
|
||||
|
@ -613,7 +615,6 @@ class PostUpdate
|
|||
|
||||
Logger::info('Start', ['item' => $id]);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
|
||||
$terms = DBA::p("SELECT `term`.`tid`, `item`.`uri-id`, `term`.`type`, `term`.`term`, `term`.`url`, `item-content`.`body`
|
||||
|
@ -667,4 +668,57 @@ class PostUpdate
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the "post-delivery-data" table with data from the "item-delivery-data" table
|
||||
*
|
||||
* @return bool "true" when the job is done
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function update1345()
|
||||
{
|
||||
// Was the script completed?
|
||||
if (DI::config()->get('system', 'post_update_version') >= 1345) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$id = DI::config()->get('system', 'post_update_version_1345_id', 0);
|
||||
|
||||
Logger::info('Start', ['item' => $id]);
|
||||
|
||||
$rows = 0;
|
||||
|
||||
$deliveries = DBA::p("SELECT `uri-id`, `iid`, `item-delivery-data`.`postopts`, `item-delivery-data`.`inform`,
|
||||
`queue_count`, `queue_done`, `activitypub`, `dfrn`, `diaspora`, `ostatus`, `legacy_dfrn`, `queue_failed`
|
||||
FROM `item-delivery-data`
|
||||
INNER JOIN `item` ON `item`.`id` = `item-delivery-data`.`iid`
|
||||
WHERE `iid` >= ? ORDER BY `iid` LIMIT 10000", $id);
|
||||
|
||||
if (DBA::errorNo() != 0) {
|
||||
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($delivery = DBA::fetch($deliveries)) {
|
||||
$id = $delivery['iid'];
|
||||
unset($delivery['iid']);
|
||||
DBA::insert('post-delivery-data', $delivery);
|
||||
++$rows;
|
||||
}
|
||||
DBA::close($deliveries);
|
||||
|
||||
DI::config()->set('system', 'post_update_version_1345_id', $id);
|
||||
|
||||
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
|
||||
|
||||
// When there are less than 100 items processed this means that we reached the end
|
||||
// The other entries will then be processed with the regular functionality
|
||||
if ($rows < 100) {
|
||||
DI::config()->set('system', 'post_update_version', 1345);
|
||||
Logger::info('Done');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
use Friendica\Database\DBA;
|
||||
|
||||
if (!defined('DB_UPDATE_VERSION')) {
|
||||
define('DB_UPDATE_VERSION', 1343);
|
||||
define('DB_UPDATE_VERSION', 1345);
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
Loading…
Reference in a new issue