bsmither Posted August 6, 2013 Share Posted August 6, 2013 Hmm. When I click the tab to Add New Administrator, PHP crashes, and I can't find the smoking gun that the error log is pointing to. Has anyone actually added a new administrator? Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 6, 2013 Share Posted August 6, 2013 I just added a Super User to the 5.2.2 dirtybutterestates site with no problems. Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 7, 2013 Author Share Posted August 7, 2013 Well, my problem is certainly something I did -- it's not a bug in CubeCart -- although I'm not too sure about the administrator management code either. It's really strange how the CubeCart PHP code is behaving on my development machine. A backup copy of CC522 is working fine. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 7, 2013 Share Posted August 7, 2013 Well, one thing's for sure - if you can't fix it - nobody else will be able to help! i'm sorry. Can you run something like Beyond Compare on the whole site and your backup and spot the difference? Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 7, 2013 Author Share Posted August 7, 2013 I did do a file compare on the latest working version and a version prepared for fresh experimenting. There are (of course) a number of differences, but no likely, or even unlikely, suspects. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 7, 2013 Share Posted August 7, 2013 Since I usually flounder around making all kinds of mistakes, I have managed to undo damage a few times by renaming and replacing whole directories, like classes, with a known good copy. Once I know which directory has the issue I can usually find the problem as I narrow it down to only the most recently modified files. Very Down and Dirty, and of course I don't make as many experimental changes as you do in the process of helping others, so I have fewer recently modified files. Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 8, 2013 Author Share Posted August 8, 2013 I found the problem. It is a case of my not realizing a side-effect of how PHP can and does express global variables. There are variables in a global scope (outside of functions) and there are Super-Globals, which can be seen everywhere. I have been working on an experiment where I was using the typical method of instantiating classes and assigning that class to a Super-Global. For example, here are statements the instantiate common classes needed to run CubeCart. The instances are assigned to the Super-Global array, $GLOBALS (a reserved variable name in PHP): $GLOBALS['cache'] = Cache::getInstance(); $GLOBALS['db'] = Database::getInstance($glob); $GLOBALS['config'] = Config::getInstance($glob); $GLOBALS['debug'] = Debug::getInstance(); $GLOBALS['session'] = Session::getInstance(); and others. Naturally, one would therefore use this to instantiate the admin class: $GLOBALS['admin'] = Admin::getInstance(); Not so fast. It seems that PHP will also make these instances of classes available with the respective global variables:$cache, $db, $config, $debug, $session, $admin, and all the others. So, if PHP is executing code in the global scope - not inside a function - as it is with many of the files in the admin/source folder, one cannot use any of the above variables. And yet, the Create New Admin portion of the settings.admin.inc.php file does that very thing. Conclusion: In the case of the Admin class, one must never assign the instance to $GLOBALS['admin'], but rather always communicate with the instance as Admin::getInstance(), because CubeCart may use the variable $admin elsewhere (in a global scope). Until that maybe changes in a future version. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 8, 2013 Share Posted August 8, 2013 Glad you found it! Obviously the kinds of in-depth experiments that you do would lead to unintended consequences from time to time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.