|
| 1 | +--TEST-- |
| 2 | +GH-20553: PHP 8.5.0 regression: PDO::FETCH_CLASSTYPE ignores $constructorArgs |
| 3 | +--EXTENSIONS-- |
| 4 | +pdo |
| 5 | +--SKIPIF-- |
| 6 | +<?php |
| 7 | +$dir = getenv('REDIR_TEST_DIR'); |
| 8 | +if (false == $dir) die('skip no driver'); |
| 9 | +if (str_starts_with(getenv('PDOTEST_DSN'), "firebird")) { |
| 10 | + die("skip firebird doesn't support non-standard SQL without FROM syntax"); |
| 11 | +} |
| 12 | +require_once $dir . 'pdo_test.inc'; |
| 13 | +PDOTest::skip(); |
| 14 | +?> |
| 15 | +--FILE-- |
| 16 | +<?php |
| 17 | + |
| 18 | +if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/'); |
| 19 | +require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; |
| 20 | +$db = PDOTest::factory(); |
| 21 | + |
| 22 | +class dumpy { |
| 23 | + function __construct() { |
| 24 | + echo 'constructor called,' . PHP_EOL . ' my class is ' . |
| 25 | + var_export(get_class($this), true) . PHP_EOL . |
| 26 | + ' input parameters: ' . |
| 27 | + var_export(func_get_args(), true) . PHP_EOL; |
| 28 | + } |
| 29 | + function __set($name, $value) { |
| 30 | + echo var_export($name, true) . ' = ' . var_export($value, true) . |
| 31 | + PHP_EOL; |
| 32 | + } |
| 33 | +} |
| 34 | +class dummy extends dumpy { |
| 35 | +} |
| 36 | + |
| 37 | +$sql = "SELECT 'dummy' pdo_fetch_class_type_class, 'bar' foo, 'dfg' abc"; |
| 38 | + |
| 39 | +$fetchModes = [ |
| 40 | + 'PDO::FETCH_CLASS' |
| 41 | + => PDO::FETCH_CLASS, |
| 42 | + 'PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE' |
| 43 | + => PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, |
| 44 | + 'PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE' |
| 45 | + => PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE, |
| 46 | + 'PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_PROPS_LATE' |
| 47 | + => PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_PROPS_LATE, |
| 48 | +]; |
| 49 | + |
| 50 | +foreach ($fetchModes as $combinedModes => $fetchMode) { |
| 51 | + echo '## ' . $combinedModes . PHP_EOL; |
| 52 | + $db->query($sql)->fetchAll( |
| 53 | + $fetchMode, |
| 54 | + 'dumpy', |
| 55 | + ['constructor argument #1'] |
| 56 | + ); |
| 57 | + echo PHP_EOL; |
| 58 | +} |
| 59 | +?> |
| 60 | +--EXPECT-- |
| 61 | +## PDO::FETCH_CLASS |
| 62 | +'pdo_fetch_class_type_class' = 'dummy' |
| 63 | +'foo' = 'bar' |
| 64 | +'abc' = 'dfg' |
| 65 | +constructor called, |
| 66 | + my class is 'dumpy' |
| 67 | + input parameters: array ( |
| 68 | + 0 => 'constructor argument #1', |
| 69 | +) |
| 70 | + |
| 71 | +## PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE |
| 72 | +constructor called, |
| 73 | + my class is 'dumpy' |
| 74 | + input parameters: array ( |
| 75 | + 0 => 'constructor argument #1', |
| 76 | +) |
| 77 | +'pdo_fetch_class_type_class' = 'dummy' |
| 78 | +'foo' = 'bar' |
| 79 | +'abc' = 'dfg' |
| 80 | + |
| 81 | +## PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE |
| 82 | +'foo' = 'bar' |
| 83 | +'abc' = 'dfg' |
| 84 | +constructor called, |
| 85 | + my class is 'dummy' |
| 86 | + input parameters: array ( |
| 87 | + 0 => 'constructor argument #1', |
| 88 | +) |
| 89 | + |
| 90 | +## PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_PROPS_LATE |
| 91 | +constructor called, |
| 92 | + my class is 'dummy' |
| 93 | + input parameters: array ( |
| 94 | + 0 => 'constructor argument #1', |
| 95 | +) |
| 96 | +'foo' = 'bar' |
| 97 | +'abc' = 'dfg' |
0 commit comments