From 1df9ec9f0fc04796202ece1603c4182e37833156 Mon Sep 17 00:00:00 2001 From: tenma Date: Mon, 28 Oct 2019 16:27:05 +0000 Subject: [PATCH] [SCRIPTS] Add updateuris script To fix user URIs to their non-fancy version --- scripts/updateuris.php | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 scripts/updateuris.php 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();