From a3cf563b6836391ff4d07335cf25189c7a06418e Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 24 Feb 2012 20:40:09 -0800 Subject: [PATCH] update author name across items if changed. --- boot.php | 2 +- database.sql | 1 + include/items.php | 18 +++++++++++++++++- update.php | 6 +++++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/boot.php b/boot.php index 4dd16c940d..0815f59f68 100755 --- a/boot.php +++ b/boot.php @@ -11,7 +11,7 @@ require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_VERSION', '2.3.1262' ); define ( 'DFRN_PROTOCOL_VERSION', '2.22' ); -define ( 'DB_UPDATE_VERSION', 1124 ); +define ( 'DB_UPDATE_VERSION', 1125 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/database.sql b/database.sql index e051cdaac5..f4199cb55a 100755 --- a/database.sql +++ b/database.sql @@ -257,6 +257,7 @@ CREATE TABLE IF NOT EXISTS `item` ( KEY `last-child` (`last-child`), KEY `unseen` (`unseen`), KEY `wall` (`wall`), + KEY `author-name` (`author-name`), KEY `author-link` (`author-link`), FULLTEXT KEY `title` (`title`), FULLTEXT KEY `body` (`body`), diff --git a/include/items.php b/include/items.php index ba4ec036fe..de3ade6b4e 100755 --- a/include/items.php +++ b/include/items.php @@ -1308,12 +1308,28 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) } if((is_array($contact)) && ($name_updated) && (strlen($new_name)) && ($name_updated > $contact['name-date'])) { - q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", + $r = q("select * from contact where uid = %d and id = %d limit 1", + intval($contact['uid']), + intval($contact['id']) + ); + + $x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", dbesc(notags(trim($new_name))), dbesc(datetime_convert()), intval($contact['uid']), intval($contact['id']) ); + + // do our best to update the name on content items + + if(count($r)) { + q("update item set `author-name` = '%s' where `author-name` = '%s' and `author-link` = '%s' and uid = %d", + dbesc(notags(trim($new_name))), + dbesc($r[0]['name']), + dbesc($r[0]['url']), + intval($contact['uid']) + ); + } } if(strlen($birthday)) { diff --git a/update.php b/update.php index 07555bc019..0096754d20 100755 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@