Issue 1:
Hello,

When i run the code below, on the second search, the results are duplicated.

$finder = new Finder();
$first_results = $finder->in('/my/path')->files()->name('/my_pattern/');

// [...] some code

$second_results = $finder->in('/my/path')->files()->name('/another_pattern/');

But if i run that code, it works as intended :

$finder = new Finder();
$first_results = $finder->in('/my/path')->files()->name('/my_pattern/');

// [...] some code

$finder = new Finder();
$second_results = $finder->in('/my/path')->files()->name('/another_pattern/');

Issue 2:
Q
A

Bug report?
yes

Feature request?
no

BC Break report?
yes

RFC?
no

Symfony version
>=3.4.0

I noticed that, when using the dependency injection component without the fullstack framework that the ContainerBuilder cannot be used a container anymore (it was working from Symfony 2.0 to 3.3).

The context is the following: when using it with Drupal, it might happen that Drupal modules are being enabled, when they do, they are enabled one by one, implying a container rebuild each time.

Problem is that before 3.4, container was loaded using require_once and class name was always the same which lead the container NOT being reloaded even if changed due to require_once usage, and it was also impossible to manually include the file which would have lead to a duplicated class name hence a fatal error.

As a simple bypass, I was using this code as a replacement of Kernel::initializeContainer():

protected function initializeContainer()
{
$class = $this->getContainerClass();
$cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug);
$fresh = true;
if (!$cache->isFresh()) {
$container = $this->buildContainer();
$container->compile();
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());

$fresh = false;

$this->container = $container;
} else {
require_once $cache->getPath();

$this->container = new $class();
$this->container->set('kernel', $this);
}

if (!$fresh && $this->container->has('cache_warmer')) {
$this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'));
}
}

The only notable change in this code is that I don't require_once the container when it is being rebuilt, but use directly the ContainerBuilder instance instead, which was until now gracefully working.

Now, if we try that since 3.4, it will fail with a fatal error due to the lack of the container.build_id parameter, and there's a few usages of it with the framework bundle enabled (it is being used as default values for cache adapters version parameter for example).

I did bypass this problem with a simple version compare and a fallback on the original Symfony kernel own initializeContainer() method now that the container class name do change thanks to its hashed name, but it is a breaking change:

protected function initializeContainer()
{
// From Symfony 3.4 only a require and not require_once is being used,
// we can safely rely upon the parent implementation.
if (0 <= version_compare(BaseKernel::VERSION, '3.4.0')) {
return parent::initializeContainer();
}

// ...

Please note that it is very simple to bypass, and it is a very minor breakage since I guess that the ContainerBuilder was not meant to be used a container itself, nevertheless I suspect that other applications that might use the dependency injection manually could one day end up with the same problem - certainly under very, very peculiar conditions (such as the one I experienced).