]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #2910 set the site_guid of site entities
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 12 Jun 2011 21:07:49 +0000 (21:07 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 12 Jun 2011 21:07:49 +0000 (21:07 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@9192 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/classes/ElggSite.php
engine/lib/upgrades/2011061200-1.8b1-sites_need_a_site_guid-6d9dcbf46c0826cc.php [new file with mode: 0644]
version.php

index 30b222c2484d58957ac93008a4fa48f6f5380380..e3b8b8f1a7478d03934956e2f0750e8a2eea8d2f 100644 (file)
@@ -148,11 +148,20 @@ class ElggSite extends ElggEntity {
         * @return bool
         */
        public function save() {
+               global $CONFIG;
+
                // Save generic stuff
                if (!parent::save()) {
                        return false;
                }
 
+               // make sure the site guid is set (if not, set to self)
+               if (!$this->get('site_guid')) {
+                       $guid = $this->get('guid');
+                       update_data("UPDATE {$CONFIG->dbprefix}entities SET site_guid=$guid
+                               WHERE guid=$guid");
+               }
+
                // Now save specific stuff
                return create_site_entity($this->get('guid'), $this->get('name'),
                        $this->get('description'), $this->get('url'));
diff --git a/engine/lib/upgrades/2011061200-1.8b1-sites_need_a_site_guid-6d9dcbf46c0826cc.php b/engine/lib/upgrades/2011061200-1.8b1-sites_need_a_site_guid-6d9dcbf46c0826cc.php
new file mode 100644 (file)
index 0000000..4fc59ac
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Elgg 1.8b1 upgrade 2011061200
+ * sites_need_a_site_guid
+ *
+ * Sites did not have a site guid. This causes problems with getting
+ * metadata on site objects since we default to the current site.
+ */
+
+global $CONFIG;
+
+$ia = elgg_set_ignore_access(true);
+$access_status = access_get_show_hidden_status();
+access_show_hidden_entities(true);
+
+$options = array(
+       'type' => 'site',
+       'site_guid' => 0,
+);
+$batch = new ElggBatch('elgg_get_entities', $options);
+
+foreach ($batch as $entity) {
+       if (!$entity->site_guid) {
+               update_data("UPDATE {$CONFIG->dbprefix}entities SET site_guid=$entity->guid
+                               WHERE guid=$entity->guid");
+       }
+}
+
+access_show_hidden_entities($access_status);
+elgg_set_ignore_access($ia);
index d1cc63aef985c4243f9d8c3b3b68cc45607cd80c..9d3bf43e325c433e66dccd37a695084a2a4a98b0 100644 (file)
@@ -11,7 +11,7 @@
 
 // YYYYMMDD = Elgg Date
 // XX = Interim incrementer
-$version = 2011052801;
+$version = 2011061200;
 
 // Human-friendly version name
 $release = '1.8b1';