Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unknown named parameter" on routings with parameters #29

Open
lllopo opened this issue May 13, 2021 · 5 comments
Open

"Unknown named parameter" on routings with parameters #29

lllopo opened this issue May 13, 2021 · 5 comments
Assignees
Labels

Comments

@lllopo
Copy link

lllopo commented May 13, 2021

Version

  • WP Emerge: 0.16.0
  • WordPress: 5.7.2
  • PHP: 8.0.5

Expected behavior

Routings with parameters should work.

Actual behavior

Looks like they don't (I think because of with PHP 8). At least I don't see the error in my code if any. I'm getting : "Unknown named parameter $num1" in HttpKernel.php on line 177.

Steps to reproduce (in case of a bug)

  1. Create a routing of the type :
    App::route()->get()->url('/joro-test/{num1}/{num2}')->handle('TestController@check');

  2. Controller looks like this :

class TestController {
		public function check(RequestInterface $request, $view, $num1, $num2) {
			return App::view("web/test/check")->with( "someVar", $num2 ?? "bang" );
		}
	}

Comments : I see similar complaints with Symfony routing, which is similar.

@lllopo
Copy link
Author

lllopo commented May 14, 2021

A-a-a-and the fix for this is to convert the WPEmerge\Helpers\Handler execute function as follows :

public function execute(...$arguments) {
		//$arguments = func_get_args();
		$instance = $this->make();

		if ( $instance instanceof Closure ) {
			return call_user_func_array( $instance, $arguments );
		}

		return call_user_func_array( [$instance, $this->get()['method']], $arguments );
	}

@lllopo
Copy link
Author

lllopo commented May 25, 2021

Hmmm ... is this project still alive at all ?

@atanas-dev atanas-dev self-assigned this May 25, 2021
@atanas-dev atanas-dev added the bug label May 25, 2021
@atanas-dev
Copy link
Contributor

atanas-dev commented May 25, 2021

Hey @lllopo ,

I've missed to update the issue - a fix for this is already in master (b2c8a1b#diff-49fe90f07f48a9150957752e8f9ae0001283daacea41e65ac88e8bd739c709b2R177) but needs some more polishing before it gets released.

@codemonkeynorth
Copy link

codemonkeynorth commented Dec 20, 2023

@atanas-dev could this be released please? what issues might it cause as it fixes the problem?

@atanas-dev
Copy link
Contributor

@codemonkeynorth this fix is included in the 0.17.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants