Skip to content

Commit

Permalink
Merge pull request #12720 from Jurigag/3.1.x.-view-params
Browse files Browse the repository at this point in the history
Fixes view params scope for php5
  • Loading branch information
sergeyklay authored Mar 18, 2017
2 parents 105d39d + 21fed52 commit 0d89a9e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Fixed `Phalcon\Mvc\Model` to correctly add error when try to save empty string value to not null and not default column [#12688](https://github.com/phalcon/cphalcon/issues/12688)
- Fixed `Phalcon\Validation\Validator\Uniqueness` collection persistent condition
- Fixed `Phalcon\Loader::autoLoad` to prevent PHP warning [#12684](https://github.com/phalcon/cphalcon/pull/12684)
- Fixed params view scope for PHP5 [#12648](https://github.com/phalcon/cphalcon/issues/12648)

# [3.0.4](https://github.com/phalcon/cphalcon/releases/tag/v3.0.4) (2017-02-20)
- Fixed Isnull check is not correct when the model field defaults to an empty string. [#12507](https://github.com/phalcon/cphalcon/issues/12507)
Expand Down
2 changes: 1 addition & 1 deletion phalcon/mvc/view.zep
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ class View extends Injectable implements ViewInterface
* Create a virtual symbol table.
* Variables are shared across symbol tables in PHP5
*/
if is_php_version("5") {
if PHP_MAJOR_VERSION == 5 {
create_symbol_table();
}

Expand Down
34 changes: 34 additions & 0 deletions tests/unit/Mvc/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,40 @@ function () {
);
}

/**
* Tests params view scope
*
* @issue 12648
* @author Wojciech Ślawski <[email protected]>
* @since 2017-03-17
*/
public function testIssue12648()
{
if (PHP_MAJOR_VERSION != 5) {
$this->markTestSkipped("This issue is fixed only for php5");
}

$this->specify(
"View params are available in local scope",
function () {
$this->_clearCache();
$di = $this->_getDi();
$view = new View();
$view->setDI($di);
$view->setViewsDir(PATH_DATA . 'views' . DIRECTORY_SEPARATOR);
$view->setParamToView('a_cool_var', 'test');

$content = $view->setRenderLevel(View::LEVEL_ACTION_VIEW)->getRender('test3', 'another');
expect($content)->equals("<html>lol<p>test</p></html>\n");
try {
echo $a_cool_var;
} catch (\PHPUnit_Framework_Exception $e) {
expect($e->getMessage())->contains("Undefined variable: a_cool_var");
}
}
);
}

private function _getDi($service = 'viewCache', $lifetime = 60)
{
$di = new Di();
Expand Down

0 comments on commit 0d89a9e

Please sign in to comment.