The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
If Config::get() doesn't match it should return false - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: If Config::get() doesn't match it should return false (/showthread.php?tid=235) |
If Config::get() doesn't match it should return false - plb - 09-01-2016 Please see this paste: http://pastebin.com/hXtASj6S If the value is not found in Config then we shouldn't get back the whole $_GLOBALS['config'] - instead we should get a false return value so we can handle that and provide an appropriate default. If Config::get() doesn't match it should return false - mudmin - 09-01-2016 I agree. Just curious. Did you run into something where that caused a problem? If Config::get() doesn't match it should return false - plb - 09-02-2016 Not in UserSpice, but in my own app. My philosophy in starting with UserSpice is that I want to build on the framework that is there to the greatest extent possible (not reinventing the wheel). Thus since you had a config class already in place I just add my config elements to your system. However, my basic approach to configured elements is to always provide a (hopefully reasonable) default. So I always check if the item exists in the Config file and, if not, I provide this default like this: Code: $myCfgItem = Config::get('myapp/mycfgitem') ? : 'my default'; What I ran into was that the Code: Config::get() Code: $config It's very possible I'm not using Config in the way it was intended - for all my suggestions please take them as just that: suggestions. I will confess I'm going to have a bear of a time the next time I upgrade UserSpice... :-) But that's on my head - you clearly communicated that I should use the Code: usersc If Config::get() doesn't match it should return false - mudmin - 09-02-2016 That makes a lot of sense. Plus, it's just good practice to return false in that situation. I have that noted. Regarding upgrades... Are you modifying the userspice code? That usersc folder works pretty great. If you want a modded admin.php then you just copy ours, put it in that folder, make sure the path to the init is right, and from that point on, yours will show up instead of ours. Even if you've modified existing code, you can put yours in there. We are also making a place for modified functions so that you can just make your own and our upgrades won't knock off your stuff. Beyond that, there is a full diff of every single change so you can copy/paste if you have to. Just go to https://github.com/mudmin/UserSpice4/commits/master and click on that 7 digit code on the right and you'll get a list of which files changed and the +/- for every one. |