<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>yes</td>
</tr>
<tr>
<td>RFC?</td>
<td>yes/no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>2.8</td>
</tr>
</tbody>
</table>
<p dir="auto">There was recently a change to the UniqueEntity Validator: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/symfony/doctrine-bridge/commit/40941a3/hovercard" href="https://github.com/symfony/doctrine-bridge/commit/40941a3">symfony/doctrine-bridge@<tt>40941a3</tt></a></p>
<p dir="auto">This has changed it's behaviour. It used to "return" if any value was null. Now, it continues if a value is null.</p>
<p dir="auto">This means that if you have 1 null value and 1 non null value, it only matches the criteria to the single value.</p>
<p dir="auto">I think this is quite a big BC break. Would love to get some feedback on this change.</p>
<p dir="auto">We now have validation that is failing when we use 2 fields (one has a value and the other is null). We need it to only validate if both are not null.</p>
<table role="table">
<thead>
<tr>
<th>Q</th>
<th>A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bug report?</td>
<td>yes</td>
</tr>
<tr>
<td>Feature request?</td>
<td>no</td>
</tr>
<tr>
<td>BC Break report?</td>
<td>no</td>
</tr>
<tr>
<td>RFC?</td>
<td>no</td>
</tr>
<tr>
<td>Symfony version</td>
<td>2.8.17</td>
</tr>
</tbody>
</table>
<p dir="auto">Scenario: I'm validating an entity like this</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$validator-&gt;validate($device, [
    new UniqueEntity([
        'fields' =&gt; ['accountId', 'tenantUuid'],
        'em' =&gt; $provisioningEm
    ])
]);"><pre class="notranslate"><span class="pl-s1"><span class="pl-c1">$</span>validator</span>-&gt;<span class="pl-en">validate</span>(<span class="pl-s1"><span class="pl-c1">$</span>device</span>, [
    <span class="pl-k">new</span> <span class="pl-v">UniqueEntity</span>([
        <span class="pl-s">'fields'</span> =&gt; [<span class="pl-s">'accountId'</span>, <span class="pl-s">'tenantUuid'</span>],
        <span class="pl-s">'em'</span> =&gt; <span class="pl-s1"><span class="pl-c1">$</span>provisioningEm</span>
    ])
]);</pre></div>
<p dir="auto">If <code class="notranslate">accountId</code> happens to be null, <a href="https://github.com/symfony/symfony/blob/2.8/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php#L90-L94">UniqueEntityValidator</a> will now exclude it from the constraint list (since commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/symfony/symfony/commit/1e3421d6f03325ef805f5d11c714982b70d6c06f/hovercard" href="https://github.com/symfony/symfony/commit/1e3421d6f03325ef805f5d11c714982b70d6c06f"><tt>1e3421d</tt></a> ), failing <a href="https://github.com/symfony/symfony/blob/2.8/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php#L136-L137">later on</a> because <code class="notranslate">$criteria[$fields[0]]</code> is an invalid array access: <code class="notranslate">fields[0]</code> is the string "accountId", which is not in <code class="notranslate">$criteria</code>.<br>
Reverting lines 88-94 to the version before the commit linked above fixes the issue.</p>