From 2363de0ba2fa5cbf3037452d6119d614d988efce Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Thu, 25 Aug 2011 10:34:52 -0700 Subject: Fixing blog upgrades for excerpt. --- mod/blog/start.php | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/mod/blog/start.php b/mod/blog/start.php index b9911aa74..d00196bfd 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -225,11 +225,37 @@ function blog_ecml_views_hook($hook, $entity_type, $return_value, $params) { } /** - * When upgrading, check if the ElggBlog class has been registered as this - * was added in Elgg 1.8 + * Upgrade from 1.7 to 1.8. */ -function blog_run_upgrades() { - if (!update_subtype('object', 'blog', 'ElggBlog')) { - add_subtype('object', 'blog', 'ElggBlog'); +function blog_run_upgrades($event, $type, $details) { + $blog_upgrade_version = get_plugin_setting('upgrade_version', 'blogs'); + + if (!$blog_upgrade_version) { + // When upgrading, check if the ElggBlog class has been registered as this + // was added in Elgg 1.8 + if (!update_subtype('object', 'blog', 'ElggBlog')) { + add_subtype('object', 'blog', 'ElggBlog'); + } + + // only run this on the first migration to 1.8 + if ($details->to >= 2011061200) { + // add excerpt to all blogs that don't have it. + $ia = elgg_set_ignore_access(true); + $options = array( + 'type' => 'object', + 'subtype' => 'blog' + ); + + $blogs = new ElggBatch($options); + foreach ($blogs as $blog) { + if (!$blog->excerpt) { + $blog->excerpt = elgg_get_excerpt($blog->description); + } + } + + elgg_set_ignore_access($ia); + } + + elgg_set_plugin_setting('upgrade_version', 1, 'blogs'); } } -- cgit v1.2.3 From a0d6ee9cb451bcd016a16ff1cc43fdb630786d08 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Thu, 25 Aug 2011 10:39:22 -0700 Subject: Removed silly check for elgg version. --- mod/blog/start.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/mod/blog/start.php b/mod/blog/start.php index d00196bfd..a92f5cf85 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -238,24 +238,22 @@ function blog_run_upgrades($event, $type, $details) { } // only run this on the first migration to 1.8 - if ($details->to >= 2011061200) { - // add excerpt to all blogs that don't have it. - $ia = elgg_set_ignore_access(true); - $options = array( - 'type' => 'object', - 'subtype' => 'blog' - ); - - $blogs = new ElggBatch($options); - foreach ($blogs as $blog) { - if (!$blog->excerpt) { - $blog->excerpt = elgg_get_excerpt($blog->description); - } - } + // add excerpt to all blogs that don't have it. + $ia = elgg_set_ignore_access(true); + $options = array( + 'type' => 'object', + 'subtype' => 'blog' + ); - elgg_set_ignore_access($ia); + $blogs = new ElggBatch($options); + foreach ($blogs as $blog) { + if (!$blog->excerpt) { + $blog->excerpt = elgg_get_excerpt($blog->description); + } } + elgg_set_ignore_access($ia); + elgg_set_plugin_setting('upgrade_version', 1, 'blogs'); } } -- cgit v1.2.3 From 51f3c3ea8549d465fafa9c1817aa6f8cf334a404 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Thu, 25 Aug 2011 11:03:02 -0700 Subject: Fixes #3558. Added upgrade for excerpt in blogs. --- mod/blog/start.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/blog/start.php b/mod/blog/start.php index a92f5cf85..2d8f75ed2 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -245,7 +245,7 @@ function blog_run_upgrades($event, $type, $details) { 'subtype' => 'blog' ); - $blogs = new ElggBatch($options); + $blogs = new ElggBatch('elgg_get_entities', $options); foreach ($blogs as $blog) { if (!$blog->excerpt) { $blog->excerpt = elgg_get_excerpt($blog->description); -- cgit v1.2.3