Fixed The requested page could not be found. (Code: no_controller, controller: -, action: -)

@Chris D I digged into the router code (src/XF/Mvc/Router.php on line 834) a bit and could fix the problem by replacing this:
PHP:
$findReplacements[$placeholder] = '(/?)';

with that:
PHP:
$findReplacements[$placeholder] = '(/|$)';
 
Code:
                        $from = str_replace($match[0], $placeholder, $from);
                        $to = str_replace($match[0], '$' . ($i + 1), $to);
                }
 
                $from = preg_quote($from, '#');
                foreach ($findReplacements AS $findPlaceholder => $findReplacement)
                {
                        $from = str_replace($findPlaceholder, $findReplacement, $from);
                }

                return ['#^' . $from . '#', $to];

/*              if (substr($from, -1) == '/' && substr($to, -1) == '/')
                {
                        // both end in slashes, make the last slash optional
                        $matchId = $varMatches;
                        $placeholder = $replacementChr . $matchId . $replacementChr;
                        $findReplacements[$placeholder] = '(/?)';
                        $from = substr($from, 0, -1) . $placeholder;
                        $to = substr($to, 0, -1) . '$' . ($matchId + 1);
                }

                $from = preg_quote($from, '#');

                foreach ($findReplacements AS $findPlaceholder => $findReplacement)
                {
                        $from = str_replace($findPlaceholder, $findReplacement, $from);
                }

                return ['#^' . $from . '#', $to];
*/
 
@zhenglee Indeed, you think that solves the problem? It is hoped that this will solve the above-mentioned problems.

@Chris D I digged into the router code (src/XF/Mvc/Router.php on line 834) a bit and could fix the problem by replacing this:
PHP:
$findReplacements[$placeholder] = '(/?)';

with that:
PHP:
$findReplacements[$placeholder] = '(/|$)';

Thanks, but are you sure? If this doesn't solve the problem, which practical solutions do you suggest? Because we have a lot of these custom route filters and we really want to achieve something.
 
Thank you for reporting this issue. The issue is now resolved and we are aiming to include that in a future XF release (2.1.0 Beta 5).

Change log:
Ensure that we only consider the final slash on a route filter to be optional when it is the last character
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Top Bottom