1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/pgsql/tests/pg_fetch_object_with_abstract_class.phpt
Gina Peter Banyard 94dc6ae871 ext/pgsql: Fix segfaults when attempting to fetch row into a non-instantiable class name (#20180)
Also fix Windows CI with Postgres and CLEAN sections

---------

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-11-04 00:04:30 +00:00

60 lines
1.2 KiB
PHP

--TEST--
pg_fetch_object() with abstract class name
--EXTENSIONS--
pgsql
--SKIPIF--
<?php
include("skipif.inc");
?>
--FILE--
<?php
interface I {}
abstract class C {}
enum E {
case A;
}
include "config.inc";
$table_name = "pg_fetch_object_abstract_class";
$db = pg_connect($conn_str);
pg_query($db, "CREATE TABLE {$table_name} (a integer, b text)");
pg_query($db, "INSERT INTO {$table_name} VALUES(0, 'ABC')");
$sql = "SELECT * FROM $table_name WHERE a = 0";
try {
$result = pg_query($db, $sql);
var_dump(pg_fetch_object($result, NULL, 'I'));
} catch(Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
$result = pg_query($db, $sql);
var_dump(pg_fetch_object($result, NULL, 'C'));
} catch(Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
$result = pg_query($db, $sql);
var_dump(pg_fetch_object($result, NULL, 'E'));
} catch(Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--CLEAN--
<?php
include('config.inc');
$db = @pg_connect($conn_str);
@pg_query($db, "DROP TABLE IF EXISTS pg_fetch_object_abstract_class cascade");
?>
--EXPECT--
Error: Cannot instantiate interface I
Error: Cannot instantiate abstract class C
Error: Cannot instantiate enum E