Hello guys!
If anyone knows this please help.
I am using apache 2.4.51, PHP 8.0.12 on Microsoft Windows 11 64 bit operating system and using Codeigniter 4.3.1 to test Shield and Myth/Auth.
It worked fine until everything used locale(language).
However, after applying locale, there is no problem in get, but the following error occurs in post.
Of course, the data transmitted to the database is not entered.
browser error message
==============================
ErrorException
preg_match(): Compilation failed: unmatched closing parenthesis at offset 7
SYSTEMPATH\Router\Router.php at line 418
411
412 // Are we dealing with a locale?
413 if (strpos($routeKey, '{locale}') !== false) {
414 $routeKey = str_replace('{locale}', '[^/]+', $routeKey);
415 }
416
417 // Does the RegEx match?
418 if (preg_match('#^' . $routeKey . '$#u', $uri, $matches)) {
419 // Is this route supposed to redirect to another?
420 if ($this->collection->isRedirect($routeKey)) {
421 // replacing matched route groups with references: post/([0-9]+) -> post/$1
422 $redirectTo = preg_replace_callback('/(\([^\(]+\))/', static function () {
423 static $i = 1;
424
425 return '$' . $i++;
{PHP internal code} — CodeIgniter\Debug\Exceptions->errorHandler ( arguments )
SYSTEMPATH\Router\Router.php : 418 — preg_match()
SYSTEMPATH\Router\Router.php : 181 — CodeIgniter\Router\Router->checkRoutes ( arguments )
174 $uri = urldecode($uri);
175
176 // Restart filterInfo
177 $this->filterInfo = null;
178 $this->filtersInfo = [];
179
180 // Checks defined routes
181 if ($this->checkRoutes($uri)) {
182 if ($this->collection->isFiltered($this->matchedRoute[0])) {
183 $multipleFiltersEnabled = config('Feature')->multipleFilters ?? false;
184 if ($multipleFiltersEnabled) {
185 $this->filtersInfo = $this->collection->getFiltersForRoute($this->matchedRoute[0]);
186 } else {
187 // for backward compatibility
188 $this->filterInfo = $this->collection->getFilterForRoute($this->matchedRoute[0]);
SYSTEMPATH\CodeIgniter.php : 815 — CodeIgniter\Router\Router->handle ( arguments )
808 $path = $this->determinePath();
809
810 $this->benchmark->stop('bootstrap');
811 $this->benchmark->start('routing');
812
813 ob_start();
814
815 $this->controller = $this->router->handle($path);
816 $this->method = $this->router->methodName();
817
818 // If a {locale} segment was matched in the final route,
819 // then we need to set the correct locale on our Request.
820 if ($this->router->hasLocale()) {
821 $this->request->setLocale($this->router->getLocale());
822 }
SYSTEMPATH\CodeIgniter.php : 449 — CodeIgniter\CodeIgniter->tryToRouteIt ( arguments )
442 *
443 * @deprecated $returnResponse is deprecated.
444 */
445 protected function handleRequest(?RouteCollectionInterface $routes, Cache $cacheConfig, bool $returnResponse = false)
446 {
447 $this->returnResponse = $returnResponse;
448
449 $routeFilter = $this->tryToRouteIt($routes);
450
451 $uri = $this->determinePath();
452
453 if ($this->enableFilters) {
454 // Start up the filters
455 $filters = Services::filters();
456
SYSTEMPATH\CodeIgniter.php : 368 — CodeIgniter\CodeIgniter->handleRequest ( arguments )
361 $this->response->send();
362 $this->callExit(EXIT_SUCCESS);
363
364 return;
365 }
366
367 try {
368 return $this->handleRequest($routes, $cacheConfig, $returnResponse);
369 } catch (RedirectException $e) {
370 $logger = Services::logger();
371 $logger->info('REDIRECTED ROUTE at ' . $e->getMessage());
372
373 // If the route is a 'redirect' route, it throws
374 // the exception with the $to as the message
375 $this->response->redirect(base_url($e->getMessage()), 'auto', $e->getCode());
FCPATH\index.php : 67 — CodeIgniter\CodeIgniter->run ()
60 *---------------------------------------------------------------
61 * LAUNCH THE APPLICATION
62 *---------------------------------------------------------------
63 * Now that everything is setup, it's time to actually fire
64 * up the engines and make this app do its thang.
65 */
66
67 $app->run();
==============================
Error message in log file
==============================
CRITICAL - (Time) --> preg_match(): Compilation failed: unmatched closing parenthesis at offset 7
in SYSTEMPATH\Router\Router.php on line 418.
1 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'preg_match(): Compilation failed: unmatched closing parenthesis at offset 7', 'SYSTEMPATH\\Router\\Router.php', 418)
2 SYSTEMPATH\Router\Router.php(418): preg_match('#^Search)$#u', 'en/auth/register', null)
3 SYSTEMPATH\Router\Router.php(181): CodeIgniter\Router\Router->checkRoutes('en/auth/register')
4 SYSTEMPATH\CodeIgniter.php(815): CodeIgniter\Router\Router->handle('en/auth/register')
5 SYSTEMPATH\CodeIgniter.php(449): CodeIgniter\CodeIgniter->tryToRouteIt(Object(CodeIgniter\Router\RouteCollection))
6 SYSTEMPATH\CodeIgniter.php(368): CodeIgniter\CodeIgniter->handleRequest(null, Object(Config\Cache), false)
7 FCPATH\index.php(67): CodeIgniter\CodeIgniter->run()
==============================