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

EZP-31127: Skipped non-existing Content Types in ContentTypeIdentifier criterion #2872

Merged
merged 5 commits into from
Jan 31, 2020

Conversation

emodric
Copy link
Contributor

@emodric emodric commented Nov 14, 2019

Question Answer
JIRA issue EZP-31127
Bug/Improvement yes
New feature no
Target version 7.5
BC breaks no
Tests pass yes
Doc needed no

Makes it possible to use non existent content type identifiers in the criterion (e.g. when coming from an outside DB field, where the content type might be deleted in the meantime).

Otherwise, you'd have to use ContentTypeId and load the IDs yourself.

TODO:

  • Implement feature / fix a bug.
  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.

@andrerom andrerom changed the title Do not use non-existing content types in ContentTypeIdentifier criterion EZP-31127: Do not use non-existing content types in ContentTypeIdentifier criterion Nov 25, 2019
@emodric
Copy link
Contributor Author

emodric commented Dec 13, 2019

Hi. Will this be going in any time soon?

It would be nice if it could make it into the next patch release.

@emodric
Copy link
Contributor Author

emodric commented Jan 8, 2020

@andrerom @adamwojs Updated the implementation to return a none-matching expression if there are no valid IDs.

@andrerom
Copy link
Contributor

andrerom commented Jan 8, 2020

+1, but should ideally have some small integration test coverage for this in terms of legacy SQL vs Solr vs ...

@emodric
Copy link
Contributor Author

emodric commented Jan 14, 2020

Any tips on getting started with the test? As far as I can see, this does not have any tests at all.

@andrerom
Copy link
Contributor

@emodric

6 => [
[
'filter' => new Criterion\ContentTypeIdentifier(
'user'
),
'sortClauses' => [new SortClause\ContentId()],
],
$fixtureDir . 'ContentTypeId.php',
],

Maybe duplicate this one with a invalid type? And duplicate the MatchNone case below with two invalid types.

@emodric
Copy link
Contributor Author

emodric commented Jan 15, 2020

Not sure what you mean about duplicating MatchNone. It does not have any arguments, no?

@emodric
Copy link
Contributor Author

emodric commented Jan 15, 2020

BTW, Solr variant of this PR: ezsystems/ezplatform-solr-search-engine#161

@andrerom
Copy link
Contributor

andrerom commented Jan 15, 2020

Not sure what you mean about duplicating MatchNone. It does not have any arguments, no?

Assuming MatchNone fixture is for empty response here, but something like:

                [
                    'filter' => new Criterion\ContentTypeIdentifier(
                        'invalid1',
                        'invalid2'
                    ),
                    'sortClauses' => [new SortClause\ContentId()],
                ],
                $fixtureDir . 'MatchNone.php',
            ],

@emodric
Copy link
Contributor Author

emodric commented Jan 15, 2020

Ah, okay, I understand now. Updated the test case.

@emodric
Copy link
Contributor Author

emodric commented Jan 15, 2020

Failures are probably related to not having the changes from ezsystems/ezplatform-solr-search-engine#161.

@alongosz alongosz changed the title EZP-31127: Do not use non-existing content types in ContentTypeIdentifier criterion EZP-31127: Skipped non-existing Content Types in ContentTypeIdentifier criterion Jan 16, 2020
try {
$idList[] = $this->contentTypeHandler->loadByIdentifier($identifier)->id;
} catch (NotFoundException $e) {
// Skip non-existing content types
Copy link
Member

Choose a reason for hiding this comment

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

Question: wouldn't we actually want to log (warning) usage of non-existing Content Type identifiers? So the Maintainers can trace any outdated apps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andrerom mentioned it earlier. Yes, but as a separate improvement, that adds logging consistently to every handler that has the same issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

For the case where only some are invalid I agree we should add warning directly here, as it's a bit unique case compared to other criteria.

Maybe something like:

Suggested change
// Skip non-existing content types
// Skip non-existing content types, but track for code below
$invalidIdentifiers[] = $identifier;

Then further down:

        if (count($idList) === 0) {
            return $query->expr->not($query->bindValue('1'));
        } else (!empty($invalidIdentifiers)) {
            // log warning or error 
        }

Copy link
Contributor Author

@emodric emodric Jan 16, 2020

Choose a reason for hiding this comment

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

Updated in 0ef9b7f

@emodric
Copy link
Contributor Author

emodric commented Jan 22, 2020

Going in? :)

@micszo
Copy link
Member

micszo commented Jan 22, 2020

In queue for QA. Maybe I'll be able to start today. Aiming to get it in this week.

@emodric
Copy link
Contributor Author

emodric commented Jan 22, 2020

@micszo Thanks for the update! 👍

@micszo micszo self-assigned this Jan 22, 2020
@micszo
Copy link
Member

micszo commented Jan 23, 2020

@emodric could you please try rebasing both PRs? some tests failed due to missing TranslatedName which was introduced in a fix several days ago.

@emodric
Copy link
Contributor Author

emodric commented Jan 23, 2020

@micszo Done!

Copy link
Member

@micszo micszo left a comment

Choose a reason for hiding this comment

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

QA Approved on eZ Platform EE 2.5 with branches with Legacy SE & Solr.
In case of LSE warning is printed twice but we confirmed it's not related to these changes.
Thanks for support to @alongosz!

@micszo micszo removed their assignment Jan 31, 2020
@lserwatka lserwatka merged commit d9f9a21 into ezsystems:7.5 Jan 31, 2020
@lserwatka
Copy link
Member

@alongosz could you merge it up?

@alongosz
Copy link
Member

Merged up to master along with today's other changes as 717d488.

Thank you @emodric 🎉

@emodric
Copy link
Contributor Author

emodric commented Jan 31, 2020

Thanks all for review!

emodric added a commit to netgen-layouts/layouts-ezplatform that referenced this pull request Mar 4, 2020
… converting content type identifiers to IDs

Related issue fixed in eZ Publish kernel 7.5.7

ezsystems/ezpublish-kernel#2872
emodric added a commit to netgen-layouts/layouts-ezplatform-relation-list-query that referenced this pull request Mar 4, 2020
emodric added a commit to netgen-layouts/layouts-ezplatform-tags-query that referenced this pull request Mar 4, 2020
emodric added a commit to netgen-layouts/content-browser-ezplatform that referenced this pull request Mar 4, 2020
emodric added a commit to netgen-layouts/layouts-ezplatform-relation-list-query that referenced this pull request Apr 14, 2020
emodric added a commit to netgen-layouts/layouts-ezplatform-relation-list-query that referenced this pull request Apr 14, 2020
emodric added a commit to netgen-layouts/layouts-ezplatform-relation-list-query that referenced this pull request Apr 14, 2020
emodric added a commit to netgen-layouts/layouts-ezplatform-relation-list-query that referenced this pull request Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

6 participants