Sub folder controller error #1306

Closed
hakimihamdan88 opened this Issue Apr 29, 2012 · 2 comments

Comments

Projects
None yet
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, '/'));

@AkenRoberts

This comment has been minimized.

Show comment Hide comment
@AkenRoberts

AkenRoberts May 2, 2012

Contributor

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?

Contributor

AkenRoberts commented May 2, 2012

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?

@AkenRoberts

This comment has been minimized.

Show comment Hide comment
@AkenRoberts

AkenRoberts May 2, 2012

Contributor

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.

Contributor

AkenRoberts commented May 2, 2012

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 pushed a commit that referenced this issue May 2, 2012

Phil Sturgeon
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment