Skip to content

fix(postgresql): guard null column defaults in extractValueFromDefault#15

Merged
TDannhauer merged 3 commits into
FRAMEWORK_6_0from
fix/postgresql-null-column-default
Jun 21, 2026
Merged

fix(postgresql): guard null column defaults in extractValueFromDefault#15
TDannhauer merged 3 commits into
FRAMEWORK_6_0from
fix/postgresql-null-column-default

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Summary

  • Return early when PostgreSQL column default expressions are null, before the preg_match() chain in extractValueFromDefault().
  • Apply the same guard in both the legacy (lib/) and PSR-4 (src/) PostgreSQL Column classes.
  • Add a unit test covering columns without a default expression.

Motivation

Schema introspection via pg_get_expr() can leave column_default unset for columns with no default. On PHP 8.4, passing that value to preg_match() emits deprecation warnings. This shows up during schema-heavy requests (for example ActiveSync Tasks sync triggering Nag table introspection).

Changes

  • lib/Horde/Db/Adapter/Postgresql/Column.php_extractValueFromDefault()
  • src/Adapter/Postgresql/Column.phpextractValueFromDefault()
  • test/Legacy/Adapter/Postgresql/ColumnTest.phptestMissingDefaultNull()

Test plan

  • vendor/bin/phpunit -c phpunit.xml.dist --testsuite legacy --filter ColumnTest (PostgreSQL Column tests)
  • Construct Column with null default under PHP 8.4 with E_ALL; no deprecation warnings

PostgreSQL schema introspection can return a NULL default expression
when a column has no default. Passing that value to preg_match()
triggers PHP 8.4 deprecations during schema-heavy requests.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents PHP 8.4 deprecation warnings during PostgreSQL schema introspection by short-circuiting extractValueFromDefault() (and its legacy equivalent) when column_default is null, and adds a regression test for a missing default expression.

Changes:

  • Add null guards in both PSR-4 and legacy PostgreSQL Column default-extraction helpers to avoid calling preg_match() with null.
  • Add a unit test ensuring a Column constructed with a null default returns null from getDefault().

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Adapter/Postgresql/Column.php Adds early return for null defaults before regex parsing.
lib/Horde/Db/Adapter/Postgresql/Column.php Mirrors the same null guard in the legacy implementation.
test/Legacy/Adapter/Postgresql/ColumnTest.php Adds a regression test for null default expressions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Adapter/Postgresql/Column.php
Comment thread lib/Horde/Db/Adapter/Postgresql/Column.php
@TDannhauer TDannhauer merged commit 81bebbf into FRAMEWORK_6_0 Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants