Skip to content

New #868: Add SerializationFailureException - #1196

Open
KalimeroMK wants to merge 4 commits into
yiisoft:masterfrom
KalimeroMK:add-868-serialization-failure-exception
Open

New #868: Add SerializationFailureException#1196
KalimeroMK wants to merge 4 commits into
yiisoft:masterfrom
KalimeroMK:add-868-serialization-failure-exception

Conversation

@KalimeroMK

Copy link
Copy Markdown
Contributor

Fix#868

Adds SerializationFailureException for SQLSTATE code 40001 (serialization failure, e.g. transaction deadlock in concurrent updates). The code is the same for all databases, so the conversion is done centrally in ConvertException, next to the existing IntegrityException mapping.

@codecov

codecovBot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.62%. Comparing base (f0b0d2b) to head (99d6356).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #1196 +/- ##
=========================================
Coverage 98.62% 98.62% - Complexity 1645 1646 +1 
=========================================
Files 120 120 Lines 4288 4290 +2 =========================================
+ Hits 4229 4231 +2 
Misses 59 59 

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a database exception for SQLSTATE 40001 serialization failures.

Changes:

  • Adds SerializationFailureException.
  • Maps SQLSTATE 40001 centrally and adds a test.
  • Updates the changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

FileDescription
src/Exception/SerializationFailureException.phpDefines the new exception type.
src/Exception/ConvertException.phpConverts matching failures to the new type.
tests/Db/Exception/ConvertExceptionTest.phpTests serialization-failure conversion.
CHANGELOG.mdDocuments the feature.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment threadsrc/Exception/ConvertException.php Outdated
Comment threadsrc/Exception/ConvertException.php Outdated
Comment threadsrc/Exception/ConvertException.php Outdated
Comment threadsrc/Exception/ConvertException.php Outdated

if (
($errorInfo[0] ?? null) === '40001'
|| str_contains($this->e->getMessage(), self::MSG_SERIALIZATION_FAILURE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are there cases when ($errorInfo[0] ?? null) === '40001' is not enough?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

in real usage PDO always populates errorInfo, so the message fallback only served manually constructed exceptions I Removed it so the check now relies solely on $errorInfo[0] and the test sets errorInfo the way PDO would.

Sign up for freeto 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.

Add SerializationFailureException

5 participants

@KalimeroMK@vjik@Tigrov@zoranbogoevskimkd