Skip to content

HHVM causes malfunction of redirect(...) method of PresenterComponent since func_get_args returns arguments by references instead values #77

@jeroneemou

Description

@jeroneemou

Since PresenterComponent::redirect function has optional parameter $code, following code:

if (!is_numeric($code)) { // first parameter is optional
    $args = $destination;
    $destination = $code;
    $code = NULL;
}


if (!is_array($args)) {
    $args = array_slice(func_get_args(), is_numeric($code) ? 2 : 1);
}

will cause difference between HHVM interpreter and PHP interpreter. Because func_get_args returns arguments by references instead values in HHVM.

Example in HHVM

calling:

$this->redirect('Question:detail', 50);

will transfer parameters into:

code        = NULL 
destination = string(15) "Question:detail" 
args        = array(1) { [0]=> string(15) "Question:detail" }

while call:

$this->redirect('301', 'Question:detail', 50);

results in this:

code        = string(3) "301" 
destination = string(15) "Question:detail" 
args        = array(1) { [0]=> int(61) }

Difference between generated urls with route:

new Route('admin/<presenter>/<action>/<id>',...)

is:

admin/question/detail/Question%3Adetail - WRONG

vs:

admin/question/detail/65 - CORRECT!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions