Skip to content

fix(presentations): catch Throwable in PresentationMaterial::getSummitId - #603

Merged
smarcet merged 2 commits into
mainfrom
fix/presentation-material-summit-id-catch-throwable
Sep 16, 2026
Merged

smarcet merged 2 commits into
mainfrom
fix/presentation-material-summit-id-catch-throwable

Conversation

@smarcet

@smarcet smarcet commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

main is red since #579: the integration-tests (Services, tests/Unit/Services/) job fails on PresentationMaterialEventDispatchTest::testDeleteMediaUploadDispatchesLifeCycleEventWithoutError with Error: Call to a member function getSummitId() on null at PresentationMaterial.php:82.

Root cause

Presentation::removeMediaUpload() nulls the owning presentation before Doctrine's PreRemove fires, so PresentationMaterial::getSummitId() dereferences null and PHP throws \Error. The method only caught \Exception, which \Error does not extend, so the error escaped the lifecycle listener and aborted the flush. The test added in #579 already documents this as the accepted degraded case (summit_id 0) and expects the catch to cover \Throwable.

PresentationMaterial::getPresentationId() has the same shape ($this->presentation->getId() inside a catch (\Exception)) and fails the same way on a material whose presentation is not set.

Change

  • PresentationMaterial::getSummitId() and PresentationMaterial::getPresentationId(): catch (\Exception $ex) becomes catch (\Throwable $ex), falling back to 0 as before. These are the only two catches in the file.
  • PresentationMaterialEventDispatchTest::testAccessorsReturnZeroWhenPresentationIsNotSet: asserts both accessors return 0 on a material with no presentation.

Not changed: ScheduleEntity::_getSummitId() and ScheduleEntity::deleting() also catch only \Exception. Left as-is to keep the hotfix minimal.

Verification

Run inside the local Docker stack:

vendor/bin/phpunit tests/Unit/Services/PresentationMaterialEventDispatchTest.php
OK (4 tests, 11 assertions)

Red/green checked: with the new test and the original production file the run reports 2 errors (getSummitId() on null in the delete test, getId() on null in the new test); with the fix both pass.

Removing a media upload nulls the owning presentation before Doctrine's
PreRemove fires, so getSummitId() dereferences null and PHP throws
\Error. The catch only covered \Exception, so the error escaped the
lifecycle listener and aborted the flush, which is what breaks the
Services CI job on main since #579. Catch \Throwable and fall back to 0,
the degraded case PresentationMaterialEventDispatchTest already
documents and asserts.
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 8f3bdc13-abac-4d31-9368-42d44b9d9944

📥 Commits

Reviewing files that changed from the base of the PR and between dd92877 and 6962b0b.

📒 Files selected for processing (2)
  • app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationMaterial.php
  • tests/Unit/Services/PresentationMaterialEventDispatchTest.php

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-603/

This page is automatically updated on each push to this PR.

…ntationId too

Same shape as getSummitId(): a material whose presentation is not set
dereferences null and throws \Error, which the \Exception catch did not
cover. Add a test asserting both accessors return 0 in that state.
@smarcet
smarcet merged commit cd4fee7 into main Sep 16, 2026
34 checks passed
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-603/

This page is automatically updated on each push to this PR.

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.

1 participant