fix(postgresql): guard null column defaults in extractValueFromDefault#15
Merged
Merged
Conversation
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.
There was a problem hiding this comment.
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
nullguards in both PSR-4 and legacy PostgreSQL Column default-extraction helpers to avoid callingpreg_match()withnull. - Add a unit test ensuring a
Columnconstructed with anulldefault returnsnullfromgetDefault().
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
null, before thepreg_match()chain inextractValueFromDefault().lib/) and PSR-4 (src/) PostgreSQL Column classes.Motivation
Schema introspection via
pg_get_expr()can leavecolumn_defaultunset for columns with no default. On PHP 8.4, passing that value topreg_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.php—extractValueFromDefault()test/Legacy/Adapter/Postgresql/ColumnTest.php—testMissingDefaultNull()Test plan
vendor/bin/phpunit -c phpunit.xml.dist --testsuite legacy --filter ColumnTest(PostgreSQL Column tests)Columnwithnulldefault under PHP 8.4 withE_ALL; no deprecation warnings