Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Sub folder controller error #1306

Closed
hakimihamdan88 opened this Issue · 2 comments

3 participants

@hakimihamdan88

i have a controller named pages in admin folder.
/applications/controllers/admin/pages.php

function delete($id)
{
echo $id;
}

when i try to echo id number "1" in admin/pages/delete/1 , it echo "delete" not "1"

** using latest CI dev

please check this line. the cause

// This is being routed to a file in a sub directory
$this->directory and array_unshift($segments, trim($this->directory, '/'));

@cryode

I can confirm that this is an issue on the latest dev commit.

@philsturgeon looks to have committed this. And I have to be honest, I've never seen that kind of syntax since working with PHP. Is this an error, Phil? Can you explain what's up with the and here?

@cryode

The problem here is coming from Phil's solution to issue #122 regarding the ruri_string() method, which involves adding the directory segment back onto the $uri->rsegments array. It's a good fix for that, however the core uses the $uri->rsegments array in the call_user_func_array() function which calls the requested controller method. If you did it like this, $id would come through appropriately: public function delete($method, $id) {}

But, obviously, that's bad. Looks like the ruri_string() and similar reverse-URI methods may need to be rethought slightly. An additional URI class property that includes the entire array, or each segment includes the directory where appropriate.

Although if we wanted to get even more complicated, CodeIgniter is still limited to only a single subfolder in the controllers directory. If it was to move beyond that, a LOT of the routing and URI code would need modification.

@philsturgeon philsturgeon referenced this issue from a commit
@philsturgeon philsturgeon Reverted rui_string change.
This had knock-on effects as can be seen in #1306. Issue #122 has been
reopend until it is fixed properly.
81aa94b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.