Skip to content
Merged
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
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ PHP NEWS
. Error handling of Uri\WhatWg\Url::withHost() is fixed when the input
contains a port. Now, it triggers an exception; previously, the error
was silently swallowed. (Máté Kocsis)
. Support empty URIs with Uri\Rfc3986\Uri. (timwolla)

17 Jul 2025, PHP 8.5.0alpha2

Expand Down
51 changes: 20 additions & 31 deletions ext/intl/dateformat/dateformat_format_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
size_t locale_len;
bool pattern = false;
UDate date;
TimeZone *timeZone = NULL;
std::unique_ptr<TimeZone> timeZone;
UErrorCode status = U_ZERO_ERROR;
DateFormat *df = NULL;
Calendar *cal = NULL;
std::unique_ptr<DateFormat> df;
std::unique_ptr<Calendar> cal;
DateFormat::EStyle dateStyle = DateFormat::kDefault,
timeStyle = DateFormat::kDefault;

Expand Down Expand Up @@ -158,28 +158,28 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
"not initialized properly", 0);
RETURN_FALSE;
}
timeZone = obj_cal->getTimeZone().clone();
timeZone = std::unique_ptr<TimeZone>(obj_cal->getTimeZone().clone());
date = obj_cal->getTime(status);
if (U_FAILURE(status)) {
intl_error_set(NULL, status,
"datefmt_format_object: error obtaining instant from "
"IntlCalendar", 0);
RETVAL_FALSE;
goto cleanup;
RETURN_FALSE;
}
cal = obj_cal->clone();
cal = std::unique_ptr<Calendar>(obj_cal->clone());
} else if (instanceof_function(instance_ce, php_date_get_interface_ce())) {
if (intl_datetime_decompose(object, &date, &timeZone, NULL,
TimeZone *tz;
if (intl_datetime_decompose(object, &date, &tz, NULL,
"datefmt_format_object") == FAILURE) {
RETURN_FALSE;
}
cal = new GregorianCalendar(Locale::createFromName(locale_str), status);
timeZone = std::unique_ptr<TimeZone>(tz);
cal = std::unique_ptr<Calendar>(new GregorianCalendar(Locale::createFromName(locale_str), status));
if (U_FAILURE(status)) {
intl_error_set(NULL, status,
"datefmt_format_object: could not create GregorianCalendar",
0);
RETVAL_FALSE;
goto cleanup;
RETURN_FALSE;
}
} else {
intl_error_set(NULL, status, "datefmt_format_object: the passed object "
Expand All @@ -190,36 +190,32 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)

if (pattern) {
StringPiece sp(Z_STRVAL_P(format));
df = new SimpleDateFormat(
df = std::unique_ptr<DateFormat>(new SimpleDateFormat(
UnicodeString::fromUTF8(sp),
Locale::createFromName(locale_str),
status);
status));

if (U_FAILURE(status)) {
intl_error_set(NULL, status,
"datefmt_format_object: could not create SimpleDateFormat",
0);
RETVAL_FALSE;
goto cleanup;
RETURN_FALSE;
}
} else {
df = DateFormat::createDateTimeInstance(dateStyle, timeStyle,
Locale::createFromName(locale_str));
df = std::unique_ptr<DateFormat>(DateFormat::createDateTimeInstance(dateStyle, timeStyle,
Locale::createFromName(locale_str)));

if (df == NULL) { /* according to ICU sources, this should never happen */
intl_error_set(NULL, status,
"datefmt_format_object: could not create DateFormat",
0);
RETVAL_FALSE;
goto cleanup;
RETURN_FALSE;
}
}

//must be in this order (or have the cal adopt the tz)
df->adoptCalendar(cal);
cal = NULL;
df->adoptTimeZone(timeZone);
timeZone = NULL;
df->adoptCalendar(cal.release());
df->adoptTimeZone(timeZone.release());

{
zend_string *u8str;
Expand All @@ -231,15 +227,8 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object)
intl_error_set(NULL, status,
"datefmt_format_object: error converting result to UTF-8",
0);
RETVAL_FALSE;
goto cleanup;
RETURN_FALSE;
}
RETVAL_STR(u8str);
}


cleanup:
delete df;
delete timeZone;
delete cal;
}
15 changes: 6 additions & 9 deletions ext/snmp/snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,21 +1038,18 @@ static bool snmp_session_set_auth_protocol(struct snmp_session *s, zend_string *
}
#endif

smart_string err = {0};

smart_string_appends(&err, "Authentication protocol must be \"SHA\"");
zend_value_error(
"Authentication protocol must be \"SHA\""
#ifdef HAVE_SNMP_SHA256
smart_string_appends(&err, " or \"SHA256\"");
" or \"SHA256\""
#endif
#ifdef HAVE_SNMP_SHA512
smart_string_appends(&err, " or \"SHA512\"");
" or \"SHA512\""
#endif
#ifndef DISABLE_MD5
smart_string_appends(&err, " or \"MD5\"");
" or \"MD5\""
#endif
smart_string_0(&err);
zend_value_error("%s", err.c);
smart_string_free(&err);
);
return false;
}
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion ext/tidy/tests/031.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tidy
--FILE--
<?php
$buffer = '<html></html>';
$config = array('doctype' => 'php');
$config = array('doctype' => 'auto');

$tidy = tidy_parse_string($buffer, $config);
var_dump(tidy_config_count($tidy));
Expand Down
11 changes: 10 additions & 1 deletion ext/tidy/tests/tidy_error1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ try {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

$config = ['doctype' => 'php', 0 => 'value2'];
$config = ['doctype' => 'php'];

try {
var_dump($tidy->parseString($buffer, $config));
} catch (\TypeError $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
}

$config = ['doctype' => 'auto', 0 => 'value2'];

try {
var_dump($tidy->parseString($buffer, $config));
Expand All @@ -45,4 +53,5 @@ try {
ValueError: tidy::parseString(): Argument #2 ($config) Unknown Tidy configuration option "bogus"
TypeError: tidy::parseString(): Argument #2 ($config) must be of type array with keys as string
ValueError: tidy::parseString(): Argument #2 ($config) Attempting to set read-only option "doctype-mode"
TypeError: tidy::parseString(): Argument #2 ($config) option "doctype" does not accept "php" as a value
TypeError: tidy::parseString(): Argument #2 ($config) must be of type array with keys as string
Loading