Adds script to fix names issues.
authorStéphane Jacob <sj@m4x.org>
Sun, 3 Jun 2012 10:37:47 +0000 (12:37 +0200)
committerStéphane Jacob <sj@m4x.org>
Sun, 3 Jun 2012 10:37:47 +0000 (12:37 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
upgrade/1.1.5/xxx_fix_names.php [new file with mode: 0755]

diff --git a/upgrade/1.1.5/xxx_fix_names.php b/upgrade/1.1.5/xxx_fix_names.php
new file mode 100755 (executable)
index 0000000..0660ede
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/php5
+<?php
+require_once 'connect.db.inc.php';
+require_once '../../include/name.func.inc.php';
+
+$pids = XDB::fetchOneRow("SELECT  pid
+                            FROM  profile_public_names
+                           WHERE  firstname_ordinary = '0' OR lastname_marital = '0' OR lastname_ordinary = '0'");
+
+XDB::execute("UPDATE  profile_public_names
+                 SET  firstname_ordinary = ''
+               WHERE  firstname_ordinary = '0'");
+XDB::execute("UPDATE  profile_public_names
+                 SET  lastname_ordinary = ''
+               WHERE  lastname_ordinary = '0'");
+XDB::execute("UPDATE  profile_public_names
+                 SET  lastname_ordinary = ''
+               WHERE  lastname_ordinary = '0'");
+
+foreach ($pids as $pid) {
+    $profile = Profile::get($pid);
+    $item = XDB::fetchOneAssoc('SELECT  *
+                                  FROM  profile_public_names
+                                 WHERE  pid = {?}', $pid);
+    update_display_names($profile, $item);
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>