The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If Config::get() doesn't match it should return false
#1
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.
  Reply
#2
I agree.

Just curious. Did you run into something where that caused a problem?
  Reply
#3
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()
was returning the whole
Code:
$config
array and thus instead of a value I was getting an array in my variable.

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
directory...
  Reply
#4
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.
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)