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
Add a feature switch to trigger SchemaValidator in Collector #1120
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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+
There was a problem hiding this comment.
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)
df47248
to
c408889
Compare
@stof all done. Tests added. |
As it's targeted a big release, should we put it to false by default? |
69d6000
to
44a3011
Compare
There was a problem hiding this 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)
Please add a summary of #1115 to the body of your commit message (but keep the |
44a3011
to
9b22320
Compare
@ostrolucky @greg0ire all done. |
e1ae6ae
to
ab82ecc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best reviewed with whitespace ignored https://github.com/doctrine/DoctrineBundle/pull/1120/files?utf8=%E2%9C%93&diff=unified&w=1
|
||
$collector->collect(new Request(), new Response()); | ||
|
||
$this->assertEmpty($collector->getEntities()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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
ab82ecc
to
1ccb822
Compare
Fixes #1115