<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>3.2?</td>
</tr>
</tbody>
</table>
<p dir="auto">Steps to repeat:</p>
<ol dir="auto">
<li>
<p dir="auto"><code class="notranslate">git clone git@github.com:weaverryan/flex-redis-bug.git</code></p>
</li>
<li>
<p dir="auto"><code class="notranslate">composer install</code></p>
</li>
</ol>
<p dir="auto">It will explode with:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/121003/32515567-922c23d4-c3ce-11e7-865c-b8920921b2bc.png"><img width="1272" alt="screen shot 2017-11-07 at 3 15 49 pm" src="https://user-images.githubusercontent.com/121003/32515567-922c23d4-c3ce-11e7-865c-b8920921b2bc.png" style="max-width: 100%;"></a></p>
<p dir="auto">The project is a standard Flex app, but with the following changes:</p>
<p dir="auto">A) Doctrine ORM is installed</p>
<p dir="auto">B) The <code class="notranslate">app</code> cache uses redis (see <code class="notranslate">framework.yaml</code>)</p>
<p dir="auto">C) We're in the <code class="notranslate">prod</code> environment</p>
<p dir="auto">The error happens on <code class="notranslate">cache:clear</code>. This comes from the result cache configured by default in <code class="notranslate">prod</code> for Doctrine: <a href="https://github.com/symfony/recipes/blob/93d80647f510e00a52db869251136593a2dc2182/doctrine/doctrine-bundle/1.6/config/packages/prod/doctrine.yaml#L28">https://github.com/symfony/recipes/blob/93d80647f510e00a52db869251136593a2dc2182/doctrine/doctrine-bundle/1.6/config/packages/prod/doctrine.yaml#L28</a></p>
<p dir="auto">This is caused by a lack of laziness... <em>somewhere</em>. It could be in Doctrine - this whole thing starts when we try to warmup the proxies... which instantiates the entity managers (which instantiates result caches and also connection objects). Or, it could be in the Cache component, where (at least with Redis) a connection to the Redis server is established in order to create the <code class="notranslate">RedisAdapter</code> object (even if you never make any connections to it).</p>
<p dir="auto">Thanks!</p>
<p dir="auto">There is a bug at the moment, where: you cannot spool an email and authenticate the user in the same response.</p>
<p dir="auto">The authentication works, but the session disappears for One request, before appearing again. This only happens when the email is actually sent.</p>
<p dir="auto">This causes the user to appear 'Anonymous' for the next response, which is causing problems, as the application could be expecting the user to be logged in.</p>
<p dir="auto">This currently prevents spooling emails on any events where the user may also get logged in,</p>
<ul dir="auto">
<li>password change success</li>
<li>email confirmation</li>
<li>account created</li>
<li>etc</li>
</ul>
<p dir="auto">I have created a test bundle using symfony standard and the demo login setup.</p>
<p dir="auto"><a href="https://github.com/carlcraig/symfony-standard/tree/spool-auth">https://github.com/carlcraig/symfony-standard/tree/spool-auth</a></p>
<p dir="auto">I have also tested this with FOSUserBundle</p>
<p dir="auto"><a href="https://github.com/carlcraig/symfony-standard/tree/fos-userbundle-spool-auth">https://github.com/carlcraig/symfony-standard/tree/fos-userbundle-spool-auth</a></p>
<p dir="auto">Has anyone else encountered this problem?</p>
<p dir="auto">Is there any way to get round this?</p>