Fix fatal error
This commit is contained in:
parent
49c59fed2c
commit
b46b88cc10
|
@ -100,6 +100,9 @@ class PostUpdate
|
||||||
if (!self::update1426()) {
|
if (!self::update1426()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!self::update1427()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,4 +964,51 @@ class PostUpdate
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update the "uri-id" field in the event table
|
||||||
|
*
|
||||||
|
* @return bool "true" when the job is done
|
||||||
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
|
* @throws \ImagickException
|
||||||
|
*/
|
||||||
|
private static function update1427()
|
||||||
|
{
|
||||||
|
// Was the script completed?
|
||||||
|
if (DI::config()->get("system", "post_update_version") >= 1427) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$condition = ["`uri-id` IS NULL"];
|
||||||
|
Logger::info('Start', ['rest' => DBA::count('event', $condition)]);
|
||||||
|
|
||||||
|
$rows = 0;
|
||||||
|
$events = DBA::select('event', ['id', 'uri', 'guid'], $condition, ['limit' => 1000]);
|
||||||
|
|
||||||
|
if (DBA::errorNo() != 0) {
|
||||||
|
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($event = DBA::fetch($events)) {
|
||||||
|
if (!empty($event['guid'])) {
|
||||||
|
$uriid = ItemURI::insert(['uri' => $event['uri'], 'guid' => $event['guid']]);
|
||||||
|
} else {
|
||||||
|
$uriid = ItemURI::getIdByURI($event['uri']);
|
||||||
|
}
|
||||||
|
DBA::update('event', ['uri-id' => $uriid], ['id' => $event['id']]);
|
||||||
|
++$rows;
|
||||||
|
}
|
||||||
|
DBA::close($events);
|
||||||
|
|
||||||
|
Logger::info('Processed', ['rows' => $rows]);
|
||||||
|
|
||||||
|
if ($rows <= 100) {
|
||||||
|
DI::config()->set("system", "post_update_version", 1427);
|
||||||
|
Logger::info('Done');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -589,10 +589,10 @@ class Event
|
||||||
$last_date = '';
|
$last_date = '';
|
||||||
$fmt = DI::l10n()->t('l, F j');
|
$fmt = DI::l10n()->t('l, F j');
|
||||||
foreach ($event_result as $event) {
|
foreach ($event_result as $event) {
|
||||||
$item = Post::selectFirst(['plink', 'author-name', 'author-avatar', 'author-link', 'private'], ['id' => $event['itemid']]);
|
$item = Post::selectFirst(['plink', 'author-name', 'author-avatar', 'author-link', 'private', 'uri-id'], ['id' => $event['itemid']]);
|
||||||
if (!DBA::isResult($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
// Using default values when no item had been found
|
// Using default values when no item had been found
|
||||||
$item = ['plink' => '', 'author-name' => '', 'author-avatar' => '', 'author-link' => '', 'private' => Item::PUBLIC];
|
$item = ['plink' => '', 'author-name' => '', 'author-avatar' => '', 'author-link' => '', 'private' => Item::PUBLIC, 'uri-id' => ($event['uri-id'] ?? 0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = array_merge($event, $item);
|
$event = array_merge($event, $item);
|
||||||
|
|
Loading…
Reference in a new issue