xref: /php-src/ext/pgsql/tests/bug72197.phpt (revision c15988aa)
1--TEST--
2Bug #72197 pg_lo_create arbitrary read
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php include("inc/skipif.inc"); ?>
7--FILE--
8<?php
9/* This shouldn't crash. */
10$var1=-32768;
11$var2="12";
12try {
13    pg_lo_create($var1, $var2);
14} catch (TypeError $e) {
15    echo $e->getMessage(), "\n";
16}
17
18/* This should work correctly. */
19include('inc/config.inc');
20
21/* Check with explicit link. */
22$conn = pg_connect($conn_str);
23pg_query($conn, "BEGIN");
24$oid = pg_lo_create($conn);
25var_dump($oid);
26
27/* Check with default link */
28$oid = pg_lo_create();
29var_dump($oid);
30
31/* don't commit */
32pg_query($conn, "ROLLBACK");
33pg_close($conn);
34?>
35--EXPECTF--
36pg_lo_create(): Argument #1 ($connection) must be of type PgSql\Connection when the connection is provided%w
37int(%d)
38
39Deprecated: pg_lo_create(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
40int(%d)
41