Skip to content

Fix reference support for intltz_get_offset() #18364

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ext/intl/tests/intltz_get_offset_references.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
intltz_get_offset references
--EXTENSIONS--
intl
--FILE--
<?php
$tz = IntlTimeZone::createTimeZone('Europe/Brussels');

class Test {
public string $a, $b;
}
$test = new Test;
$test->a = $test->b = "hello";

$rawOffset =& $test->a;
$dstOffset =& $test->b;
intltz_get_offset($tz, 0.0, true, $rawOffset, $dstOffset);
var_dump($test);
?>
--EXPECT--
object(Test)#2 (2) {
["a"]=>
&string(7) "3600000"
["b"]=>
&string(1) "0"
}
8 changes: 3 additions & 5 deletions ext/intl/timezone/timezone_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_offset)
TIMEZONE_METHOD_INIT_VARS;

if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(),
"Odbz/z/", &object, TimeZone_ce_ptr, &date, &local, &rawOffsetArg,
"Odbzz", &object, TimeZone_ce_ptr, &date, &local, &rawOffsetArg,
&dstOffsetArg) == FAILURE) {
RETURN_THROWS();
}
Expand All @@ -431,10 +431,8 @@ U_CFUNC PHP_FUNCTION(intltz_get_offset)

INTL_METHOD_CHECK_STATUS(to, "intltz_get_offset: error obtaining offset");

zval_ptr_dtor(rawOffsetArg);
ZVAL_LONG(rawOffsetArg, rawOffset);
zval_ptr_dtor(dstOffsetArg);
ZVAL_LONG(dstOffsetArg, dstOffset);
ZEND_TRY_ASSIGN_REF_LONG(rawOffsetArg, rawOffset);
ZEND_TRY_ASSIGN_REF_LONG(dstOffsetArg, dstOffset);

RETURN_TRUE;
}
Expand Down
Loading