Welcome Guest, Not a member yet? Register   Sign In
Going throw the Controller twice !
#11

[eluser]Derek Jones[/eluser]
How did a missing/bad path to favicon.ico cause CI to run twice in one instantiation?
#12

[eluser]John_Betong[/eluser]
Hi Derek,
 
Here is the code to be placed immediately before </body></html>
Code:
<?php if(LOCALHOST) { ?>
  
      <p style='width:600px; height:60px; margin:1em auto; font-size:2em'>
            &lt;?php $logfile = 'log-' .date('Y-m-d') .'.php'; if (file_exists($logfile)) { ?&gt;
            <span style='border:outset 4px'>
              <a href='/_show_logfile.php'>Show logfile</a>
          </span>    
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <span style='border:outset 4px'>
                <a href='/_delete_logfile.php'>Delete: logfile</a>
          </span>    
            &lt;?php    } ?&gt;
      </p>    
   &lt;?php } ?&gt;

Here is the /root/_show_logfile.php
Code:
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Show logfile</htitle>
&lt;/head&gt;

&lt;body style='background:#ccc none; color:#00f'&gt;        
    
    <div style='width:80%; height:640px; margin:1em auto; overflow:auto; background:#ffa none'>
        <pre  style='text-align:left'>
            &lt;?php
                // echo $CI->$config['log_path'] .BR;
                $logfile = 'log-' .date('Y-m-d') .'.php';
              if (file_exists($logfile)) {
                  echo file_get_contents($logfile);
              }
            ?&gt;    
            
        </pre>
        
    </div>    
    
    <div style='border:outset 4px; width:320px; margin:1em auto; font-size:2em; text-align:center'>
                &lt;?php if (file_exists($logfile)) { ?&gt;
                
                        <a href='_delete_logfile.php'>Delete: logfile</a>
                        
                &lt;?php    } ?&gt;
    </div>
    
&lt;/body&gt;
&lt;/html&gt;

&nbsp;
and here is the /root/_delete_logfile.php
Code:
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Delete logfile&lt;/title&gt;
    &lt;/head&gt;
&lt;body align-'center'&gt;
    
    <div style='width:60%; margin:4em auto'>                    
        &lt;?php
            $logfile = 'log-' .date('Y-m-d') .'.php';
            if (file_exists($logfile) AND unlink($logfile)) {
                echo 'Yes we have no ' .$logfile;
            }
        ?&gt;
        
        <p>
            <a href='_menu.php'> menu</a>
        </a>
    </div>        
    
&lt;/body&gt;
&lt;/html&gt;
&nbsp;
Make an incorrecrt path to your favicon.ico and let me know the results.
&nbsp;
Needless to say you will have to setup the error logfile paths.
&nbsp;
I am curious to know if it only fails to work on my computer.
&nbsp;
&nbsp;
#13

[eluser]Derek Jones[/eluser]
That's really not the question I asked, John - you need to step back, way back, to this:

Quote:“Final output sent to browser”, etc was also happening twice.

Instead of adding log messages to your code to trace through things, a reduction test would be more productive, as I suggested. Start with nothing, literally nothing but an echo and an empty controller and slowly add your code in until you see your application running output and such multiple times. I think you're seeing a symptom, not the problem.

Edit-to-add: Clarifying why I'm making that recommendation: Others trying out your log viewer won't show productive or meaningful results if they're not experiencing the problem of double-processing to begin with.
#14

[eluser]John_Betong[/eluser]
Hi Derek,
&nbsp;
I believe I isolated the problem to the incorrect paths to favicon.ico in the header.
&nbsp;
I ran these tests with and without the correct paths and these are the result:
&nbsp;
Here is the logfile with the incorrect path to favicon.ico
with these two line in my &lt;header&gt;
&nbsp;
&lt;link rel="icon" href="favicon.ico" type="image/x-icon" /&gt;
&lt;link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /&gt;
&nbsp;
Code:
DEBUG - 2008-05-05 00:42:31 --&gt; Config Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Hooks Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; URI Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Router Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Output Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Input Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2008-05-05 00:42:31 --&gt; Language Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Loader Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Controller Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Helpers loaded: url
DEBUG - 2008-05-05 00:42:31 --&gt; Helpers loaded: form
DEBUG - 2008-05-05 00:42:31 --&gt; Helpers loaded: date
DEBUG - 2008-05-05 00:42:31 --&gt; Helpers loaded: html
DEBUG - 2008-05-05 00:42:31 --&gt; Helpers loaded: h_helper
DEBUG - 2008-05-05 00:42:31 --&gt; Database Driver Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Model Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; Session Class Initialized
DEBUG - 2008-05-05 00:42:31 --&gt; File loaded: ci_betsprint/views/_blog_intro.php
DEBUG - 2008-05-05 00:42:31 --&gt; File loaded: ci_betsprint/views/_doctype.php
DEBUG - 2008-05-05 00:42:31 --&gt; File loaded: ci_betsprint/views/_header.php
DEBUG - 2008-05-05 00:42:31 --&gt; File loaded: ci_betsprint/views/_title.php
DEBUG - 2008-05-05 00:42:31 --&gt; File loaded: ci_betsprint/views/_box_left.php
DEBUG - 2008-05-05 00:42:31 --&gt; File loaded: ci_betsprint/views/_box_right.php
DEBUG - 2008-05-05 00:42:31 --&gt; File loaded: ci_betsprint/views/_footer.php
DEBUG - 2008-05-05 00:42:31 --&gt; File loaded: ci_betsprint/views/_analytics.php
DEBUG - 2008-05-05 00:42:31 --&gt; File loaded: ci_betsprint/views/view_001.php
DEBUG - 2008-05-05 00:42:31 --&gt; Language file loaded: language/english/profiler_lang.php
DEBUG - 2008-05-05 00:42:31 --&gt; Final output sent to browser
DEBUG - 2008-05-05 00:42:32 --&gt; Total execution time: 0.1756
DEBUG - 2008-05-05 00:42:32 --&gt; Config Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Hooks Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; URI Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Router Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Output Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Input Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2008-05-05 00:42:32 --&gt; Language Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Loader Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Controller Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Helpers loaded: url
DEBUG - 2008-05-05 00:42:32 --&gt; Helpers loaded: form
DEBUG - 2008-05-05 00:42:32 --&gt; Helpers loaded: date
DEBUG - 2008-05-05 00:42:32 --&gt; Helpers loaded: html
DEBUG - 2008-05-05 00:42:32 --&gt; Helpers loaded: h_helper
DEBUG - 2008-05-05 00:42:32 --&gt; Database Driver Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Model Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; Session Class Initialized
DEBUG - 2008-05-05 00:42:32 --&gt; File loaded: ci_betsprint/views/_blog_intro.php
DEBUG - 2008-05-05 00:42:32 --&gt; File loaded: ci_betsprint/views/_doctype.php
DEBUG - 2008-05-05 00:42:32 --&gt; File loaded: ci_betsprint/views/_header.php
DEBUG - 2008-05-05 00:42:32 --&gt; File loaded: ci_betsprint/views/_title.php
DEBUG - 2008-05-05 00:42:32 --&gt; File loaded: ci_betsprint/views/_box_left.php
DEBUG - 2008-05-05 00:42:32 --&gt; File loaded: ci_betsprint/views/_box_right.php
DEBUG - 2008-05-05 00:42:32 --&gt; File loaded: ci_betsprint/views/_footer.php
DEBUG - 2008-05-05 00:42:32 --&gt; File loaded: ci_betsprint/views/_analytics.php
DEBUG - 2008-05-05 00:42:32 --&gt; File loaded: ci_betsprint/views/view_001.php
DEBUG - 2008-05-05 00:42:32 --&gt; Language file loaded: language/english/profiler_lang.php
DEBUG - 2008-05-05 00:42:32 --&gt; Final output sent to browser
DEBUG - 2008-05-05 00:42:32 --&gt; Total execution time: 0.2768
&nbsp;
&nbsp;
#15

[eluser]John_Betong[/eluser]
Hi Derek,
&nbsp;
I exceeded the 6,000 character limit and had to make a new post
&nbsp;
Here is the output with the correct path to favicon.ico
&nbsp;
&lt;link rel="icon" href="/favicon.ico" type="image/x-icon" /&gt;
&lt;link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /&gt;
&nbsp;
Code:
DEBUG - 2008-05-05 00:45:51 --&gt; Config Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Hooks Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; URI Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Router Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Output Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Input Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2008-05-05 00:45:51 --&gt; Language Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Loader Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Controller Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Helpers loaded: url
DEBUG - 2008-05-05 00:45:51 --&gt; Helpers loaded: form
DEBUG - 2008-05-05 00:45:51 --&gt; Helpers loaded: date
DEBUG - 2008-05-05 00:45:51 --&gt; Helpers loaded: html
DEBUG - 2008-05-05 00:45:51 --&gt; Helpers loaded: h_helper
DEBUG - 2008-05-05 00:45:51 --&gt; Database Driver Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Model Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; Session Class Initialized
DEBUG - 2008-05-05 00:45:51 --&gt; File loaded: ci_betsprint/views/_blog_intro.php
DEBUG - 2008-05-05 00:45:51 --&gt; File loaded: ci_betsprint/views/_doctype.php
DEBUG - 2008-05-05 00:45:51 --&gt; File loaded: ci_betsprint/views/_header.php
DEBUG - 2008-05-05 00:45:51 --&gt; File loaded: ci_betsprint/views/_title.php
DEBUG - 2008-05-05 00:45:51 --&gt; File loaded: ci_betsprint/views/_box_left.php
DEBUG - 2008-05-05 00:45:51 --&gt; File loaded: ci_betsprint/views/_box_right.php
DEBUG - 2008-05-05 00:45:51 --&gt; File loaded: ci_betsprint/views/_footer.php
DEBUG - 2008-05-05 00:45:51 --&gt; File loaded: ci_betsprint/views/_analytics.php
DEBUG - 2008-05-05 00:45:51 --&gt; File loaded: ci_betsprint/views/view_001.php
DEBUG - 2008-05-05 00:45:51 --&gt; Language file loaded: language/english/profiler_lang.php
DEBUG - 2008-05-05 00:45:51 --&gt; Final output sent to browser
DEBUG - 2008-05-05 00:45:51 --&gt; Total execution time: 0.2025
&nbsp;
&nbsp;
#16

[eluser]John_Betong[/eluser]
Hi Derek,
&nbsp;
I searched the forum and this post appears to describe in detail the problems I am having:
&nbsp;
http://ellislab.com/forums/viewthread/45802/
&nbsp;
It is now past midnight and I am off for some much needed beauty sleep Smile
&nbsp;
&nbsp;
#17

[eluser]Derek Jones[/eluser]
Ok, I see, you're talking about separate instantiations, not the application running twice within the context of a single request. Yes, with URI segments, the browser will not form paths correctly to relatively linked assets, as the browser sees each segment as a physical directory. You can also see this with index.php written out of the URL with catch-all-esque rules like the "file and directory check" method that is so popular, where every bad request ends up being handled by the application, which can be a silly waste of resources.
#18

[eluser]a&w[/eluser]
[quote author="Derek Jones" date="1209942874"]...Yes, with URI segments, the browser will not form paths correctly to relatively linked assets, as the browser sees each segment as a physical directory. You can also see this with index.php written out of the URL with catch-all-esque rules like the "file and directory check" method that is so popular, where every bad request ends up being handled by the application, which can be a silly waste of resources.[/quote]

I experienced this same problem periodically. I noticed before finding this thread and this one:
http://ellislab.com/forums/viewthread/45802/

that missing resources (jss, css, etc.) seemed to have this affect also. I was curious if you/anyone had a different .htaccess to suggest than the catch all approach. My current .htaccess looks something like this:

Code:
# disable directory browsing
Options All -Indexes
<FilesMatch "\.(gif|jpg|jpeg|png|swf|css|js|html?|xml|txt)$">
    # Remove Etags inode (only use the modified time and size of the file)
    FileETag MTime Size
</FilesMatch>
<IfModule mod_rewrite.c>
    RewriteEngine On
#If the request is for a file that exists already on the server, don't rewrite.
#an exclamation mark ('!') is used to negate the meaning.
    RewriteCond %{REQUEST_FILENAME} !-f
#If the request is for a real directory (one that exists on the server), don't rewrite.
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{REQUEST_URI} !^(.*)\.css$
    RewriteCond %{REQUEST_URI} !^(.*)\.jpg$
    RewriteCond %{REQUEST_URI} !^(.*)\.gif$

#serve up index.php/whatever for any conditions rewritten per above    
    RewriteRule ^(.*)$ /mysite/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

    # local:
    ErrorDocument 404 /aaaa/index.php
</IfModule>
<IfModule mod_expires.c>
    # must have mod_expires enabled in httpd.conf
    <FilesMatch "\.(gif|jpg|jpeg|png|swf|html?|txt)$">
        ExpiresActive On
        ExpiresDefault "access plus 10 years"
    </FilesMatch>
</IfModule>
#19

[eluser]Derek Jones[/eluser]
You could instead only rewrite URLs with requests whose first segments match your controller names (or routing rules). See an example in the ExpressionEngine Wiki for the "include list" method.




Theme © iAndrew 2016 - Forum software by © MyBB