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

Ion Auth config is being loaded twice #1000

Closed
sha256-of-poop opened this issue Nov 29, 2016 · 11 comments
Closed

Ion Auth config is being loaded twice #1000

sha256-of-poop opened this issue Nov 29, 2016 · 11 comments

Comments

@sha256-of-poop
Copy link

sha256-of-poop commented Nov 29, 2016

Every config file in CodeIgniter is loaded once except for Ion Auth,
Not sure if that's Ion Auth issue or CI's.

To test simply put this in config/ion_auth and open /auth/login
echo 'loaded<br>';

I have two applications in single CI install, to separate user and admin, wanted to share Ion Auth config so did a require_once() to load users' app's config in the admins' app. that's when I realized this (it wouldn't run with require_once).

Also I am honored to post the 1000th issue here, Where can I receive my golden potato?

@benedmunds
Copy link
Owner

Are you maybe autoloading it as well as loading it directly?

@benedmunds
Copy link
Owner

Also http://giphy.com/gifs/mashed-potatoes-scared-michael-ian-black-edTsLojZ7hF5u/fullscreen

@sha256-of-poop
Copy link
Author

sha256-of-poop commented Nov 29, 2016

@benedmunds
Thank you for the quick delivery of my prize 🍠

No sir, no auto-load, but to be sure I just downloaded CI and IonAuth again for a fresh setup (nothing edited other than sess_save_path config)

It is still loading twice.

@avenirer
Copy link
Contributor

If you have two applications, does that mean that you have two ion_auth libraries installed? Or what do you mean by "two applications"?

@sha256-of-poop
Copy link
Author

sha256-of-poop commented Nov 29, 2016

@avenirer @benedmunds
Thanks for the reply,

Let's forget that (2 application) part for a second, I installed a fresh copy of CI + Ion Auth (single unmodified installation, not 2 applications)
I did not edit or add any files, or do anything, just set sess_save_path config and put an echo 'loaded'; in config/ion_auth.php file.

Now this config file is loaded twice (I see 2 loaded echoed on every auth page I see). you can simply try this on your installation, you will also see it's loaded twice.

Now is this normal? because I had heard that CI would not load things twice, and every other config file is loaded once, not sure why ion_auth config is loaded twice.


And about that two applications part (which is on another installation, this loading twice happens on clean installation as I explained above) , I have this:

--- system (shared for both apps)
--- application
-------- admin_app
----------------- full application files (config, controllers, models etc...)
-------- user_app
----------------- full application files (config, controllers, models etc...)
--- index.php (user index)
--- admin_index.php (admin index that loads shared system folder but different application)

I just wanted to share configs between the two apps, so in admin_app/config/ion_auth.php I put this:
require_once('../../user_app/config/ion_auth.php');

I did the same for config.php and database.php , they both work fine and load once, but as Ion_auth config file is loaded twice, require_once does not work, if I change it to include or require it works. that's why I realized it's loading twice and asked this question.

@avenirer
Copy link
Contributor

I've verified and indeed it loads twice. I will also look into it.

@avenirer
Copy link
Contributor

further testing inside the library showed me that the first time it is loaded is not loaded by the library. If i put this in the constructor of the library:

public function __construct()
    {
        echo '<h2>before requesting</h2>';
        $this->load->config('ion_auth', TRUE);
        echo '<h2>just requested</h2>';
...

The resulted output is:

loaded
before requesting
loaded
just requested

@avenirer
Copy link
Contributor

Looking at a library i've developed (Postal for CI), I see the same behaviour. Most likely it is because the library is calling the CI object in order to use the framework's libraries, which is also calling the libraries and configs again.

@sha256-of-poop
Copy link
Author

Thank you for working on this, I also removed both config loads from library and module but it's still loading, but then even tho it's loaded, I cannot access the configs!

@sha256-of-poop
Copy link
Author

sha256-of-poop commented Dec 1, 2016

@avenirer
If I understand correctly, this is a CI issue, not related to Ion Auth, right?

So I should close this and report it in CI?

and Thanks again for investigating this.

@avenirer
Copy link
Contributor

avenirer commented Dec 5, 2016

In my opinion it is not related to the library. You should report it to the CodeIgniter repo, but by using another library, maybe a "dummy" library which only loads a "dummy" config.

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

3 participants