From 4b19f1801d29c6441b0f2aaa08ed834df1a0e056 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 30 Mar 2013 15:21:51 -0400 Subject: fixed upgrade script - was skipping pages because we were changing the results between calls to ElggBatch --- mod/pages/upgrades/2012061800.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'mod/pages') diff --git a/mod/pages/upgrades/2012061800.php b/mod/pages/upgrades/2012061800.php index fe39faea5..c21ccae3b 100644 --- a/mod/pages/upgrades/2012061800.php +++ b/mod/pages/upgrades/2012061800.php @@ -1,21 +1,26 @@ guid); +function pages_2012061800($page) { $dbprefix = elgg_get_config('dbprefix'); - $subtype_id = add_subtype('object', 'page_top'); + $subtype_id = (int)get_subtype_id('object', 'page_top'); + $page_guid = (int)$page->guid; update_data("UPDATE {$dbprefix}entities - set subtype='$subtype_id' WHERE guid=$page->guid"); + SET subtype = $subtype_id WHERE guid = $page_guid"); + error_log("called"); return true; } @@ -23,8 +28,11 @@ $previous_access = elgg_set_ignore_access(true); $dbprefix = elgg_get_config('dbprefix'); $name_metastring_id = get_metastring_id('parent_guid'); +if (!$name_metastring_id) { + return; +} -// Looking for pages without metadata (see #3046) +// Looking for pages without metadata $options = array( 'type' => 'object', 'subtype' => 'page', @@ -33,11 +41,9 @@ $options = array( WHERE md.entity_guid = e.guid AND md.name_id = $name_metastring_id)" ); -$batch = new ElggBatch('elgg_get_entities_from_metadata', $options, 'pages_2012061800', 100); +$batch = new ElggBatch('elgg_get_entities_from_metadata', $options, 'pages_2012061800', 50, false); elgg_set_ignore_access($previous_access); if ($batch->callbackResult) { error_log("Elgg Pages upgrade (2012061800) succeeded"); -} else { - error_log("Elgg Pages upgrade (2012061800) failed"); } -- cgit v1.2.3