Skip to content

Commit a89eb20

Browse files
committed
ext/pgsql: remove deprecated default link support
1 parent 655f116 commit a89eb20

15 files changed

+320
-561
lines changed

ext/pgsql/pgsql.c

+236-268
Large diffs are not rendered by default.

ext/pgsql/pgsql.stub.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -489,76 +489,76 @@ function pg_pconnect(string $connection_string, int $flags = 0): PgSql\Connectio
489489

490490
function pg_connect_poll(PgSql\Connection $connection): int {}
491491

492-
function pg_close(?PgSql\Connection $connection = null): true {}
492+
function pg_close(PgSql\Connection $connection): true {}
493493

494494
/** @refcount 1 */
495-
function pg_dbname(?PgSql\Connection $connection = null): string {}
495+
function pg_dbname(PgSql\Connection $connection): string {}
496496

497-
function pg_last_error(?PgSql\Connection $connection = null): string {}
497+
function pg_last_error(PgSql\Connection $connection): string {}
498498

499499
/**
500500
* @alias pg_last_error
501501
* @deprecated
502502
*/
503-
function pg_errormessage(?PgSql\Connection $connection = null): string {}
503+
function pg_errormessage(PgSql\Connection $connection): string {}
504504

505505
/** @refcount 1 */
506-
function pg_options(?PgSql\Connection $connection = null): string {}
506+
function pg_options(PgSql\Connection $connection): string {}
507507

508508
/** @refcount 1 */
509-
function pg_port(?PgSql\Connection $connection = null): string {}
509+
function pg_port(PgSql\Connection $connection): string {}
510510

511511
/** @refcount 1 */
512-
function pg_tty(?PgSql\Connection $connection = null): string {}
512+
function pg_tty(PgSql\Connection $connection): string {}
513513

514514
/** @refcount 1 */
515-
function pg_host(?PgSql\Connection $connection = null): string {}
515+
function pg_host(PgSql\Connection $connection): string {}
516516

517517
/**
518518
* @return array<string, int|string|null>
519519
* @refcount 1
520520
*/
521-
function pg_version(?PgSql\Connection $connection = null): array {}
521+
function pg_version(PgSql\Connection $connection): array {}
522522

523523
/**
524524
* @param PgSql\Connection|string $connection
525525
* @refcount 1
526526
*/
527-
function pg_parameter_status($connection, string $name = UNKNOWN): string|false {}
527+
function pg_parameter_status($connection, string $name): string|false {}
528528

529-
function pg_ping(?PgSql\Connection $connection = null): bool {}
529+
function pg_ping(PgSql\Connection $connection): bool {}
530530

531531
/**
532532
* @param PgSql\Connection|string $connection
533533
* @refcount 1
534534
*/
535-
function pg_query($connection, string $query = UNKNOWN): PgSql\Result|false {}
535+
function pg_query($connection, string $query): PgSql\Result|false {}
536536

537537
/**
538538
* @param PgSql\Connection|string $connection
539539
* @alias pg_query
540540
*/
541-
function pg_exec($connection, string $query = UNKNOWN): PgSql\Result|false {}
541+
function pg_exec($connection, string $query): PgSql\Result|false {}
542542

543543
/**
544544
* @param PgSql\Connection|string $connection
545545
* @param string|array $query
546546
* @refcount 1
547547
*/
548-
function pg_query_params($connection, $query, array $params = UNKNOWN): PgSql\Result|false {}
548+
function pg_query_params($connection, $query, array $params): PgSql\Result|false {}
549549

550550
/**
551551
* @param PgSql\Connection|string $connection
552552
* @refcount 1
553553
*/
554-
function pg_prepare($connection, string $statement_name, string $query = UNKNOWN): PgSql\Result|false {}
554+
function pg_prepare($connection, string $statement_name, string $query): PgSql\Result|false {}
555555

556556
/**
557557
* @param PgSql\Connection|string $connection
558558
* @param string|array $statement_name
559559
* @refcount 1
560560
*/
561-
function pg_execute($connection, $statement_name, array $params = UNKNOWN): PgSql\Result|false {}
561+
function pg_execute($connection, $statement_name, array $params): PgSql\Result|false {}
562562

563563
function pg_num_rows(PgSql\Result $result): int {}
564564

@@ -707,9 +707,9 @@ function pg_last_oid(PgSql\Result $result): string|int|false {}
707707
*/
708708
function pg_getlastoid(PgSql\Result $result): string|int|false {}
709709

710-
function pg_trace(string $filename, string $mode = "w", ?PgSql\Connection $connection = null, int $trace_mode = 0): bool {}
710+
function pg_trace(string $filename, string $mode = "w", PgSql\Connection $connection, int $trace_mode = 0): bool {}
711711

712-
function pg_untrace(?PgSql\Connection $connection = null): true {}
712+
function pg_untrace(PgSql\Connection $connection): true {}
713713

714714
/**
715715
* @param PgSql\Connection $connection
@@ -840,15 +840,15 @@ function pg_set_client_encoding($connection, string $encoding = UNKNOWN): int {}
840840
*/
841841
function pg_setclientencoding($connection, string $encoding = UNKNOWN): int {}
842842

843-
function pg_client_encoding(?PgSql\Connection $connection = null): string {}
843+
function pg_client_encoding(PgSql\Connection $connection): string {}
844844

845845
/**
846846
* @alias pg_client_encoding
847847
* @deprecated
848848
*/
849-
function pg_clientencoding(?PgSql\Connection $connection = null): string {}
849+
function pg_clientencoding(PgSql\Connection $connection): string {}
850850

851-
function pg_end_copy(?PgSql\Connection $connection = null): bool {}
851+
function pg_end_copy(PgSql\Connection $connection): bool {}
852852

853853
/** @param PgSql\Connection|string $connection */
854854
function pg_put_line($connection, string $query = UNKNOWN): bool {}

ext/pgsql/pgsql_arginfo.h

+20-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/pgsql/php_pgsql.h

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ ZEND_BEGIN_MODULE_GLOBALS(pgsql)
187187
zend_long allow_persistent;
188188
zend_long auto_reset_persistent;
189189
int ignore_notices,log_notices;
190-
zend_object *default_link; /* default link when connection is omitted */
191190
HashTable field_oids;
192191
HashTable table_oids;
193192
HashTable connections;

ext/pgsql/tests/05large_object.phpt

+9-20
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ pg_exec ($db, "commit");
5656
echo "Test without connection\n";
5757
pg_exec ($db, "begin");
5858
$oid = pg_lo_create ($db) or print("pg_lo_create() error\n");
59-
pg_lo_unlink($oid) or print("pg_lo_unlink() error 2\n");
60-
pg_exec ($db, "commit");
59+
60+
try {
61+
pg_lo_unlink($oid);
62+
} catch (Error $e) {
63+
echo $e->getMessage(), \PHP_EOL;
64+
}
6165

6266
echo "Test with string oid value\n";
6367
pg_exec ($db, "begin");
@@ -80,21 +84,11 @@ if (!file_exists($path . 'php.gif.exported')) {
8084
pg_query($db, 'commit');
8185

8286
/* invalid OID values */
83-
try {
84-
pg_lo_create(-15);
85-
} catch (\ValueError $e) {
86-
echo $e->getMessage(), \PHP_EOL;
87-
}
8887
try {
8988
pg_lo_create($db, -15);
9089
} catch (\ValueError $e) {
9190
echo $e->getMessage(), \PHP_EOL;
9291
}
93-
try {
94-
pg_lo_create('giberrish');
95-
} catch (\ValueError $e) {
96-
echo $e->getMessage(), \PHP_EOL;
97-
}
9892
try {
9993
pg_lo_create($db, 'giberrish');
10094
} catch (\ValueError $e) {
@@ -119,17 +113,12 @@ open/read_all/close LO
119113
large object data
120114
int(17)
121115
unlink LO
116+
pg_lo_unlink() error 1
122117
Test without connection
123-
124-
Deprecated: pg_lo_unlink(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
118+
Requires 2 arguments, 1 given
125119
Test with string oid value
120+
pg_lo_unlink() error 3
126121
import/export LO
127-
128-
Deprecated: pg_lo_create(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
129-
Invalid OID value passed
130-
Invalid OID value passed
131-
132-
Deprecated: pg_lo_create(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
133122
Invalid OID value passed
134123
Invalid OID value passed
135124
OK

ext/pgsql/tests/08escape.phpt

-3
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ else {
9999

100100
?>
101101
--EXPECTF--
102-
Deprecated: pg_escape_string(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
103102
pg_escape_string() is Ok
104-
105-
Deprecated: pg_escape_bytea(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
106103
pg_escape_bytea() is Ok
107104
pg_escape_bytea() actually works with database
108105
pg_escape_literal() is Ok

ext/pgsql/tests/18pg_escape_bytea_before.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ else {
2929
}
3030
?>
3131
--EXPECTF--
32-
Deprecated: pg_escape_bytea(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
3332
OK

ext/pgsql/tests/27large_object_oid.phpt

-17
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,9 @@ if ($oid != 21001) echo ("pg_lo_create() wrong id\n");
3232
pg_lo_unlink ($db, $oid);
3333
pg_exec ($db, "commit");
3434

35-
echo "create LO using default connection\n";
36-
pg_exec ("begin");
37-
$oid = pg_lo_create (21002);
38-
if (!$oid) echo ("pg_lo_create() error\n");
39-
if ($oid != 21002) echo ("pg_lo_create() wrong id\n");
40-
pg_lo_unlink ($oid);
41-
pg_exec ("commit");
42-
4335
echo "OK";
4436
?>
4537
--EXPECTF--
4638
create LO from int
4739
create LO from string
48-
create LO using default connection
49-
50-
Deprecated: pg_exec(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
51-
52-
Deprecated: pg_lo_create(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
53-
54-
Deprecated: pg_lo_unlink(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
55-
56-
Deprecated: pg_exec(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
5740
OK

0 commit comments

Comments
 (0)