mirror of
https://github.com/friendica/friendica
synced 2025-04-25 05:50:12 +00:00
Issue 11893: Postupdate to fix wrong parents
This commit is contained in:
parent
f0622163b2
commit
ec8377a8c7
2 changed files with 56 additions and 0 deletions
|
@ -111,6 +111,9 @@ class PostUpdate
|
|||
if (!self::update1452()) {
|
||||
return false;
|
||||
}
|
||||
if (!self::update1483()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1085,4 +1088,37 @@ class PostUpdate
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the parent.
|
||||
* This fixes a bug that was introduced in the development of version 2022.09
|
||||
*
|
||||
* @return bool "true" when the job is done
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function update1483()
|
||||
{
|
||||
// Was the script completed?
|
||||
if (DI::config()->get('system', 'post_update_version') >= 1483) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Logger::info('Start');
|
||||
|
||||
$posts = DBA::select('post-view', ['uri-id'], ['conversation' => './']);
|
||||
while ($post = DBA::fetch($posts)) {
|
||||
echo $post['uri-id'] . "\n";
|
||||
$parent = Item::getParent($post['uri-id']);
|
||||
if ($parent != 0) {
|
||||
DBA::update('post', ['parent-uri-id' => $parent], ['uri-id' => $post['uri-id']]);
|
||||
DBA::update('post-user', ['parent-uri-id' => $parent], ['uri-id' => $post['uri-id']]);
|
||||
}
|
||||
}
|
||||
DBA::close($posts);
|
||||
|
||||
DI::config()->set('system', 'post_update_version', 1483);
|
||||
Logger::info('Done');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue