summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorfisharebest <fisharebest@gmail.com>2011-06-07 22:55:27 +0000
committerfisharebest <fisharebest@gmail.com>2011-06-07 22:55:27 +0000
commitf439717a8ca4dded13da2dd693c09ad0268ed619 (patch)
tree9d723f092515f08800ddbb4322bc02669e1044f3 /includes
parent6b8a8a680d990393f4c7a8a1aa15a018cc314100 (diff)
downloadwebtrees-f439717a8ca4dded13da2dd693c09ad0268ed619.tar.gz
webtrees-f439717a8ca4dded13da2dd693c09ad0268ed619.tar.bz2
webtrees-f439717a8ca4dded13da2dd693c09ad0268ed619.zip
Fix: webtrees-1.1.2 changed the "full name" column in wt_name to include the slashes. The individual/family lists require that the name is saved the same as the way it is generated by the WT_Person object. Therefore upgrading to/from 1.1.2 causes records not to show - until they are edited or re-imported. Revert to the original behaviour (no slashes), and update the database to remove any that were added by 1.1.2.
Also remove the n_list column. It has never been used.
Diffstat (limited to 'includes')
-rw-r--r--includes/db_schema/db_schema_11_12.php54
-rw-r--r--includes/functions/functions_import.php8
-rw-r--r--includes/session.php2
3 files changed, 59 insertions, 5 deletions
diff --git a/includes/db_schema/db_schema_11_12.php b/includes/db_schema/db_schema_11_12.php
new file mode 100644
index 0000000000..2f440123d7
--- /dev/null
+++ b/includes/db_schema/db_schema_11_12.php
@@ -0,0 +1,54 @@
+<?php
+// Update the database schema from version 11 to 12
+// - delete the wt_name.n_list column; it has never been used
+// - a bug in webtrees 1.1.2 caused the wt_name.n_full column
+// to include slashes around the surname. These are unnecessary,
+// and cause problems when we try to match the name from the
+// gedcom with the name from the table.
+//
+// The script should assume that it can be interrupted at
+// any point, and be able to continue by re-running the script.
+// Fatal errors, however, should be allowed to throw exceptions,
+// which will be caught by the framework.
+// It shouldn't do anything that might take more than a few
+// seconds, for systems with low timeout values.
+//
+// webtrees: Web based Family History software
+// Copyright (C) 2011 Greg Roach
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// @version $Id: db_schema_10_11.php 11634 2011-05-28 17:26:04Z greg $
+
+if (!defined('WT_WEBTREES')) {
+ header('HTTP/1.0 403 Forbidden');
+ exit;
+}
+
+define('WT_DB_SCHEMA_11_12', '');
+
+// Remove slashes from INDI names
+self::exec("UPDATE `##name` SET n_full=REPLACE(n_full, '/', '') WHERE n_surn IS NOT NULL");
+
+// Remove the n_list column
+try {
+ self::exec("ALTER TABLE `##name` DROP n_list");
+} catch (PDOException $x) {
+ // Already done?
+}
+
+// Update the version to indicate success
+set_site_setting($schema_name, $next_version);
+
diff --git a/includes/functions/functions_import.php b/includes/functions/functions_import.php
index 425a3d0a13..6c6ac79d8b 100644
--- a/includes/functions/functions_import.php
+++ b/includes/functions/functions_import.php
@@ -890,8 +890,8 @@ function update_names($xref, $ged_id, $record) {
static $sql_insert_name_indi=null;
static $sql_insert_name_other=null;
if (!$sql_insert_name_indi) {
- $sql_insert_name_indi=WT_DB::prepare("INSERT INTO `##name` (n_file,n_id,n_num,n_type,n_sort,n_full,n_list,n_surname,n_surn,n_givn,n_soundex_givn_std,n_soundex_surn_std,n_soundex_givn_dm,n_soundex_surn_dm) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
- $sql_insert_name_other=WT_DB::prepare("INSERT INTO `##name` (n_file,n_id,n_num,n_type,n_sort,n_full,n_list) VALUES (?,?,?,?,?,?,?)");
+ $sql_insert_name_indi=WT_DB::prepare("INSERT INTO `##name` (n_file,n_id,n_num,n_type,n_sort,n_full,n_surname,n_surn,n_givn,n_soundex_givn_std,n_soundex_surn_std,n_soundex_givn_dm,n_soundex_surn_dm) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)");
+ $sql_insert_name_other=WT_DB::prepare("INSERT INTO `##name` (n_file,n_id,n_num,n_type,n_sort,n_full) VALUES (?,?,?,?,?,?)");
}
if ($record->getType()!='FAM' && $record->getXref()) {
@@ -911,9 +911,9 @@ function update_names($xref, $ged_id, $record) {
$soundex_surn_std="'".soundex_std($name['surname'])."'";
$soundex_surn_dm="'".soundex_dm($name['surname'])."'";
}
- $sql_insert_name_indi->execute(array($ged_id, $xref, $n, $name['type'], $name['sort'], $name['fullNN'], $name['listNN'], $name['surname'], $name['surn'], $name['givn'], $soundex_givn_std, $soundex_surn_std, $soundex_givn_dm, $soundex_surn_dm));
+ $sql_insert_name_indi->execute(array($ged_id, $xref, $n, $name['type'], $name['sort'], $name['fullNN'], $name['surname'], $name['surn'], $name['givn'], $soundex_givn_std, $soundex_surn_std, $soundex_givn_dm, $soundex_surn_dm));
} else {
- $sql_insert_name_other->execute(array($ged_id, $xref, $n, $name['type'], $name['sort'], $name['full'], $name['list']));
+ $sql_insert_name_other->execute(array($ged_id, $xref, $n, $name['type'], $name['sort'], $name['full']));
}
}
}
diff --git a/includes/session.php b/includes/session.php
index dd9411fcbc..bb4d74d3a9 100644
--- a/includes/session.php
+++ b/includes/session.php
@@ -52,7 +52,7 @@ define('WT_DEBUG_SQL', false);
define('WT_ERROR_LEVEL', 2); // 0=none, 1=minimal, 2=full
// Required version of database tables/columns/indexes/etc.
-define('WT_SCHEMA_VERSION', 11);
+define('WT_SCHEMA_VERSION', 12);
// Regular expressions for validating user input, etc.
define('WT_REGEX_XREF', '[A-Za-z0-9:_-]+');