Skip to content

CP-17204 connection lost#17208

Merged
niden merged 20 commits into
5.0.xfrom
CP-17204-connection-lost
Jun 21, 2026
Merged

CP-17204 connection lost#17208
niden merged 20 commits into
5.0.xfrom
CP-17204-connection-lost

Conversation

@niden

@niden niden commented Jun 21, 2026

Copy link
Copy Markdown
Member

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a PR for the documentation about this change

Added connection-liveness and opt-in auto-reconnect support to Phalcon\Db\Adapter\Pdo\AbstractPdo: ping() (a SELECT 1 probe), ensureConnection() (reconnect in place when the probe fails), and setAutoReconnect()/getAutoReconnect() (also settable via the autoReconnect descriptor key). When auto-reconnect is enabled and a query fails on a lost ("gone away") connection outside a transaction, execute() and query() fire the new db:connectionLost event, reconnect, and retry the statement once; a loss inside a transaction is re-thrown without retry. "Gone away" detection is provided per driver by Phalcon\Db\Adapter\Pdo\Mysql (error codes 2006/2013) and Phalcon\Db\Adapter\Pdo\Postgresql (SQLSTATE 08003/08006/57P01-03), with a message fallback.

Added the same liveness and opt-in auto-reconnect support to Phalcon\DataMapper\Pdo\Connection (ping(), ensureConnection(), setAutoReconnect()/getAutoReconnect()), wrapping exec(), perform(), prepare(), and query() with the single-retry behavior. This connection has no events manager, so no db:connectionLost event is fired; "gone away" detection is driver-agnostic and the in-transaction guard uses a locally tracked transaction level.

Thanks

niden and others added 16 commits June 12, 2026 16:06
The :params placeholder and the built-in default MVC/CLI routes compiled to the nested quantifier (/.*)*, whose overlapping body backtracks catastrophically when the trailing anchor cannot match. Because Router::handle() runs the pattern against the request URI on every request, a short crafted URI drove preg_match() into exponential time.

Compile the trailing group to the equivalent (/.*)? instead. It accepts the same language and captures the same params value, so routing behaviour is unchanged while the nested quantifier is removed. Updated the affected compiled-pattern tests and added a regression test.
Assisted-by: Claude Code
Assisted-by: Claude Code
Fix router params redos
Assisted-by: Claude Code
Assisted-by: Claude Code
@niden niden requested a review from Jeckerson June 21, 2026 01:53
@niden niden self-assigned this Jun 21, 2026
@niden niden added new feature request Planned Feature or New Feature Request 5.0 The issues we want to solve in the 5.0 release labels Jun 21, 2026
@niden niden merged commit 63060d0 into 5.0.x Jun 21, 2026
58 checks passed
@niden niden deleted the CP-17204-connection-lost branch June 21, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.0 The issues we want to solve in the 5.0 release new feature request Planned Feature or New Feature Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants