Welcome Guest, Not a member yet? Register   Sign In
Some classes load twice!
#11

[eluser]John_Betong[/eluser]
A long time ago I had a problem with the controllers loading twice. Eventually managed to trace the cause to the wrong path for the favicon.ico.

I found the error by checking in the Apache and PHP error log files.

Well worth a try...
 
 
 
#12

[eluser]Razican[/eluser]
[quote author="John_Betong" date="1291906912"]A long time ago I had a problem with the controllers loading twice. Eventually managed to trace the cause to the wrong path for the favicon.ico.

I found the error by checking in the Apache and PHP error log files.

Well worth a try...
 
 
 [/quote]
I have tried to find all broken URLs but I found nothing.
[quote author="WanWizard" date="1291858310"]I can't look into your environment, so it's very difficult for me to give you the correct config.

What you can do as a temporary measure, add
Code:
log_message('debug', "URL requested: ".$_SERVER['REQUEST_URI']);
as last statement of the constructor in system/core/controller.php. Make sure to set the log_threshold to 4 in your config to be able to see debugging.

It will log every URL requested to the log file. That would help you to find which assets are missing.[/quote]
With that statement this is the log with the -d and -f on:
Code:
DEBUG - 12-12-2010 16:58:42 --> Config Class Initialized
DEBUG - 12-12-2010 16:58:42 --> Hooks Class Initialized
DEBUG - 12-12-2010 16:58:42 --> Unicode Class Initialized
DEBUG - 12-12-2010 16:58:42 --> Unicode Class - UTF-8 Support Enabled
DEBUG - 12-12-2010 16:58:42 --> URI Class Initialized
DEBUG - 12-12-2010 16:58:42 --> Router Class Initialized
DEBUG - 12-12-2010 16:58:42 --> Output Class Initialized
DEBUG - 12-12-2010 16:58:42 --> Input Class Initialized
DEBUG - 12-12-2010 16:58:42 --> Security Class Initialized
DEBUG - 12-12-2010 16:58:42 --> XSS Filtering completed
DEBUG - 12-12-2010 16:58:42 --> XSS Filtering completed
DEBUG - 12-12-2010 16:58:42 --> CRSF cookie Set
DEBUG - 12-12-2010 16:58:42 --> Global POST and COOKIE data sanitized
DEBUG - 12-12-2010 16:58:42 --> Language Class Initialized
DEBUG - 12-12-2010 16:58:42 --> Loader Class Initialized
DEBUG - 12-12-2010 16:58:42 --> Config file loaded: megapublik/config/megapublik.php
DEBUG - 12-12-2010 16:58:42 --> Helper loaded: language_helper
DEBUG - 12-12-2010 16:58:42 --> Helper loaded: form_helper
DEBUG - 12-12-2010 16:58:42 --> Helper loaded: html_helper
DEBUG - 12-12-2010 16:58:42 --> Helper loaded: url_helper
DEBUG - 12-12-2010 16:58:42 --> Helper loaded: cookie_helper
DEBUG - 12-12-2010 16:58:42 --> Helper loaded: overal_helper
DEBUG - 12-12-2010 16:58:42 --> Language file loaded: language/spanish/overal_lang.php
DEBUG - 12-12-2010 16:58:43 --> Database Driver Class Initialized
DEBUG - 12-12-2010 16:58:43 --> Session Class Initialized
DEBUG - 12-12-2010 16:58:43 --> Helper loaded: string_helper
DEBUG - 12-12-2010 16:58:43 --> Encrypt Class Initialized
DEBUG - 12-12-2010 16:58:43 --> Session routines successfully run
DEBUG - 12-12-2010 16:58:43 --> Model Class Initialized
DEBUG - 12-12-2010 16:58:43 --> Model Class Initialized
DEBUG - 12-12-2010 16:58:43 --> Controller Class Initialized
DEBUG - 12-12-2010 16:58:43 --> URL requested: /megapublik/es
DEBUG - 12-12-2010 16:58:43 --> Language file loaded: language/spanish/login_lang.php
DEBUG - 12-12-2010 16:58:43 --> File loaded: megapublik/views/menu_outgame.php
DEBUG - 12-12-2010 16:58:43 --> File loaded: megapublik/views/head.php
DEBUG - 12-12-2010 16:58:43 --> File loaded: megapublik/views/footer.php
DEBUG - 12-12-2010 16:58:43 --> File loaded: megapublik/views/login.php
DEBUG - 12-12-2010 16:58:43 --> Language file loaded: language/spanish/profiler_lang.php
DEBUG - 12-12-2010 16:58:43 --> Helper loaded: text_helper
DEBUG - 12-12-2010 16:58:43 --> Final output sent to browser
DEBUG - 12-12-2010 16:58:43 --> Total execution time: 0.0521
This is when I put the
Code:
RewriteCond %{REQUEST_URI} !^(images|javascript|css)
Code:
DEBUG - 12-12-2010 16:59:29 --> Config Class Initialized
DEBUG - 12-12-2010 16:59:29 --> Hooks Class Initialized
DEBUG - 12-12-2010 16:59:29 --> Unicode Class Initialized
DEBUG - 12-12-2010 16:59:29 --> Unicode Class - UTF-8 Support Enabled
DEBUG - 12-12-2010 16:59:29 --> URI Class Initialized
DEBUG - 12-12-2010 16:59:29 --> Router Class Initialized
ERROR - 12-12-2010 16:59:29 --> 404 Page Not Found --> index_php
#13

[eluser]Razican[/eluser]
Is there any solution?
#14

[eluser]WanWizard[/eluser]
Try mine. I've used this one on every server deployed sofar:

Code:
Options -Indexes
Options +FollowSymLinks

# Set the default file for indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>

    # activate URL rewriting
    RewriteEngine On

    # if installed in a sub-directory of the document
    # root, modify the path below accordingly
    RewriteBase /megapublik/

    # nasty hack to capture ruined URI's by a mod_rewrite bug.
    #
    # You need these two lines when you use mod_vhost_alias, and this
    # .htaccess file generates a "500 internal server error".
    # In the rule below, replace --DOCROOT-- by your full docroot path,
    # without a leading slash, but with a trailing slash!
    # (i.e 'path/to/my/docroot/', without quotes offcourse)
    #
#    RewriteCond $1 index\.php/$
#    RewriteRule ^--DOCROOT--(.*)$ /$1 [S=1]

    # do not rewrite links to the documentation, assets and public files
    RewriteCond $1 !^(images|javascript|css)

    # do not rewrite for php files in the document root or robots.txt
    RewriteCond $1 !^([^\..]+\.php|robot\.txt)

    # but rewrite everything else
    RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>

    # If we    don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 index.php

</IfModule>
#15

[eluser]Razican[/eluser]
The classes continue loading more than one time.

Code:
DEBUG - 20-12-2010 19:52:36 --&gt; Config Class Initialized
DEBUG - 20-12-2010 19:52:36 --&gt; Hooks Class Initialized
DEBUG - 20-12-2010 19:52:36 --&gt; Unicode Class Initialized
DEBUG - 20-12-2010 19:52:36 --&gt; Unicode Class - UTF-8 Support Enabled
DEBUG - 20-12-2010 19:52:36 --&gt; URI Class Initialized
DEBUG - 20-12-2010 19:52:36 --&gt; Router Class Initialized
DEBUG - 20-12-2010 19:52:36 --&gt; Output Class Initialized
DEBUG - 20-12-2010 19:52:36 --&gt; Input Class Initialized
DEBUG - 20-12-2010 19:52:36 --&gt; Security Class Initialized
DEBUG - 20-12-2010 19:52:36 --&gt; XSS Filtering completed
DEBUG - 20-12-2010 19:52:36 --&gt; XSS Filtering completed
DEBUG - 20-12-2010 19:52:36 --&gt; CRSF cookie Set
DEBUG - 20-12-2010 19:52:36 --&gt; Global POST and COOKIE data sanitized
DEBUG - 20-12-2010 19:52:37 --&gt; Language Class Initialized
DEBUG - 20-12-2010 19:52:37 --&gt; Loader Class Initialized
DEBUG - 20-12-2010 19:52:37 --&gt; Config file loaded: megapublik/config/megapublik.php
DEBUG - 20-12-2010 19:52:37 --&gt; Helper loaded: language_helper
DEBUG - 20-12-2010 19:52:37 --&gt; Helper loaded: form_helper
DEBUG - 20-12-2010 19:52:37 --&gt; Helper loaded: html_helper
DEBUG - 20-12-2010 19:52:37 --&gt; Helper loaded: url_helper
DEBUG - 20-12-2010 19:52:37 --&gt; Helper loaded: cookie_helper
DEBUG - 20-12-2010 19:52:37 --&gt; Helper loaded: overal_helper
DEBUG - 20-12-2010 19:52:37 --&gt; Language file loaded: language/spanish/overal_lang.php
DEBUG - 20-12-2010 19:52:37 --&gt; Database Driver Class Initialized
DEBUG - 20-12-2010 19:52:37 --&gt; Session Class Initialized
DEBUG - 20-12-2010 19:52:37 --&gt; Helper loaded: string_helper
DEBUG - 20-12-2010 19:52:37 --&gt; Encrypt Class Initialized
DEBUG - 20-12-2010 19:52:37 --&gt; Session routines successfully run
DEBUG - 20-12-2010 19:52:37 --&gt; Model Class Initialized
DEBUG - 20-12-2010 19:52:37 --&gt; Model Class Initialized
DEBUG - 20-12-2010 19:52:37 --&gt; Controller Class Initialized
DEBUG - 20-12-2010 19:52:37 --&gt; Language file loaded: language/spanish/login_lang.php
DEBUG - 20-12-2010 19:52:37 --&gt; File loaded: megapublik/views/menu_outgame.php
DEBUG - 20-12-2010 19:52:37 --&gt; File loaded: megapublik/views/head.php
DEBUG - 20-12-2010 19:52:37 --&gt; File loaded: megapublik/views/footer.php
DEBUG - 20-12-2010 19:52:37 --&gt; File loaded: megapublik/views/login.php
DEBUG - 20-12-2010 19:52:37 --&gt; Language file loaded: language/spanish/profiler_lang.php
DEBUG - 20-12-2010 19:52:37 --&gt; Helper loaded: text_helper
DEBUG - 20-12-2010 19:52:37 --&gt; Final output sent to browser
DEBUG - 20-12-2010 19:52:37 --&gt; Total execution time: 0.0893
#16

[eluser]WanWizard[/eluser]
Add some debug code somewhere to log the requested URI to the logfile (see here for a suggestion).

I always find that very handy, and should be in CI by default.
#17

[eluser]tonanbarbarian[/eluser]
it is entirely possible that the model class is not loading twice at all
what i suggest you do is add your own logging to your code

i.e. in the constructor of your models and controllers add sometihng like the following
Code:
log_message('debug', 'MyController initialised');

What I think is happening is that in the constructor of your controller you are loading 2 models.
Now each model in the constructor will load the parent model class, and that class in the CI core has the following to log a debug message
Code:
log_message('debug', "Model Class Initialized");
So as you can see there is not really an issue I can see.

Add the logging as I suggested to your code and you will probably see the related models being loaded before or after the log messages that indicate the Model Class initialised.
#18

[eluser]Razican[/eluser]
I have put the debug messages and I'm not sure about what to think, it loads twice the model class before loading the model. I have put the debug message with every model. the user model is autoloaded by the autoload.php file.

This is the log file:
Code:
DEBUG - 23-12-2010 19:09:19 --&gt; Config Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Hooks Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Unicode Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Unicode Class - UTF-8 Support Enabled
DEBUG - 23-12-2010 19:09:19 --&gt; URI Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Router Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Output Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Input Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Security Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; XSS Filtering completed
DEBUG - 23-12-2010 19:09:19 --&gt; XSS Filtering completed
DEBUG - 23-12-2010 19:09:19 --&gt; CRSF cookie Set
DEBUG - 23-12-2010 19:09:19 --&gt; Global POST and COOKIE data sanitized
DEBUG - 23-12-2010 19:09:19 --&gt; Language Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Loader Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Config file loaded: megapublik/config/megapublik.php
DEBUG - 23-12-2010 19:09:19 --&gt; Helper loaded: language_helper
DEBUG - 23-12-2010 19:09:19 --&gt; Helper loaded: form_helper
DEBUG - 23-12-2010 19:09:19 --&gt; Helper loaded: html_helper
DEBUG - 23-12-2010 19:09:19 --&gt; Helper loaded: url_helper
DEBUG - 23-12-2010 19:09:19 --&gt; Helper loaded: cookie_helper
DEBUG - 23-12-2010 19:09:19 --&gt; Helper loaded: overal_helper
DEBUG - 23-12-2010 19:09:19 --&gt; Language file loaded: language/spanish/overal_lang.php
DEBUG - 23-12-2010 19:09:19 --&gt; Database Driver Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Session Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Helper loaded: string_helper
DEBUG - 23-12-2010 19:09:19 --&gt; Encrypt Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Session garbage collection performed.
DEBUG - 23-12-2010 19:09:19 --&gt; Session routines successfully run
DEBUG - 23-12-2010 19:09:19 --&gt; Model Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; Model Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; User Model initialised
DEBUG - 23-12-2010 19:09:19 --&gt; Controller Class Initialized
DEBUG - 23-12-2010 19:09:19 --&gt; URL requested: /megapublik/es
DEBUG - 23-12-2010 19:09:19 --&gt; Language file loaded: language/spanish/login_lang.php
DEBUG - 23-12-2010 19:09:19 --&gt; File loaded: megapublik/views/menu_outgame.php
DEBUG - 23-12-2010 19:09:19 --&gt; File loaded: megapublik/views/head.php
DEBUG - 23-12-2010 19:09:19 --&gt; File loaded: megapublik/views/footer.php
DEBUG - 23-12-2010 19:09:19 --&gt; File loaded: megapublik/views/login.php
DEBUG - 23-12-2010 19:09:19 --&gt; Language file loaded: language/spanish/profiler_lang.php
DEBUG - 23-12-2010 19:09:19 --&gt; Helper loaded: text_helper
DEBUG - 23-12-2010 19:09:19 --&gt; Final output sent to browser
DEBUG - 23-12-2010 19:09:19 --&gt; Total execution time: 0.0558
#19

[eluser]Razican[/eluser]
I have noticed that when I disable hooks, it continues loading the hook class. Could it be connected with the error?
#20

[eluser]Razican[/eluser]
I have corrected some bugs but I still get those multi-loading errors. This is one of my debug source with multi XSS filtering, and multiple model class loading:
Code:
DEBUG - 04-01-2011 21:16:05 --&gt; Config Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Hooks Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Unicode Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Unicode Class - UTF-8 Support Enabled
DEBUG - 04-01-2011 21:16:05 --&gt; URI Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Router Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Output Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Input Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Security Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; XSS Filtering completed
DEBUG - 04-01-2011 21:16:05 --&gt; XSS Filtering completed
DEBUG - 04-01-2011 21:16:05 --&gt; XSS Filtering completed
DEBUG - 04-01-2011 21:16:05 --&gt; XSS Filtering completed
DEBUG - 04-01-2011 21:16:05 --&gt; XSS Filtering completed
DEBUG - 04-01-2011 21:16:05 --&gt; XSS Filtering completed
DEBUG - 04-01-2011 21:16:05 --&gt; XSS Filtering completed
DEBUG - 04-01-2011 21:16:05 --&gt; XSS Filtering completed
DEBUG - 04-01-2011 21:16:05 --&gt; XSS Filtering completed
DEBUG - 04-01-2011 21:16:05 --&gt; CRSF cookie Set
DEBUG - 04-01-2011 21:16:05 --&gt; CSRF token verified
DEBUG - 04-01-2011 21:16:05 --&gt; Global POST and COOKIE data sanitized
DEBUG - 04-01-2011 21:16:05 --&gt; Language Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Loader Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Config file loaded: megapublik/config/megapublik.php
DEBUG - 04-01-2011 21:16:05 --&gt; Helper loaded: language_helper
DEBUG - 04-01-2011 21:16:05 --&gt; Helper loaded: form_helper
DEBUG - 04-01-2011 21:16:05 --&gt; Helper loaded: html_helper
DEBUG - 04-01-2011 21:16:05 --&gt; Helper loaded: url_helper
DEBUG - 04-01-2011 21:16:05 --&gt; Helper loaded: cookie_helper
DEBUG - 04-01-2011 21:16:05 --&gt; Helper loaded: overal_helper
DEBUG - 04-01-2011 21:16:05 --&gt; Language file loaded: language/spanish/overal_lang.php
DEBUG - 04-01-2011 21:16:05 --&gt; Database Driver Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Session Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Helper loaded: string_helper
DEBUG - 04-01-2011 21:16:05 --&gt; Encrypt Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Session routines successfully run
DEBUG - 04-01-2011 21:16:05 --&gt; Model Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Model Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; User model loaded.
DEBUG - 04-01-2011 21:16:05 --&gt; Controller Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Language hook initialised.
DEBUG - 04-01-2011 21:16:05 --&gt; Helper loaded: email_helper
DEBUG - 04-01-2011 21:16:05 --&gt; Model Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; Registration_m model loaded.
DEBUG - 04-01-2011 21:16:05 --&gt; Language file loaded: language/spanish/registration_lang.php
DEBUG - 04-01-2011 21:16:05 --&gt; Email Class Initialized
DEBUG - 04-01-2011 21:16:05 --&gt; File loaded: megapublik/views/head.php
DEBUG - 04-01-2011 21:16:05 --&gt; File loaded: megapublik/views/footer.php
DEBUG - 04-01-2011 21:16:05 --&gt; File loaded: megapublik/views/mail.php
DEBUG - 04-01-2011 21:16:06 --&gt; Language file loaded: language/spanish/email_lang.php
DEBUG - 04-01-2011 21:16:07 --&gt; File loaded: megapublik/views/menu_outgame.php
DEBUG - 04-01-2011 21:16:07 --&gt; File loaded: megapublik/views/head.php
DEBUG - 04-01-2011 21:16:07 --&gt; File loaded: megapublik/views/footer.php
DEBUG - 04-01-2011 21:16:07 --&gt; File loaded: megapublik/views/registration/registration.php
DEBUG - 04-01-2011 21:16:07 --&gt; Language file loaded: language/spanish/profiler_lang.php
DEBUG - 04-01-2011 21:16:07 --&gt; Helper loaded: text_helper
DEBUG - 04-01-2011 21:16:07 --&gt; Final output sent to browser
DEBUG - 04-01-2011 21:16:07 --&gt; Total execution time: 2.0128

Why does this happen? is this a CI bug? it happened with CI 1.7.2 too. Please, I need help.




Theme © iAndrew 2016 - Forum software by © MyBB