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

Add a feature switch to trigger SchemaValidator in Collector #1120

Merged

Conversation

bastnic
Copy link
Contributor

@bastnic bastnic commented Jan 6, 2020

Fixes #1115

Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

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

I think the template should hide the section entirely instead of saying there is no error, if the mapping was not validated.

@@ -26,9 +26,16 @@ class DoctrineDataCollector extends BaseCollector
/** @var string[] */
private $groupedQueries;

public function __construct(ManagerRegistry $registry)
/** @var bool */
private $shouldValidateSchemaClass;
Copy link
Member

Choose a reason for hiding this comment

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

I would name it shouldValidateSchema. I don't see why there is Class in the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

private $shouldValidateSchemaClass;

/**
* @param bool $shouldValidateSchemaClass
Copy link
Member

Choose a reason for hiding this comment

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

please use a typehint instead, as the master branch requires PHP 7.1+

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done (I had 1.12.x in ming but @ostrolucky confirmed it's master)

@ostrolucky ostrolucky added this to the 2.1.0 milestone Jan 6, 2020
@bastnic bastnic force-pushed the feature/feature-switch-SchemaValidator branch 3 times, most recently from df47248 to c408889 Compare January 6, 2020 13:59
@bastnic
Copy link
Contributor Author

bastnic commented Jan 6, 2020

@stof all done.

Tests added.

@bastnic bastnic requested a review from stof January 6, 2020 14:00
@bastnic
Copy link
Contributor Author

bastnic commented Jan 6, 2020

As it's targeted a big release, should we put it to false by default?

@bastnic bastnic force-pushed the feature/feature-switch-SchemaValidator branch 2 times, most recently from 69d6000 to 44a3011 Compare January 6, 2020 14:11
Copy link
Member

@ostrolucky ostrolucky left a comment

Choose a reason for hiding this comment

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

XSD needs to be updated as well. Since you missed that, let's add test for that (check AbstractDoctrineExtensionTest)

@greg0ire
Copy link
Member

greg0ire commented Jan 6, 2020

Please add a summary of #1115 to the body of your commit message (but keep the Fixes #1115 though)

@bastnic bastnic force-pushed the feature/feature-switch-SchemaValidator branch from 44a3011 to 9b22320 Compare January 6, 2020 20:30
@bastnic
Copy link
Contributor Author

bastnic commented Jan 6, 2020

@ostrolucky @greg0ire all done.

@bastnic bastnic force-pushed the feature/feature-switch-SchemaValidator branch 2 times, most recently from e1ae6ae to ab82ecc Compare January 6, 2020 21:04
Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

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


$collector->collect(new Request(), new Response());

$this->assertEmpty($collector->getEntities());
Copy link
Member

Choose a reason for hiding this comment

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

Asserting this doesn't make sense to me, any particular reason to do it? Using getMappingErrors would at least make some sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if entities is empty, it's because we never enter in the if condition, otherwise it would be ['default' => []]. It's also the condition asked by @stof, to not display anything in the template.

You are right, I will add a test on getMappingErrors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Tests/DataCollector/DoctrineDataCollectorTest.php Outdated Show resolved Hide resolved
Calling SchemaValidator from DoctrineDataCollector can
results in loading a lot of metadatas for relations of
retated entities. On some profile, it can be up to 18%
of the total (already heavy) pages.

As there is already a command to get the schema
validation, we can put this validation behind a feature
switch `profiling_collect_schema_errors`.

Command is: `bin console doctrine:schema:validate`

Fixes doctrine#1115
@bastnic bastnic force-pushed the feature/feature-switch-SchemaValidator branch from ab82ecc to 1ccb822 Compare January 7, 2020 09:09
@ostrolucky ostrolucky merged commit 4e60cd9 into doctrine:master Jan 7, 2020
@bastnic bastnic deleted the feature/feature-switch-SchemaValidator branch January 7, 2020 09:13
@alcaeus alcaeus added this to 2.1 in Roadmap Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

[performance] DoctrineDataCollector SchemaValidator could be optional
4 participants