diff --git a/scripts/updateuris.php b/scripts/updateuris.php new file mode 100644 index 0000000000..af7ae61e7b --- /dev/null +++ b/scripts/updateuris.php @@ -0,0 +1,74 @@ +#!/usr/bin/env php +. + */ + +/** + * Update User URIs. + * + * @package GNUsocial + * @author Bruno Casteleiro + * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org + * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later + */ + +define('INSTALLDIR', dirname(__FILE__, 2)); +define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public'); + +$shortoptions = ''; +$longoptions = array(); + +$helptext = <<find()) { + while ($user->fetch()) { + printfv("Updating user {$user->nickname}..."); + try { + updateUserUri($user); + } catch(Exception $e) { + echo "\nError updating {$user->nickname} URI: " . $e->getMessage() . "\n"; + } + printfv("DONE.\n"); + } + } +} + +function updateUserUri($user) +{ + $orig = clone($user); + $user->uri = common_user_uri($user); + $user->updateWithKeys($orig); +} + +main();