Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-7055: Allowed to return null when content is not deleted #297

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

mikadamczyk
Copy link
Contributor

Question Answer
JIRA issue IBX-7055
Type feature
Target Ibexa version v4.6
BC breaks no

When content is not deleted (e.g. on before event propagation is stopped) the null value must be set as a result.

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (main for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ibexa/engineering).

@mikadamczyk mikadamczyk self-assigned this Nov 24, 2023
@mikadamczyk mikadamczyk marked this pull request as ready for review November 27, 2023 08:59
@mikadamczyk mikadamczyk requested review from alongosz and a team November 27, 2023 08:59
@konradoboza konradoboza requested a review from a team November 27, 2023 09:02
Copy link
Contributor

@Steveb-p Steveb-p left a comment

Choose a reason for hiding this comment

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

Is this needed for some functionality?

In theory here, if there is a chance that result is not set, then BeforeTrashEvent::hasTrashItem() method should be called first. Because of how BeforeTrashEvent::getResult() works internally, null will never be returned - an exception will be thrown.

What you want to do instead is probably add phpstan-assert-if-true annotation to BeforeTrashEvent::isResultSet() method, instructing PHPStan that when this method returns true, $this->result will not be null.

See https://phpstan.org/writing-php-code/narrowing-types#custom-type-checking-functions-and-methods for more details.

Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

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

At least unit test layer for events should include coverage for this change.

tests/lib/Event/TrashServiceTest.php Outdated Show resolved Hide resolved
tests/lib/Event/TrashServiceTest.php Outdated Show resolved Hide resolved
@alongosz
Copy link
Member

alongosz commented Dec 6, 2023

Running regressions via ibexa/commerce#508

@alongosz alongosz force-pushed the IBX-7055-allow-return-null branch from 3710f3c to 4e73c46 Compare December 6, 2023 11:33
Copy link

sonarqubecloud bot commented Dec 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@alongosz
Copy link
Member

alongosz commented Dec 6, 2023

Solr failure is unrelated, regressions all green. The change is too trivial for QA, merging :)

@alongosz alongosz merged commit e22d595 into main Dec 6, 2023
19 of 22 checks passed
@alongosz alongosz deleted the IBX-7055-allow-return-null branch December 6, 2023 12:27
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.

5 participants