Part of the EllisLab Network
   
2 of 3
2
Default Controller Bug
Posted: 01 March 2007 02:22 PM   [ Ignore ]   [ # 16 ]  
Grad Student
Rank
Total Posts:  32
Joined  02-27-2007
mediaslave - 01 March 2007 02:09 PM

By the way the above installation do not use mod_rewrite.  This does work with mod_rewrite though as well.

Mediaslave

Sorry this is confusing what I wrote here.  I meant to say that the above installations are very basic and do not use mod_rewrite.  The bug is the same with or without mod_rewrite in place.

My PATCH works also with mod_rewrite.

I agree that it does not matter whether you use mod_rewrite or not.  The bug is still there.  I was just trying to show Derek that with the most basic installation it is a bug.

Mediaslave

Profile
 
 
Posted: 01 March 2007 05:14 PM   [ Ignore ]   [ # 17 ]  
Grad Student
Rank
Total Posts:  32
Joined  02-27-2007

Hi Derek,

I did not see these questions when I read this post the first time.  Here are some answers for you.

Derek Allard - 01 March 2007 01:36 PM

So it appears that this only manifests if you’re running multiple applications off one CI install. 

FALSE.  It happens when the bootstrap file is a subdirectory having it’s one CI installation or sharing a CI installation.

Derek Allard - 01 March 2007 01:36 PM

Is this only a problem if you’re using htaccess files?

NO. With or without htaccess files it breaks

Derek Allard - 01 March 2007 01:36 PM

Can you explain to me why its breaking?  For example, “CI has a hard-coded path in $file.php and it is isn’t looking in $otherplace”.  That type of thing?

It (system/libraries/Router.php) breaks because it is comparing the wrong strings.  When a CI installation is in subdirectory needs to compare the string not of just the SELF (/index.php) constant, but the full path from the public root:

Installation in:

/subdirectory

The constants below used in both examples that with a subdirectory installation of /subdirectory are:

SELF = index.php
PUBLICROOTTOSELF
= /subdirectory/index.php

Router.php lines 306 and 307 look like:

$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');    
            if (
$path != '' AND $path != "/" . SELF)

change these to:

$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');    
            if (
$path != '' AND $path != PUBLICROOTTOSELF)

AND

Lines 320 and 321 look like:

$path = (isset($_SERVER['ORIG_PATH_INFO'])) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO');    
            if (
$path != '' AND $path != "/".SELF)

change these to:

$path = (isset($_SERVER['ORIG_PATH_INFO'])) ? $_SERVER['ORIG_PATH_INFO'] : @getenv('ORIG_PATH_INFO');    
            if (
$path != '' AND $path != PUBLICROOTTOSELF)

Well I don’t know if I have helped you anymore on this, maybe it is just over kill.  It is a lot harder to squash bugs in forums than in person.

Thanks,

Mediaslave

Profile
 
 
Posted: 02 March 2007 04:04 PM   [ Ignore ]   [ # 18 ]  
Grad Student
Rank
Total Posts:  32
Joined  02-27-2007

Hi Derek,

I know that you probably have not had time to finish looking into this, but I wondered if you had made any progress with it.

Regards,

Mediaslave

Profile
 
 
Posted: 02 March 2007 04:36 PM   [ Ignore ]   [ # 19 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6762
Joined  03-23-2006

No sorry, I haven’t even looked at it.  Put your patch into your code and see if you can break it.  I’ll do my best to get to it early next week (sorry, just too much other stuff on my plate at the moment).

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 02 March 2007 04:54 PM   [ Ignore ]   [ # 20 ]  
Grad Student
Rank
Total Posts:  32
Joined  02-27-2007

Hi Derek,

No problem.  I have tried to break it quite a bit mostly with url accessing.  Nothing seems to break it.

And really it should not effect the core of CI, because I am creating my own constant to deal with the problem and not messing with CI to much.  Only in how the Router compares.  I have done root installations, subdirectory installations and subdomain root and subdirectory installations with everything running smoothly.  I think that it is solid.

Have a great weekend,

Mediaslave

Profile
 
 
Posted: 01 May 2007 07:43 PM   [ Ignore ]   [ # 21 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  6762
Joined  03-23-2006

Hi.  A bug report was filed for this (http://codeigniter.com/bug_tracker/bug/default_controller_with_multiple_applications_bug/) but I haven’t even looked at it since this thread started (apologies).  Now that it is on record, it’ll get evaluated at some point.  Thanks.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 02 May 2007 08:46 PM   [ Ignore ]   [ # 22 ]  
Lab Assistant
RankRank
Total Posts:  128
Joined  04-06-2007

I have a feeling I know what the problem with this really is, and it isn’t anything with CI.  I was burping a bit on my initial setup using a subdir of docroot while trying to rewrite index.php out of the URL.  But I got it smoothed out with no real issue.  When I get to work tomorrow I will take a closer look at what you are reporting and compare it to my setup and report back here.

Jim

Profile
 
 
Posted: 03 May 2007 08:26 AM   [ Ignore ]   [ # 23 ]  
Lab Assistant
RankRank
Total Posts:  128
Joined  04-06-2007

Ok…I have the folloing setup working perfectly with no adjustment to any CI code:

Directory layout:

/var/
  |
  |-
www/
     |
     |-
commonlibs
     
|  |
     |  |-
CodeIgniter_1.5.3/
     |     |
     |     |-
system/
     |
     |-
html/ (httpd document root)
        |
        |-.
htaccess
        
|
        |-
index.php  (primary front controller)
        |
        |-
application/ (primary CI application code)
        |
        |-
subdir/
           |
           |-
index.php  (subdir front controller)
           |
           |-
application/ (subdir CI application code)

With nothing in the .htaccess file, and leaving default_controller as ‘welcome’ on both applications, I can go to the following URLs with no problem:
> http://www.mysite.com/  (loads primary front controller defaulting to the welcome controller and the index() method of that controller)

> http://www.mysite.com/index.php  (loads primary front controller defaulting to the welcome controller and the index() method of that controller)

> http://www.mysite.com/index.php/welcome  (loads primary front controller, welcome controller, defaulting to the index() method of that controller)

> http://www.mysite.com/index.php/welcome/index  (loads primary front controller, welcome controller, index() method of that controller)

> http://www.mysite.com/subdir  (loads subdir front controller defaulting to the subdir application’s welcome controller and the index() method of that controller)

> http://www.mysite.com/subdir/index.php  (loads subdir front controller defaulting to the subdir application’s welcome controller and the index() method of that controller)

> http://www.mysite.com/subdir/index.php/welcome  (loads subdir front controller, the subdir application’s welcome controller defaulting to the index() method of that controller)

> http://www.mysite.com/subdir/welcome/index  (loads subdir front controller, the subdir application’s welcome controller, the index() method of that controller)

Putting the folllowing into .htaccess:

RewriteEngine On

RewriteCond
%{REQUEST_URI} ^/subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond
%{REQUEST_FILENAME} !-d
RewriteRule
^subdir/(.*)$ subdir/index.php/$1 [L]


RewriteCond
%{REQUEST_FILENAME} !-f
RewriteCond
%{REQUEST_FILENAME} !-d
RewriteRule
^(.*)$ index.php/$1 [L]


allows me to go to the EXACT same URLs as I listed above, but I can pull index.php out of any of them and it still works fine.

So I am seeing no problem with front controllers (bootstrap files) in subdirs.  Did I miss something in what you guys are doing that is causing the problem?  If so, give me some instructions on what to do to my test cases to make it fail.

Thanks,
Jim

Profile
 
 
Posted: 03 May 2007 08:43 AM   [ Ignore ]   [ # 24 ]  
Grad Student
Rank
Total Posts:  66
Joined  07-12-2006

thanks for this…i will test again today.

Profile
 
 
Posted: 03 May 2007 10:53 AM   [ Ignore ]   [ # 25 ]  
Grad Student
Rank
Total Posts:  66
Joined  07-12-2006

Thanks again for looking into this. I do not doubt that this is working for you, but this still does not seam to be working for me. I removed .htaccess to just take that out of the equation.

My setup:

/public_html/
     /
admin/
          .
index.php
               
($system_folder = "../system";)
               (
$application_folder = "application/admin";)
     /
system/
          /
application/
               /
admin/
                    (
$config['base_url' = "http://mysite.com/admin/";)
                    (
$config['index_page'] = "index.php";)
               /
public/
                    (
$config['base_url' = "http://mysite.com/";)
                    (
$config['index_page'] = "index.php";)
     
index.php
          
($system_folder = "system";)
          (
$application_folder = "application/public";)

mysite.com/ works
mysite.com/index.php works
mysite.com/index.php/ “No input file specified.”
mysite.com/index.php/welcome works
mysite.com/index.php/welcome/ works

mysite.com/admin/ ci 404 page
mysite.com/admin/index.php ci 404 page
mysite.com/admin/index.php/ “No input file specified.”
mysite.com/admin/index.php/welcome works
mysite.com/admin/index.php/welcome/ works

Any help on this would be a huge help. There was another user (mediaslave) who was having this same problem as me. So i am reluctant to blame this on my server or something and not ci.

Profile
 
 
Posted: 03 May 2007 11:27 AM   [ Ignore ]   [ # 26 ]  
Lab Assistant
RankRank
Total Posts:  128
Joined  04-06-2007

Wow…I set up a completely fresh server with a brand new CI install matching EXACTLY what you showed as your setup and everything worked correctly.  Every URL you showed worked correctly with no problem.

What web server are you using?

Jim

Profile
 
 
Posted: 03 May 2007 11:46 AM   [ Ignore ]   [ # 27 ]  
Grad Student
Rank
Total Posts:  66
Joined  07-12-2006

apache (dreamhost)....damn real wierd? i am testing this with a current project that is in development (which IS 1.5.3), but i will download a fresh copy and try another test.

Profile
 
 
Posted: 03 May 2007 11:57 AM   [ Ignore ]   [ # 28 ]  
Lab Assistant
RankRank
Total Posts:  128
Joined  04-06-2007

Ahhhh..DREAMHOST!!  That may be it.  There are some odd things that go on with CI and Dreamhost.

One thing I specifically remember seeing was that index.php HAD TO BE FOLLOWED by a question mark (?) before the CI path stuff could be put in:
http://www.site.com/index.php?/welcome

Also, there is mention of adjusting the CI URI Protocol settings for Dreamhost.

Profile
 
 
Posted: 03 May 2007 12:08 PM   [ Ignore ]   [ # 29 ]  
Grad Student
Rank
Total Posts:  32
Joined  02-27-2007
JAAulde - 03 May 2007 11:57 AM

Ahhhh..DREAMHOST!!  That may be it.  There are some odd things that go on with CI and Dreamhost.

One thing I specifically remember seeing was that index.php HAD TO BE FOLLOWED by a question mark (?) before the CI path stuff could be put in:
http://www.site.com/index.php?/welcome

Also, there is mention of adjusting the CI URI Protocol settings for Dreamhost.

He is not having a problem with index.php/welcome that one works in his example so the ? is not the problem.

Also,  I am not on dreamhost.  I use MT

Regards

Profile
 
 
Posted: 03 May 2007 12:18 PM   [ Ignore ]   [ # 30 ]  
Lab Assistant
RankRank
Total Posts:  128
Joined  04-06-2007

Yeah, the ? was just something I remembered specifically.  But as you can see by my Google search and the linked topic, some hosting setups result in exactly the errors you are getting and there are some remedies to try.

Jim

Profile
 
 
   
2 of 3
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 66428 Total Logged-in Users: 36
Total Topics: 84791 Total Anonymous Users: 3
Total Replies: 455013 Total Guests: 238
Total Posts: 539804    
Members ( View Memberlist )
Newest Members:  X_franllogocsaturkeyPeter BryanttherendStudioGeorgiaJZeerfedegheEdgedcentice