Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Undefined index: user_agent #1153

Closed
markbratanov opened this issue Aug 10, 2015 · 8 comments
Closed

Undefined index: user_agent #1153

markbratanov opened this issue Aug 10, 2015 · 8 comments

Comments

@markbratanov
Copy link

Currently receiving this error on a fresh install:

A PHP Error was encountered
Severity: Notice
Message: Undefined index: user_agent
Filename: MX/Loader.php
Line Number: 174

Backtrace:

File: /home/site/path/content/application/third_party/MX/Loader.php
Line: 174
Function: _error_handler

File: /home/site/path/content/bonfire/libraries/Template.php
Line: 732
Function: library

File: /home/site/path/content/bonfire/libraries/Template.php
Line: 880
Function: themeView

File: /home/site/public_html/sites/path.com/content/themes/default/index.php
Line: 1
Function: theme_view

File: /home/site/starkenglish/content/application/third_party/MX/Loader.php
Line: 352
Function: include

File: /home/site/path/content/bonfire/libraries/Template.php
Line: 827
Function: _ci_load

File: /home/site/path/content/bonfire/libraries/Template.php
Line: 673
Function: find_file

File: /home/site/path/content/bonfire/libraries/Template.php
Line: 208
Function: load_view

File: /home/site/path/content/application/controllers/Home.php
Line: 67
Function: render

File: /home/site/public_html/sites/path.com/content/index.php
Line: 314
Function: require_once

Any ideas?

@mwhitneysdsu
Copy link
Contributor

Which versions of Bonfire and CodeIgniter are you using? All I'm getting on line 174 of MX_Loader is }.

Additionally, what's on line 314 of /home/site/public_html/sites/path.com/content/index.php?

@Benjer
Copy link

Benjer commented Aug 11, 2015

Hi,
Same problem for me after your commit "Updated CLI error templates from CI 3.0.1".

In my /MX/Loader.php file, line 174:

if ($path === FALSE) 
        {
            $this->_ci_load_library($library, $params, $object_name);
            $_alias = $this->_ci_classes[$class];
        } 

In my /content/index.php file, line 314:

require_once(BASEPATH . 'core/CodeIgniter.php');

Compatibility problem with CI3.0.1?

@mwhitneysdsu
Copy link
Contributor

It looks like I forgot to update Wiredesignz' code somewhere in the last 6 months:
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/commits/c1f1870c5f9873708d45e2eeeee3d91e8a5862c2?at=codeigniter-3.x

I'll run a diff and update the dev branches shortly.

@Benjer
Copy link

Benjer commented Aug 11, 2015

Thank you very much for this regular job !

@mwhitneysdsu
Copy link
Contributor

By the way, as far as I can tell at the moment, all you should need to do to fix this error is remove line 174 from /application/third_party/MX/Loader.php.

@mwhitneysdsu
Copy link
Contributor

In the interest of keeping track of why this happened for future reference, it's a two-parter:

  1. I forgot to update the MX_Loader on GitHub, possibly because I don't make a regular habit of performing a diff against /application/third_party/MX/ and I was doing too many things at once when I updated my local files with Wiredesignz' updates on bitbucket
  2. In ee62fb6 I removed the library() method from BF_Loader. The method in BF_Loader used the following code in the equivalent of MX_Loader's line 171-184:
        if ($path === false) {
            // Use $this->_ci_load_library() in CI 3
            if (substr(CI_VERSION, 0, 1) != '2') {
                $this->_ci_load_library($library, $params, $object_name);
            } else {
                $this->_ci_load_class($library, $params, $object_name);
                $_alias = $this->_ci_classes[$class];
            }
        } else {
            Modules::load_file($_library, $path);

            $library = ucfirst($_library);
            CI::$APP->$_alias = new $library($params);

            $this->_ci_classes[$class] = $_alias;
        }

In other words, if you were using CI3 with BF_Loader's library() method, the equivalent of line 174 was not present, but if you were using CI2, it was, and everything worked as intended. Because I had updated my local copy of MX_Loader at the time that I added that method to BF_Loader, everything worked fine for me when I removed the method from BF_Loader.

@Benjer
Copy link

Benjer commented Aug 11, 2015

Yes, remove the line 174 of Loader.php corrects this error.
It's true that's not easy to maintain multiple sources to update over time.

Thanks again!

@markbratanov
Copy link
Author

Awesome, woke up this morning and this was resolved. Thanks @mwhitneysdsu @Benjer !

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

No branches or pull requests

3 participants