From 73afcad34c244f17706d686669a02abc1b709708 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Sep 2011 17:05:32 -0400 Subject: [PATCH 1/2] add hooks for upgrades --- EVENTS.txt | 4 ++++ scripts/upgrade.php | 30 +++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 0a9759c246..922b79a865 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1418,3 +1418,7 @@ StartShowInvitationSuccess: Right before showing invitations success msg EndShowInvitationSuccess: After showing invitations success msg - $action: invitation action +StartUpgrade: when starting a site upgrade + +EndUpgrade: when ending a site upgrade; good place to do your own upgrades + diff --git a/scripts/upgrade.php b/scripts/upgrade.php index 4c793ac15e..1bf444267c 100644 --- a/scripts/upgrade.php +++ b/scripts/upgrade.php @@ -33,23 +33,27 @@ require_once INSTALLDIR.'/scripts/commandline.inc'; function main() { - updateSchemaCore(); - updateSchemaPlugins(); + if (Event::handle('StartUpgrade')) { + updateSchemaCore(); + updateSchemaPlugins(); - // These replace old "fixup_*" scripts + // These replace old "fixup_*" scripts - fixupNoticeRendered(); - fixupNoticeConversation(); - initConversation(); - initInbox(); - fixupGroupURI(); + fixupNoticeRendered(); + fixupNoticeConversation(); + initConversation(); + initInbox(); + fixupGroupURI(); - initLocalGroup(); - initNoticeReshare(); + initLocalGroup(); + initNoticeReshare(); - initFaveURI(); - initSubscriptionURI(); - initGroupMemberURI(); + initFaveURI(); + initSubscriptionURI(); + initGroupMemberURI(); + + Event::handle('EndUpgrade'); + } } function tableDefs() From 6e480d2458bf4039ee0446187893203cd533dc40 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Sep 2011 17:06:05 -0400 Subject: [PATCH 2/2] Upgrade 0.9.x bookmarks to 1.0.x --- plugins/Bookmark/BookmarkPlugin.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index 77b8a8483c..ff68917bcc 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -551,4 +551,25 @@ class BookmarkPlugin extends MicroAppPlugin // TRANS: Application title. return _m('TITLE','Bookmark'); } + + function onEndUpgrade() + { + // Version 0.9.x of the plugin didn't stamp notices + // with verb and object-type (for obvious reasons). Update + // those notices here. + + $notice = new Notice(); + + $notice->whereAdd('exists (select uri from bookmark where bookmark.uri = notice.uri)'); + $notice->whereAdd('((object_type is null) or (object_type = "' .ActivityObject::NOTE.'"))'); + + $notice->find(); + + while ($notice->fetch()) { + $original = clone($notice); + $notice->verb = ActivityVerb::POST; + $notice->object_type = ActivityObject::BOOKMARK; + $notice->update($original); + } + } }