Skip to content

Commit

Permalink
Merge pull request #1672 from sjinks/issue-1556
Browse files Browse the repository at this point in the history
No arguments are passed to beforeMatch handler in Phalcon\Mvc\Router
  • Loading branch information
Phalcon committed Dec 11, 2013
2 parents f26d0cd + 3f67da4 commit 803ee9a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
- Added Phalcon\Mvc\Model::selectWriteConnection() (#1519)
- Added Phalcon\Mvc\Router\Group::convert()/getConverters() (#1555, #1572)
- Faster Phalcon\Mvc\Model\Row (#1606)
- Bug fix: no arguments were passed to beforeMatch handler in Phalcon\Mvc\Router (#1556)
- Phalcon\Flash:
- Phalcon\Flash\Session::getMessage('key') returns now an empty array if the key is not found (#908, #920)
- Phalcon\Flash\Session::getMessages() incorrectly removed all messages (#1575)
Expand Down
2 changes: 1 addition & 1 deletion ext/mvc/router.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ PHP_METHOD(Phalcon_Mvc_Router, handle){
* Call the function in the PHP userland
*/
PHALCON_INIT_NVAR(route_found);
PHALCON_CALL_USER_FUNC_ARRAY(route_found, before_match, params);
PHALCON_CALL_USER_FUNC_ARRAY(route_found, before_match, before_match_params);
}
}

Expand Down
25 changes: 25 additions & 0 deletions ext/tests/issue-1556.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Missing arguments 1, 2 for closure in beforeMatch - https://github.com/phalcon/cphalcon/issues/1556
--SKIPIF--
<?php include('skipif.inc'); ?>
--FILE--
<?php

$router = new \Phalcon\Mvc\Router(false);

$router->add('/test')->beforeMatch(
function($uri, $route, $router)
{
echo $uri, PHP_EOL;
echo get_class($route), PHP_EOL;
echo get_class($router), PHP_EOL;
return true;
}
);

$router->handle('/test');
?>
--EXPECT--
/test
Phalcon\Mvc\Router\Route
Phalcon\Mvc\Router

0 comments on commit 803ee9a

Please sign in to comment.