CodeIgniter Forums

Full Version: A very strange occurance.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been using codeignitor off and on since pre 1.5 days if I remember right. I occasionally use it to help write utilities on personal web servers for private use mostly. I've always loved it.

Anyway, I figured I'd give the pro's a crack at this head scratcher. As I'm sure someone will go, "well it'd probably help if you weren't doing x wrong", and make a right fool of myself. Now, keep in mind this is an older server which is why I haven't gone the route of wiping it and installing the latest slackware/LAMP.

I had written a pastebin clone application at one time for personal use on a private server some years ago, and had need of it again. I attempted to get the old code base to work again to no avail. Working backwards I'm down to a clean install of the same version of ci that it was written on(1.7.2). With this clean install, I've figured out the problem is coming from the controllers.

All controllers follow the same pattern, none will load the controllers default view unless it is the only function available to it.

For example:


PHP Code:
<?php

class Welcome extends Controller {

    function 
Welcome()
    {
        
parent::Controller();    
    }
    
    function 
index()
    {
        
$this->load->view('welcome_message');
    }
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */ 


Works, but:

PHP Code:
<?php

class Welcome extends Controller {

    function 
Welcome()
    {
        
parent::Controller();    
    }
    
    function 
index()
    {
        
$this->load->view('welcome_message');
    }

    function 
newfunction()
    {
        
$this->load->view('view1');
    }

    function 
newerfunction()
    {
        
$this->load->view('view2');
    }
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */ 
does not.

What happens is that upon http://server/cidir/controller/ it calls newfunction() and flatly refuses to call index(), nor can I call newerfunction() no matter how many crude hacks I try. Nor has anything of import changed on the old server since it's last update a couple of years ago.

I've gone through every conceivable idea I've been able to muster, and am looking longingly at the shotgun to put the old server out of my misery.

I have gone through everything from possible path issues, to aliens and have come up with nothing. I've never seen it behave this way.
What's in your application\config\routes.php file?
Check the error log of the server.

The code looks very old Smile I think it is a compatible issues with php.
(11-12-2016, 01:53 AM)Wouter60 Wrote: [ -> ]What's in your application\config\routes.php file?

PHP Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
|     example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
|    http://codeigniter.com/user_guide/general/routing.html
|
| -------------------------------------------------------------------------
| RESERVED ROUTES
| -------------------------------------------------------------------------
|
| There are two reserved routes:
|
|    $route['default_controller'] = 'welcome';
|
| This route indicates which controller class should be loaded if the
| URI contains no data. In the above example, the "welcome" class
| would be loaded.
|
|    $route['scaffolding_trigger'] = 'scaffolding';
|
| This route lets you set a "secret" word that will trigger the
| scaffolding feature for added security. Note: Scaffolding must be
| enabled in the controller in which you intend to use it.   The reserved 
| routes must come before any wildcard or regular expression routes.
|
*/

$route['default_controller'] = "welcome";
$route['scaffolding_trigger'] = "";


/* End of file routes.php */
/* Location: ./system/application/config/routes.php */ 

(11-12-2016, 05:58 AM)Paradinight Wrote: [ -> ]Check the error log of the server.

The code looks very old Smile I think it is a compatible issues with php.
Already done. The only errors are random 404's, etc. from passing, unrelated ip address.
I have actually found the answer to this particular conundrum.

Since everything from the code, to the server are of an older flavor, it was coming from how that particular version of php was handling the controller functions. At least, this is how I got it corrected. The server is as follows, Apache 1.3.x with php running 4.4.x. The CI code base was 1.7.x.

When naming certain functions in the controllers, I finally got the httpd to throw the error into it's error_log in the form of a fatal error. After renaming the controller functions into wildly unique names, it began to work properly. They had been fairly unique before, and there were no duplicate namings. As for why this occurred, I am at a loss to explain. Nor can I explain why a clean install broke down in the default welcome.php_controller->welcome_message.php_view when a second function was added in the welcome.php controller. But, randomly altering function names fixed each controller.