Added post update

This commit is contained in:
Michael 2020-01-05 09:10:32 +00:00
parent f183816b7d
commit a4268a973f

View File

@ -10,6 +10,7 @@ use Friendica\Core\Protocol;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\UserItem;
use Friendica\Model\PermissionSet;
/**
@ -40,6 +41,9 @@ class PostUpdate
if (!self::update1322()) {
return false;
}
if (!self::update1329()) {
return false;
}
return true;
}
@ -453,4 +457,52 @@ class PostUpdate
return true;
}
/**
* @brief update user-item data with notifications
*
* @return bool "true" when the job is done
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function update1329()
{
// Was the script completed?
if (Config::get('system', 'post_update_version') >= 1329) {
return true;
}
$id = Config::get('system', 'post_update_version_1329_id', 0);
Logger::info('Start', ['item' => $id]);
$start_id = $id;
$rows = 0;
$condition = ["`id` > ?", $id];
$params = ['order' => ['id'], 'limit' => 10000];
$items = DBA::select('item', ['id'], $condition, $params);
if (DBA::errorNo() != 0) {
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
return false;
}
while ($item = DBA::fetch($items)) {
UserItem::setNotification($item['id']);
++$rows;
}
DBA::close($items);
Config::set('system', 'post_update_version_1329_id', $id);
Logger::info('Processed', ['rows' => $rows, 'last' => $id]);
if ($start_id == $id) {
Config::set('system', 'post_update_version', 1329);
Logger::info('Done');
return true;
}
return false;
}
}