360 Commits
Author SHA1 Message Date
David Carlier 931d8ea4e1 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  ext/pgsql: Removed `pg_service()`, unavailable with any released libpq

# Conflicts:
#	ext/pgsql/pgsql.c
#	ext/pgsql/pgsql_arginfo.h
2026-09-24 04:48:20 +01:00
武田 憲太郎 43c6014670 ext/pgsql: Removed pg_service(), unavailable with any released libpq
`PQservice()` never shipped in a released libpq; it was dropped during the
PostgreSQL 18 beta.

Close GH-23857
2026-09-24 04:47:49 +01:00
Ilia Alshanetsky 0744a9072a Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/pgsql: Restore binary-safe pg_lo_write()
2026-09-13 10:21:38 -04:00
Ilia Alshanetsky c135a869c1 ext/pgsql: Restore binary-safe pg_lo_write()
The conversion of the data parameter to Z_PARAM_PATH_STR() made
pg_lo_write() reject any data containing a null byte, breaking writes of
arbitrary binary payloads which were accepted before. Accept embedded
null bytes again by parsing the data as a length-aware string. Sibling
audit: the other Z_PARAM_PATH* conversions from the same change
(pg_connect(), pg_lo_import(), table/statement identifiers) operate on
paths or SQL text where null-byte rejection is intentional.

Closes GH-23649
2026-09-13 10:17:47 -04:00
lacatoire 65ae1ad847 ext/pgsql: stop advertising PGSQL_DML_ASYNC where it is refused
pg_update() and pg_delete() list PGSQL_DML_ASYNC among the valid flags in
the error they raise, although their masks reject it and their helpers
assert it is never set. Conversely pg_insert() and pg_update() accept the
whole PGSQL_CONV_OPTS set but only named PGSQL_CONV_FORCE_NULL, so
PGSQL_CONV_IGNORE_DEFAULT and PGSQL_CONV_IGNORE_NOT_NULL are added.

While there, widen php_pgsql_delete()'s assert to PGSQL_DML_NO_CONV,
which pg_delete() accepts and the helper itself consults.

Close GH-23480
2026-08-27 21:05:19 +01:00
Gina Peter Banyard ee908f5542 Zend: normalise behaviour around class name ZPP specifier (#23359)
Splitting the behavioural change of #23052 out into this and come up with something that is hopefully more sensible and consistent between fast and slow ZPP and the object or class_name Fast ZPP specifier.
2026-08-21 13:31:45 +01:00
lacatoire fb604aab1d ext/pgsql: fix the class name casing of pg_close_stmt()'s connection
The stub spelled it Pgsql\Connection, the only such spelling in the
extension. Resolution is case-insensitive, but Reflection reported a
class name that does not match the declared one.

Close GH-23393
2026-08-20 21:37:42 +01:00
Gina Peter Banyard 0b14af3b98 standard: deprecate aliases with non canonical type name
Fix tests using non canonical versions and improve existing tests.

RFC:
- https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_is_double
- https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_is_integer
- https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_is_long
- https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_doubleval
2026-08-10 18:21:19 +01:00
NickSdot 5d58876192 tests: Cache failed service probes (#22944)
Prevents unavailable optional test services from slowing the suite through repeated connection timeouts. PDO and SNMP availability probes cache the first failure for the duration of one test run, so later SKIPIF checks return immediately.

Only failures are cached; successful probes and test connections are unchanged. PDOs one second timeout applies only to the default availability probe. The caches are private, run-scoped and removed afterwards. A service becoming available mid run is detected on the next test-suite run.
2026-08-06 11:42:56 +02:00
NickSdot 4905ce8e55 ext/pgsql: applied fixers to improve test robustness (#23040) 2026-08-04 18:13:33 +01:00
Ilija Tovilo fb21752483 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix out-of-bounds write in ext-bcmath bccomp() via bc_str2num()
  Add NEWS entries
  Fix GHSA-vc5h-9ppw-p5f3: phar circular symlink crash
  Fix SQL injection in ext-pgsql via E'...' backslash breakout
  libgd patch for CVE-2026-9672
2026-07-28 11:58:05 +02:00
Ilija Tovilo e5c3b4b083 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix out-of-bounds write in ext-bcmath bccomp() via bc_str2num()
  Add NEWS entries
  Fix GHSA-vc5h-9ppw-p5f3: phar circular symlink crash
  Fix SQL injection in ext-pgsql via E'...' backslash breakout
  libgd patch for CVE-2026-9672
2026-07-28 11:51:44 +02:00
Ilija Tovilo d3f361c3b7 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add NEWS entries
  Fix GHSA-vc5h-9ppw-p5f3: phar circular symlink crash
  Fix SQL injection in ext-pgsql via E'...' backslash breakout
  libgd patch for CVE-2026-9672
2026-07-28 11:50:34 +02:00
Ilija Tovilo 416985389d Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add NEWS entries
  Fix GHSA-vc5h-9ppw-p5f3: phar circular symlink crash
  Fix SQL injection in ext-pgsql via E'...' backslash breakout
  libgd patch for CVE-2026-9672
2026-07-28 11:41:07 +02:00
Ilija Tovilo ab048bd83b Fix SQL injection in ext-pgsql via E'...' backslash breakout
php_pgsql_add_quotes() quotes the string with E'...', but PQescapeStringConn()
does not escape \ unless standard_conforming_strings is off.
PQescapeStringConn() is meant to be used with '', so do that instead.

Fixes GHSA-7qpv-r5mr-78m4
2026-07-28 11:11:57 +02:00
David Carlier 392a84d7e1 ext/pgsql: clean up pg_fetch_object() constructor handling.
Move object_init_ex() before php_pgsql_fetch_hash() so abstract,
interface and enum errors surface earlier, look up the constructor
via the get_constructor handler (under EG(fake_scope)) so classes
with overridden handlers work, and mark the object as ctor-failed
when the constructor throws.

The ValueError for ctor args on a class without a constructor now
reports argument 4 ($constructor_args) instead of argument 3 ($class).

close GH-21884
2026-04-29 12:29:11 +01:00
KentarouTakeda c56e8caaed ext/pgsql, ext/pdo_pgsql: Remove preprocessor guards for symbols predating libpq 10 (#21384)
While working on php/doc-en#5409 to clean up outdated PostgreSQL
version notes in the documentation, I noticed that the source code
also retains #ifdef guards for symbols guaranteed to exist in
libpq >= 10.0 (the minimum enforced in build/php.m4 via
PQencryptPasswordConn).

Removed guards (all confirmed in PostgreSQL 10 documentation):

- `PG_DIAG_{INTERNAL_POSITION,INTERNAL_QUERY}`: libpq 8.0+
- `PG_DIAG_{SCHEMA,TABLE,COLUMN,DATATYPE,CONSTRAINT}_NAME`: libpq 9.3+
- `PG_DIAG_SEVERITY_NONLOCALIZED`: libpq 9.6+
- `CONNECTION_SSL_STARTUP`: libpq 8.0+
- `CONNECTION_CONSUME`: libpq 10.0+

Refs:
- https://www.postgresql.org/docs/10/libpq-exec.html#LIBPQ-PQRESULTERRORFIELD
- https://www.postgresql.org/docs/10/libpq-connect.html#LIBPQ-PQCONNECTSTARTPARAMS
- https://github.com/php/php-src/blob/53e31d58834ef04375dae7bdc549d73dae371c5a/build/php.m4#L1927
2026-03-08 05:42:50 +00:00
David Carlier 8ca6e13c2d Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/pgsql: fix GH-21165 unit test.
2026-02-17 04:27:21 +00:00
David Carlier f7af877cfe ext/pgsql: fix GH-21165 unit test.
making it fails early instead.

close GH-21234
2026-02-17 04:26:42 +00:00
David Carlier 6c8a71b3b7 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-21162: pg_connect() on error memory leak.
2026-02-15 21:27:19 +00:00
David Carlier 539c5d9f76 Fix GH-21162: pg_connect() on error memory leak.
The PHP_PQ_ERROR macro calls php_error_docref() which triggers user error handlers
thus libpq does not have the chance to clean the resources (and empty
connections string are allowed) on failure thus we avoid this macro
and delay the error handling after.

close GH-21165
2026-02-15 21:26:23 +00:00
Gina Peter Banyard 3afac4c7f1 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix include paths for new pgsql tests
2025-11-04 04:42:53 +00:00
Gina Peter Banyard 14ed75e560 Fix include paths for new pgsql tests 2025-11-04 04:42:42 +00:00
Gina Peter Banyard 7c6affd617 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Update NEWS for recent pgsql bugfix
  ext/pgsql: Fix segfaults when attempting to fetch row into a non-instantiable class name (#20180)
2025-11-04 00:09:44 +00:00
Gina Peter Banyard afca514c3b Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Update NEWS for recent pgsql bugfix
  ext/pgsql: Fix segfaults when attempting to fetch row into a non-instantiable class name (#20180)
2025-11-04 00:08:42 +00:00
Gina Peter BanyardandNiels Dossche 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
Jakub Zelenka a2cdff5583 Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
This adds error checks for escape function is pgsql and pdo_pgsql
extensions. It prevents possibility of storing not properly escaped
data which could potentially lead to some security issues.
2025-07-01 19:46:48 +03:00
Jakub Zelenka 545d1536d8 Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
This adds error checks for escape function is pgsql and pdo_pgsql
extensions. It prevents possibility of storing not properly escaped
data which could potentially lead to some security issues.
2025-07-01 09:34:49 -07:00
Ilija Tovilo 49d94cced0 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GHSA-453j-q27h-5p8x
  Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
  Fix GHSA-3cr5-j632-f35r: Null byte in hostnames
2025-07-01 17:48:00 +02:00
Jakub Zelenka 66bd809ac9 Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
This adds error checks for escape function is pgsql and pdo_pgsql
extensions. It prevents possibility of storing not properly escaped
data which could potentially lead to some security issues.
2025-07-01 23:01:16 +09:00
David Carlier 334d9bbc09 ext/pgsql: adding pg_service() alongside other connection infos.
returns the ongoing name of the service, if there is.
available since postgres 18

close GH-18198
2025-03-30 21:45:16 +01:00
David Carlier 50bffd3284 Merge branch 'PHP-8.4' 2025-03-26 17:46:38 +00:00
David Carlier 9c6fe6b0ff Fix GH-18148: pg_copy_from() wrong \n offset check.
Close GH-18149
2025-03-26 17:44:01 +00:00
David Carlier f82f602ec8 ext/pgsql: few internal changes.
Z_PARAM_STR*/Z_PARAM_PATH. lo_write checks any null byte.

close GH-17587
2025-01-26 19:15:36 +00:00
David Carlier fa8c6a552d Merge branch 'PHP-8.4' 2024-12-15 16:05:20 +00:00
David Carlier 171cc5c6e0 fix pgsql config inclusion 2024-12-15 16:05:10 +00:00
David Carlier 36d5a0fdcd Merge branch 'PHP-8.4' 2024-12-15 15:22:47 +00:00
David Carlier 1bb4bd657f fix new pgsql test 2024-12-15 15:22:35 +00:00
David Carlier 9ba2667cf5 Merge branch 'PHP-8.4' 2024-12-15 14:56:29 +00:00
David Carlier 2309cac755 Merge branch 'PHP-8.3' into PHP-8.4 2024-12-15 14:55:36 +00:00
David Carlier 0a3442fbe6 ext/pgsql fixing further calls with flexible arguments number.
continuation of GH-17161

close GH-17165
2024-12-15 14:50:59 +00:00
Niels Dossche 57e9429e73 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17158: pg_fetch_result Shows Incorrect ArgumentCountError Message when Called With 1 Argument
2024-12-14 19:49:12 +01:00
Niels Dossche e562b8cf8e Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17158: pg_fetch_result Shows Incorrect ArgumentCountError Message when Called With 1 Argument
2024-12-14 19:49:04 +01:00
Niels Dossche 388f63c310 Fix GH-17158: pg_fetch_result Shows Incorrect ArgumentCountError Message when Called With 1 Argument
Closes GH-17161.
2024-12-14 19:48:40 +01:00
Niels Dossche 21df4a97a3 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Backport GH-14962 to stable versions
2024-11-26 21:25:05 +01:00
Michael Orlitzky ae84b81bfa Backport GH-14962 to stable versions
Alpine CI regularly fails because of the sorting order of these tests.
See https://github.com/php/php-src/pull/14962#issuecomment-2498799881

Closes GH-16950.
2024-11-26 21:24:48 +01:00
David Carlier e609a21906 ext/pgsql: pgsql_copy_from to support iterable.
inspired from the Pdo\Pgsql new feature GH-15893.

close GH-16124
2024-10-01 19:53:20 +01:00
David Carlier 1da352c367 ext/pgsql: adding pg_close_stmt.
up to postgresql 17, when done with a prepared statement, we could
release it with DEALLOCATE sql command which is fine ; until we want
to implement a cache solution based on statement ids.

Since PostgreSQL 17, PQclosePrepared uses internally the `close` protocol
allowing to reuse the statement name while still freeing it.
Since the close protocol implementation had been added on libpq within
this release, no way to reimplement it.

close GH-14584
2024-09-29 16:26:35 +01:00
Gina Peter Bnayard 5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Michael Orlitzky 44b0baf705 ext/dba/tests: sort expected test output (#14962)
* ext/dba/tests/setup/setup_dba_tests.inc: sort test output

Iterating through a database with firstkey() and nextkey() is
guaranteed to retrieve all rows, but apparently not in any particular
order. This is causing a test failure for at least one user, so we
steal the sort() approach from GDBM to ensure that the output is
predictable.

* ext/dba/tests/dba_*.phpt: sort expected test output

The actual output is now sorted for consistency, so we need to update
the expected output as well. As a nice side effect, some differences
in the expected outputs for the various engines have been eliminated.

Closes GH-14786

* ext/pgsql/tests/80_bug14383.phpt: sort expected test output

This test uses a routine from ext/dba that now sorts its (actual)
output, so we have to sort the expected output here as well.

* ext/dba/tests/setup/setup_dba_tests.inc: update comment

After doing some more digging, it looks like GDBM isn't the only
engine where the iteration order with firstkey() and nextkey()
might change unexpectedly.
2024-07-26 01:16:52 +01:00