]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #1708. Moving up subpages when delete a page wasn't be applied in page_top...
authorSem <sembrestels@riseup.net>
Sun, 8 Jul 2012 11:23:40 +0000 (13:23 +0200)
committercash <cash.costello@gmail.com>
Sat, 30 Mar 2013 18:40:04 +0000 (14:40 -0400)
mod/pages/actions/pages/delete.php

index 7a314a280323eae98ae0c159f354cb0a97ec841d..fbb4cf55143315f997a50599442a4911ae8bc8aa 100644 (file)
@@ -23,6 +23,23 @@ if (elgg_instanceof($page, 'object', 'page') || elgg_instanceof($page, 'object',
                if ($children) {
                        foreach ($children as $child) {
                                $child->parent_guid = $parent;
+                               
+                               // If no parent, we need to transform $child in a page_top
+                               if ($parent == 0) {
+                                       $dbprefix = elgg_get_config('dbprefix');
+                                       $subtype_id = add_subtype('object', 'page_top');
+                                       update_data("UPDATE {$dbprefix}entities
+                                               set subtype='$subtype_id' WHERE guid=$child->guid");
+                                       
+                                       // If memcache is available then delete this entry from the cache
+                                       static $newentity_cache;
+                                       if ((!$newentity_cache) && (is_memcache_available())) {
+                                               $newentity_cache = new ElggMemcache('new_entity_cache');
+                                       }
+                                       if ($newentity_cache) {
+                                               $newentity_cache->delete($guid);
+                                       }
+                               }
                        }
                }