From: <an...@us...> - 2007-04-20 22:21:04
|
Revision: 16336 http://svn.sourceforge.net/gallery/?rev=16336&view=rev Author: andy_st Date: 2007-04-20 15:21:03 -0700 (Fri, 20 Apr 2007) Log Message: ----------- Only remove obsolete blocks of the module that is being activated. Else we'd remove default blocks that themes register at installation time for modules that aren't available (yet). Modified Paths: -------------- trunk/gallery2/modules/core/classes/GalleryModule.class trunk/gallery2/modules/core/test/phpunit/ModuleTest.class Modified: trunk/gallery2/modules/core/classes/GalleryModule.class =================================================================== --- trunk/gallery2/modules/core/classes/GalleryModule.class 2007-04-20 21:03:53 UTC (rev 16335) +++ trunk/gallery2/modules/core/classes/GalleryModule.class 2007-04-20 22:21:03 UTC (rev 16336) @@ -687,7 +687,7 @@ $blockName = $blockInfo[1]; /* Remove used block if it is not available any more. */ - if (!isset($blocks[$pluginName][$blockName])) { + if ($pluginName == $this->getId() && !isset($blocks[$pluginName][$blockName])) { unset($themeBlocks[$key]); $ret = GalleryCoreApi::setPluginParameter( 'theme', $themeId, $paramName, serialize($themeBlocks), $itemId); Modified: trunk/gallery2/modules/core/test/phpunit/ModuleTest.class =================================================================== --- trunk/gallery2/modules/core/test/phpunit/ModuleTest.class 2007-04-20 21:03:53 UTC (rev 16335) +++ trunk/gallery2/modules/core/test/phpunit/ModuleTest.class 2007-04-20 22:21:03 UTC (rev 16336) @@ -99,18 +99,24 @@ return $ret; } - /* Add bogus used theme blocks to test if they're removed after activate(). Bug #1636339 */ + /* + * Add bogus used theme blocks to test if they're removed after activate(). Bug #1636339 + * For now not testing false positives in the same module since we can't easily inject + * blocks into loadAvailableBlocks(). + */ $ret = GalleryCoreApi::setPluginParameter('theme', 'bogusTheme', 'albumBlocks', - serialize(array(array('bogusTheme.someBlock', array())))); + serialize(array(array('moduletest.missingBlock', array())))); if ($ret) { return $ret; } $ret = GalleryCoreApi::setPluginParameter('theme', 'bogusTheme', 'albumBlocks', - serialize(array(array('bogusTheme.someBlock', array()))), 42); + serialize(array(array('bogusModule.someBlock', array()), + array('moduletest.missingBlock', array()))), + 42); if ($ret) { return $ret; } - + /* Add a real theme block if one is available, that should not be removed. */ list ($ret, $blocks) = GalleryCoreApi::loadAvailableBlocks(); if ($ret) { @@ -194,6 +200,34 @@ return $ret; } + /* Verify that the bogus blocks have been removed from the theme. */ + list ($ret, $bogusBlock) = + GalleryCoreApi::getPluginParameter('theme', 'bogusTheme', 'albumBlocks'); + if ($ret) { + return $ret; + } + $this->assertEquals(array(), unserialize($bogusBlock), 'bogusTheme general parameter'); + list ($ret, $bogusBlock) = + GalleryCoreApi::getPluginParameter('theme', 'bogusTheme', 'albumBlocks', 42); + if ($ret) { + return $ret; + } + $this->assertEquals(array(array('bogusModule.someBlock', array())), + unserialize($bogusBlock), + 'bogusTheme parameter'); + + /* Make sure the real block hasn't been removed. */ + if ($blockAvailable) { + list ($ret, $realBlock) = + GalleryCoreApi::getPluginParameter('theme', 'bogusTheme', 'albumBlocks', 1337); + if ($ret) { + return $ret; + } + $this->assertEquals(array(array("$pluginName.$blockName", array())), + unserialize($realBlock), + 'Real block removed!'); + } + /* Deactivate the module */ list ($ret, $redirect) = $module->deactivate(); if ($ret) { @@ -264,32 +298,6 @@ list ($ret) = $entity->refresh(); $this->assertEquals(GALLERY_ERROR | ERROR_MISSING_OBJECT, $ret->getErrorCode(), 'entity'); - /* Verify that the bogus blocks have been removed from the theme. */ - list ($ret, $bogusBlock) = - GalleryCoreApi::getPluginParameter('theme', 'bogusTheme', 'albumBlocks'); - if ($ret) { - return $ret; - } - $this->assertEquals(array(), unserialize($bogusBlock), 'bogusTheme general parameter'); - list ($ret, $bogusBlock) = - GalleryCoreApi::getPluginParameter('theme', 'bogusTheme', 'albumBlocks', 42); - if ($ret) { - return $ret; - } - $this->assertEquals(array(), unserialize($bogusBlock), 'bogusTheme parameter'); - - /* Make sure the real block hasn't been removed. */ - if ($blockAvailable) { - list ($ret, $realBlock) = - GalleryCoreApi::getPluginParameter('theme', 'bogusTheme', 'albumBlocks', 1337); - if ($ret) { - return $ret; - } - $this->assertEquals(array(array("$pluginName.$blockName", array())), - unserialize($realBlock), - 'Real block removed!'); - } - /* Remove all references to the bogus theme from the database. */ $ret = GalleryCoreApi::removeMapEntry('GalleryPluginParameterMap', array('pluginId' => 'bogusTheme')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |