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-5905: Implemented LoadContent events #250

Open
wants to merge 8 commits into
base: 4.6
Choose a base branch
from

Conversation

mateuszdebinski
Copy link
Contributor

@mateuszdebinski mateuszdebinski commented Jul 26, 2023

Question Answer
JIRA issue IBX-5905
Type bug
Target Ibexa version v4.5
BC breaks no

PR is currently introducing one of the 3 things needed to solve the problem described in JIRA. Thanks to the content type identifier in ContentInfo, we will be able to decide whether the content type belongs to a taxonomy. If so, it will allow us to verify whether the user has the appropriate permissions. The permissions will be checked by introducing a new Event triggered after the content is loaded.
Work on the fix includes:

  1. Adding content type identifier to ContentInfo
  2. Creating an event that will be triggered after loading the content
  3. Adding verification whether the content belongs to taxonomy and if so, verification of permissions to them

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).

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.

Looks almost ok, but I have some naming & query building remarks.

Also ideally if we keep only necessary legacy persistence fixtures changes.

We need to either add new integration test or modify existing one which checks properties after creating and/or loading content type to see that it's set.

src/contracts/Persistence/Content/ContentInfo.php Outdated Show resolved Hide resolved
src/lib/Persistence/Legacy/Content/Mapper.php Outdated Show resolved Hide resolved
src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php Outdated Show resolved Hide resolved
src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php Outdated Show resolved Hide resolved
src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php Outdated Show resolved Hide resolved
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.

Looks ok. Let's make CI green.
Small remarks:

@mateuszdebinski mateuszdebinski force-pushed the IBX-5905_content_type_identifier_in_contentInfo branch 5 times, most recently from e1884e3 to b8ab8df Compare July 28, 2023 13:14
@alongosz alongosz requested a review from a team July 28, 2023 14:26
@lserwatka
Copy link
Contributor

Just an thought, would be good to test it on large database to see how this change is performing. @mateuszdebinski I think you have access to large datasets.

@mateuszdebinski
Copy link
Contributor Author

@lserwatka from what I've verified, there shouldn't be any problems with performance. I checked all SQL queries to which I added a new column and didn't see any changes in performance. I tested on a database that has a size of 43GB before uploading it to the database

@sonarcloud
Copy link

sonarcloud bot commented Aug 7, 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

@adamwojs
Copy link
Member

@mateuszdebinski Could you please add description to PR explaining how this change is related to linked issue?

@adamwojs
Copy link
Member

adamwojs commented Oct 5, 2023

@mateuszdebinski Rebase is needed here

@mateuszdebinski mateuszdebinski force-pushed the IBX-5905_content_type_identifier_in_contentInfo branch from 98d2ff3 to be0793c Compare October 9, 2023 09:32
@sonarcloud
Copy link

sonarcloud bot commented Oct 9, 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

@mateuszdebinski what is the status here? I see CI is failing and it was never sent to QA. At this point it would need to be rebased to 4.6, if still valid.

@mateuszdebinski
Copy link
Contributor Author

@alongosz There's one more thing missing, I'll take care of it this week and do a rebase to 4.6

@alongosz
Copy link
Member

alongosz commented Jul 9, 2024

Hi @mateuszdebinski, any updates on this one?

@mateuszdebinski mateuszdebinski force-pushed the IBX-5905_content_type_identifier_in_contentInfo branch from be0793c to a9c82ec Compare July 9, 2024 11:59
@mateuszdebinski mateuszdebinski changed the base branch from 4.5 to 4.6 July 9, 2024 11:59
@mateuszdebinski
Copy link
Contributor Author

@alongosz I've added the final things to this PR. Please verify the changes

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.

Seems that you're trying to solve too much at once. The scope here was to add identifier to ContentInfo. Where that new event is used?

phpstan-baseline.neon Outdated Show resolved Hide resolved
@@ -15,11 +15,14 @@

abstract class AbstractServiceTest extends TestCase
{
public function getEventDispatcher(string $beforeEventName, string $eventName): TraceableEventDispatcher
public function getEventDispatcher(string $beforeEventName, ?string $eventName): TraceableEventDispatcher
Copy link
Member

Choose a reason for hiding this comment

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

I have a feeling this is here on purpose so you won't forget to implement a pair of events - before event and event.
Any POV @Nattfarinn or @ibexa/php-dev?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't add the after event for the loadContent function here, but I will add it if necessary :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say event layer is complete only if it dispatches Before and After events. Before for pipeline interception and input refinement, After as a reaction and postprocessing.

I would add After event. Thanks @alongosz for catching this 👍 .

tests/lib/Event/ContentServiceTest.php Outdated Show resolved Hide resolved
tests/lib/Event/ContentServiceTest.php Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Jul 26, 2024

@mateuszdebinski
Copy link
Contributor Author

@alongosz This PR is part of the solution to the problem and for this, we will need this Event to verify in taxonomy whether the content type points to taxonomy to verify the appropriate permissions. PR for taxonomy will be added soon. First, I wanted to have a completed PR for core (without merge but confirmed that everything is ok)

@alongosz alongosz changed the title IBX-5905: Added content type identifier to ContentInfo IBX-5905: Implemented LoadContent events Aug 6, 2024
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.

This PR is part of the solution to the problem and for this, we will need this Event to verify in taxonomy whether the content type points to taxonomy to verify the appropriate permissions. PR for taxonomy will be added soon. First, I wanted to have a completed PR for core (without merge but confirmed that everything is ok)

@mateuszdebinski in that case the essence of the PR changed. I've changed the title accordingly. If you feel that both of these things (events + content type identifier) are separate, then I'd just extract one of those to separate PR and target one PR on top of another. However ATM for me it's not a requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants