-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
PHP Version
8.1
CodeIgniter4 Version
4.4.0
CodeIgniter4 Installation Method
Git
Which operating systems have you tested for this bug?
Windows
Which server did you use?
cli-server (PHP built-in webserver)
Database
No response
What happened?
Unable to generate a URL attached to a route defined with custom placeholders.
An exception is thrown at SYSTEMPATH\Router\RouteCollection.php at line 1343
Steps to Reproduce
- Add custom placeholder
$routes->addPlaceholder([
'version' => 'master|\d+\.(?:\d+|x)',
'page' => '[a-z0-9-]+',
]);- Create 2 routes for test
$routes->get('docs/(:version)', function() {
echo 'Test the documentation';
});
$routes->get('docs/(:version)/(:page)', function() {
echo 'Test the documentation segment';
}, ['as' => 'docs.version']);- So far everything is ok. Now let's try to get a 2nd route url (docs.version) from the 1st route
$routes->get('docs/(:version)', function() {
echo 'Test the documentation --- ' . url_to('docs.version', '10.9', 'install');
});at this level it no longer gives. yet if I don't use the url_to function, the text displays normally, so I dare to believe that my regex has no error
1st Image: Error when i use url_to function in the 1st route
2nd Image: The 2nd route is displayed normally
3th Image: The 1st route is displayed normally when the url_to function is not used
Expected Output
the display of the corresponding url (http://localhost:8000/docs/10.9/install)
Anything else?
This bug is a continuation of a ticket (feature request) opened on the forum: https://forum.codeigniter.com/showthread.php?tid=88365


