1--TEST--
2PostgreSQL fetching default link automatically is deprecated
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php include("skipif.inc"); ?>
7--FILE--
8<?php
9
10include('config.inc');
11$db = pg_connect($conn_str);
12
13// We don't care about warnings
14ini_set('error_reporting', E_ALL&~E_WARNING);
15
16// Special cases
17pg_set_error_verbosity(PGSQL_ERRORS_TERSE);
18pg_query_params('str', []);
19pg_execute('str', []);
20
21pg_lo_unlink(1);
22// deprecated alias 'pg_lounlink',
23pg_lo_open(1, 'r');
24// deprecated alias 'pg_loopen',
25pg_lo_export(1, '');
26// deprecated alias 'pg_loexport',
27
28$functions = [
29'pg_dbname',
30'pg_last_error',
31// deprecated alias 'pg_errormessage',
32'pg_options',
33'pg_port',
34'pg_tty',
35'pg_host',
36'pg_version',
37'pg_parameter_status',
38'pg_ping',
39'pg_query',
40'pg_exec',
41'pg_prepare',
42'pg_untrace',
43'pg_lo_create',
44// deprecated alias 'pg_locreate',
45'pg_lo_import',
46// deprecated alias 'pg_loimport',
47'pg_set_client_encoding',
48// deprecated alias 'pg_setclientencoding',
49'pg_client_encoding',
50// deprecated alias 'pg_clientencoding',
51'pg_end_copy',
52'pg_put_line',
53'pg_escape_string',
54'pg_escape_bytea',
55'pg_escape_literal',
56'pg_escape_identifier',
57'pg_close',
58];
59
60foreach ($functions as $function) {
61    $args = [];
62    $argNum = 0;
63    retry:
64    try {
65        $function(...$args);
66        continue;
67    } catch (ArgumentCountError) {
68        $args[] = 'str';
69        ++$argNum;
70        goto retry;
71    } catch (TypeError $e) {
72        if (str_contains($e->getMessage(), 'type array')) {
73            $args[$argNum] = [];
74            goto retry;
75        }
76        var_dump($e->getMessage());
77    } catch (\Error $e) {
78        echo $e->getMessage();
79    }
80}
81
82echo "END";
83?>
84--EXPECTF--
85Deprecated: pg_set_error_verbosity(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
86
87Deprecated: pg_query_params(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
88
89Deprecated: pg_execute(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
90
91Deprecated: pg_lo_unlink(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
92
93Deprecated: pg_lo_open(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
94
95Deprecated: pg_lo_export(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
96
97Deprecated: pg_dbname(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
98
99Deprecated: pg_last_error(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
100
101Deprecated: pg_options(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
102
103Deprecated: pg_port(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
104
105Deprecated: pg_tty(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
106
107Deprecated: pg_host(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
108
109Deprecated: pg_version(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
110
111Deprecated: pg_parameter_status(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
112
113Deprecated: pg_ping(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
114
115Deprecated: pg_query(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
116
117Deprecated: pg_exec(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
118
119Deprecated: pg_prepare(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
120
121Deprecated: pg_untrace(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
122
123Deprecated: pg_lo_create(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
124
125Deprecated: pg_lo_import(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
126
127Deprecated: pg_set_client_encoding(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
128
129Deprecated: pg_client_encoding(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
130
131Deprecated: pg_end_copy(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
132
133Deprecated: pg_put_line(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
134
135Deprecated: pg_escape_string(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
136
137Deprecated: pg_escape_bytea(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
138
139Deprecated: pg_escape_literal(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
140
141Deprecated: pg_escape_identifier(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
142
143Deprecated: pg_close(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
144END
145