Page 1 of 1

[Not a bug] deleting a default design is possible

Posted: Mon Apr 20, 2015 5:26 pm
by bess
there is no test in the code so it is possible to delete the default design

Code: Select all

$design = CmsLayoutCollection::load("the default design");
$design->delete();
After that you can't do anything more : modify page or setting a new "default" design will display this error :
Fatal error: Uncaught exception 'CmsInvalidDataException' with message 'There is no default design selected' in D:\www\forge2\lib\classes\class.CmsLayoutCollection.php on line 657
( ! ) CmsInvalidDataException: There is no default design selected in D:\www\forge2\lib\classes\class.CmsLayoutCollection.php on line 657
Call Stack
# Time Memory Function Location
1 0.0022 280368 {main}( ) ..\moduleinterface.php:0
2 0.2693 9017720 CMSModule->DoActionBase( ) ..\moduleinterface.php:76
3 0.2694 9020776 DesignManager->DoAction( ) ..\class.CMSModule.php:1446
4 0.2695 9020896 CMSModule->DoAction( ) ..\DesignManager.module.php:56
5 0.2709 9111424 include( 'D:\www\forge2\modules\DesignManager\action.defaultadmin.php' ) ..\class.CMSModule.php:1382
6 0.2773 9414744 CmsLayoutCollection::load_default( ) ..\action.defaultadmin.php:58
my solution : editing the database directly

deleting a default design (or tpl / ...) should be forbidden and throwing an exception ;)

Re: [major] deleting a default design is possible

Posted: Mon Apr 20, 2015 5:28 pm
by bess
in the same way : we don't check if the design / tpl is used by a page (if type = core::page) but i'm not sure you want to do this. ;)

Re: [major] deleting a default design is possible

Posted: Mon Apr 20, 2015 5:38 pm
by calguy1000
I don't think that all of these decisions and checks are needed in the API's. It's more of an application level issue if the user can delete the default design (the design manager doesn't let you do this).

As well, the application level should check to see if the design is in use on any pages before letting you delete it, etc. but that check doesn't need to be in the API's.

Re: [major] deleting a default design is possible

Posted: Mon Apr 20, 2015 6:15 pm
by bess
since it's not a feature forgotten, i'm okay with that :)