diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-09 03:09:57 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-09 03:09:57 +0000 |
commit | 31c056cf10bfdf8c6185c69f8fbad06b8998958c (patch) | |
tree | ef0ecf3633a5601a733d2a79abb2350cf8d630d4 /mod/groups | |
parent | bdb5d2b95792782ebc379e3348cad1812c1980b4 (diff) | |
download | elgg-31c056cf10bfdf8c6185c69f8fbad06b8998958c.tar.gz elgg-31c056cf10bfdf8c6185c69f8fbad06b8998958c.tar.bz2 |
Fixes #2679 added a script to upgrade forum topics from 1.7 and earlier
git-svn-id: http://code.elgg.org/elgg/trunk@8640 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/groups')
-rw-r--r-- | mod/groups/upgrades/2011030101.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/mod/groups/upgrades/2011030101.php b/mod/groups/upgrades/2011030101.php new file mode 100644 index 000000000..c2a80c08c --- /dev/null +++ b/mod/groups/upgrades/2011030101.php @@ -0,0 +1,53 @@ +<?php +/** + * Move text of first annotation to group forum topic object and delete annotation + * + * First determine if the upgrade is needed and then if needed, batch the update + */ + +$topics = elgg_get_entities(array( + 'type' => 'object', + 'subtype' => 'groupforumtopic', + 'limit' => 5, +)); + +// if not topics, no upgrade required +if (!$topics) { + return; +} + +// if all five of the topics have empty descriptions, we need to upgrade +foreach ($topics as $topic) { + if ($topic->description) { + return; + } +} + + +/** + * Condense annotation into object + * + * @param ElggObject $topic + */ +function groups_2011030101($topic) { + + $annotation = $topic->getAnnotations('group_topic_post', 1); + if (!$annotation) { + // no text for this forum post so we delete (probably caused by #2624) + return $topic->delete(); + } + + $topic->description = $annotation[0]->value; + $topic->save(); + + return $annotation[0]->delete(); +} + +$options = array('type' => 'object', 'subtype' => 'groupforumtopic'); +$batch = new ElggBatch('elgg_get_entities', $options, 'groups_2011030101', 100); + +if ($batch->callbackResult) { + error_log("Elgg Groups upgrade (2011030101) succeeded"); +} else { + error_log("Elgg Groups upgrade (2011030101) failed"); +} |