Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array_key_exists null parameter error #13

Open
CrashSensei opened this issue Mar 22, 2016 · 0 comments
Open

array_key_exists null parameter error #13

CrashSensei opened this issue Mar 22, 2016 · 0 comments

Comments

@CrashSensei
Copy link

Upon attempting to use laravel-settings for the first time I receive the following error and stack trace upon trying to use the get method:

ErrorException in Arr.php line 145:
array_key_exists() expects parameter 2 to be array, null given
in Arr.php line 145
at HandleExceptions->handleError('2', 'array_key_exists() expects parameter 2 to be array, null given', 'H:\meej\files\php\projects\raven\vendor\laravel\framework\src\Illuminate\Support\Arr.php', '145', array('array' => null, 'key' => 'theme-color'))
at array_key_exists('theme-color', null) in Arr.php line 145
at Arr::exists(null, 'theme-color') in Arr.php line 269
at Arr::get(null, 'theme-color', 'blue') in helpers.php line 171
at array_get(null, 'theme-color', 'blue') in Setting.php line 105
at Setting->get('theme-color', 'blue') in Facade.php line 221
at Facade::__callStatic('get', array('theme-color', 'blue')) in ComposerServiceProvider.php line 34
at Facade::get('theme-color', 'blue') in ComposerServiceProvider.php line 34

From what I can tell this error is due to the fact that the users's db settings column is null. This is to be expected as the user at this time has no custom settings defined.

A quick fix would be to check for this situation:

--- src/Setting.php (revision )
+++ src/Setting.php (revision )
@@ -225,7 +225,7 @@
             ->value($this->column);

         $this->settings[$constraint_value] = json_decode($json, true);
-        
+        if($this->settings[$constraint_value] === null) $this->settings[$constraint_value] = array();

         $this->dirty[$constraint_value] = false;
         $this->loaded[$constraint_value] = true;

My PHP version is 5.6.14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant