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
3 changes: 2 additions & 1 deletion ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,10 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch class specified");
goto in_fetch_error;
}
ctor_arguments = stmt->fetch.cls.ctor_args;
}
ZEND_ASSERT(ce != NULL);

ctor_arguments = stmt->fetch.cls.ctor_args;
if (flags & PDO_FETCH_SERIALIZE) {
if (!ce->unserialize) {
/* As this option is deprecated we do not bother to mention the class name. */
Expand Down
97 changes: 97 additions & 0 deletions ext/pdo/tests/gh20553.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
--TEST--
GH-20553: PHP 8.5.0 regression: PDO::FETCH_CLASSTYPE ignores $constructorArgs
--EXTENSIONS--
pdo
--SKIPIF--
<?php
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
if (str_starts_with(getenv('PDOTEST_DSN'), "firebird")) {
die("skip firebird doesn't support non-standard SQL without FROM syntax");
}
require_once $dir . 'pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php

if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();

class dumpy {
function __construct() {
echo 'constructor called,' . PHP_EOL . ' my class is ' .
var_export(get_class($this), true) . PHP_EOL .
' input parameters: ' .
var_export(func_get_args(), true) . PHP_EOL;
}
function __set($name, $value) {
echo var_export($name, true) . ' = ' . var_export($value, true) .
PHP_EOL;
}
}
class dummy extends dumpy {
}

$sql = "SELECT 'dummy' pdo_fetch_class_type_class, 'bar' foo, 'dfg' abc";

$fetchModes = [
'PDO::FETCH_CLASS'
=> PDO::FETCH_CLASS,
'PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE'
=> PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE,
'PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE'
=> PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE,
'PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_PROPS_LATE'
=> PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_PROPS_LATE,
];

foreach ($fetchModes as $combinedModes => $fetchMode) {
echo '## ' . $combinedModes . PHP_EOL;
$db->query($sql)->fetchAll(
$fetchMode,
'dumpy',
['constructor argument #1']
);
echo PHP_EOL;
}
?>
--EXPECT--
## PDO::FETCH_CLASS
'pdo_fetch_class_type_class' = 'dummy'
'foo' = 'bar'
'abc' = 'dfg'
constructor called,
my class is 'dumpy'
input parameters: array (
0 => 'constructor argument #1',
)

## PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE
constructor called,
my class is 'dumpy'
input parameters: array (
0 => 'constructor argument #1',
)
'pdo_fetch_class_type_class' = 'dummy'
'foo' = 'bar'
'abc' = 'dfg'

## PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE
'foo' = 'bar'
'abc' = 'dfg'
constructor called,
my class is 'dummy'
input parameters: array (
0 => 'constructor argument #1',
)

## PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_PROPS_LATE
constructor called,
my class is 'dummy'
input parameters: array (
0 => 'constructor argument #1',
)
'foo' = 'bar'
'abc' = 'dfg'
28 changes: 4 additions & 24 deletions ext/uri/uriparser/src/UriCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
# ifndef URI_DOXYGEN
# include <uriparser/Uri.h>
# include "UriCommon.h"
# include "UriSets.h"
# endif

# include <assert.h>
Expand Down Expand Up @@ -468,32 +469,11 @@ UriBool URI_FUNC(RemoveDotSegmentsAbsolute)(URI_TYPE(Uri) * uri,

unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig) {
switch (hexdig) {
case _UT('0'):
case _UT('1'):
case _UT('2'):
case _UT('3'):
case _UT('4'):
case _UT('5'):
case _UT('6'):
case _UT('7'):
case _UT('8'):
case _UT('9'):
case URI_SET_DIGIT(_UT):
return (unsigned char)(9 + hexdig - _UT('9'));

case _UT('a'):
case _UT('b'):
case _UT('c'):
case _UT('d'):
case _UT('e'):
case _UT('f'):
case URI_SET_HEX_LETTER_LOWER(_UT):
return (unsigned char)(15 + hexdig - _UT('f'));

case _UT('A'):
case _UT('B'):
case _UT('C'):
case _UT('D'):
case _UT('E'):
case _UT('F'):
case URI_SET_HEX_LETTER_UPPER(_UT):
return (unsigned char)(15 + hexdig - _UT('F'));

default:
Expand Down
114 changes: 4 additions & 110 deletions ext/uri/uriparser/src/UriEscape.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
# ifndef URI_DOXYGEN
# include <uriparser/Uri.h>
# include "UriCommon.h"
# include "UriSets.h"
# endif

URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, UriBool spaceToPlus,
Expand Down Expand Up @@ -108,72 +109,7 @@ URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, const URI_CHAR * inAfter
prevWasCr = URI_FALSE;
break;

case _UT('a'): /* ALPHA */
case _UT('A'):
case _UT('b'):
case _UT('B'):
case _UT('c'):
case _UT('C'):
case _UT('d'):
case _UT('D'):
case _UT('e'):
case _UT('E'):
case _UT('f'):
case _UT('F'):
case _UT('g'):
case _UT('G'):
case _UT('h'):
case _UT('H'):
case _UT('i'):
case _UT('I'):
case _UT('j'):
case _UT('J'):
case _UT('k'):
case _UT('K'):
case _UT('l'):
case _UT('L'):
case _UT('m'):
case _UT('M'):
case _UT('n'):
case _UT('N'):
case _UT('o'):
case _UT('O'):
case _UT('p'):
case _UT('P'):
case _UT('q'):
case _UT('Q'):
case _UT('r'):
case _UT('R'):
case _UT('s'):
case _UT('S'):
case _UT('t'):
case _UT('T'):
case _UT('u'):
case _UT('U'):
case _UT('v'):
case _UT('V'):
case _UT('w'):
case _UT('W'):
case _UT('x'):
case _UT('X'):
case _UT('y'):
case _UT('Y'):
case _UT('z'):
case _UT('Z'):
case _UT('0'): /* DIGIT */
case _UT('1'):
case _UT('2'):
case _UT('3'):
case _UT('4'):
case _UT('5'):
case _UT('6'):
case _UT('7'):
case _UT('8'):
case _UT('9'):
case _UT('-'): /* "-" / "." / "_" / "~" */
case _UT('.'):
case _UT('_'):
case _UT('~'):
case URI_SET_UNRESERVED(_UT):
/* Copy unmodified */
write[0] = read[0];
write++;
Expand Down Expand Up @@ -263,51 +199,9 @@ const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, UriBool plusToSpa

case _UT('%'):
switch (read[1]) {
case _UT('0'):
case _UT('1'):
case _UT('2'):
case _UT('3'):
case _UT('4'):
case _UT('5'):
case _UT('6'):
case _UT('7'):
case _UT('8'):
case _UT('9'):
case _UT('a'):
case _UT('b'):
case _UT('c'):
case _UT('d'):
case _UT('e'):
case _UT('f'):
case _UT('A'):
case _UT('B'):
case _UT('C'):
case _UT('D'):
case _UT('E'):
case _UT('F'):
case URI_SET_HEXDIG(_UT):
switch (read[2]) {
case _UT('0'):
case _UT('1'):
case _UT('2'):
case _UT('3'):
case _UT('4'):
case _UT('5'):
case _UT('6'):
case _UT('7'):
case _UT('8'):
case _UT('9'):
case _UT('a'):
case _UT('b'):
case _UT('c'):
case _UT('d'):
case _UT('e'):
case _UT('f'):
case _UT('A'):
case _UT('B'):
case _UT('C'):
case _UT('D'):
case _UT('E'):
case _UT('F'): {
case URI_SET_HEXDIG(_UT): {
/* Percent group found */
const unsigned char left = URI_FUNC(HexdigToInt)(read[1]);
const unsigned char right = URI_FUNC(HexdigToInt)(read[2]);
Expand Down
23 changes: 3 additions & 20 deletions ext/uri/uriparser/src/UriIp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
# include <uriparser/UriIp4.h>
# include "UriIp4Base.h"
# include <uriparser/UriBase.h>
# include "UriSets.h"
# endif

/* Prototypes */
Expand Down Expand Up @@ -194,16 +195,7 @@ URI_FUNC(ParseDecOctetOne)(UriIp4Parser * parser, const URI_CHAR * first,
}

switch (*first) {
case _UT('0'):
case _UT('1'):
case _UT('2'):
case _UT('3'):
case _UT('4'):
case _UT('5'):
case _UT('6'):
case _UT('7'):
case _UT('8'):
case _UT('9'):
case URI_SET_DIGIT(_UT):
uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9')));
return (const URI_CHAR *)URI_FUNC(ParseDecOctetThree)(parser, first + 1,
afterLast);
Expand Down Expand Up @@ -272,16 +264,7 @@ URI_FUNC(ParseDecOctetThree)(UriIp4Parser * parser, const URI_CHAR * first,
}

switch (*first) {
case _UT('0'):
case _UT('1'):
case _UT('2'):
case _UT('3'):
case _UT('4'):
case _UT('5'):
case _UT('6'):
case _UT('7'):
case _UT('8'):
case _UT('9'):
case URI_SET_DIGIT(_UT):
uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9')));
return first + 1;

Expand Down
Loading