Skip to content

WriteProxiesToFile bug #866

@radar3301

Description

@radar3301

Version 7 introduced a bug with ContainerBuilder::writeProxiesToFile().

Previous versions of ProxyFactory had a bool $writeProxiesToFile property.
Since 7.0, these checks were updated from if ($this->writeProxiesToFile) ... to if ($this->proxyDirectory) ....
No issues here.

Prior to 7.0, ProxyFactory was created in ContainerBuilder by new ProxyFactory($this->writeProxiesToFile, $this->proxyDirectory).
Since 7.0, ProxyFactory is created in ContainerBuilder by new ProxyFactory($this->proxyDirectory).
No issues here.

Until you get to ContainerBuilder::writeProxiesToFile(bool $writeToFile, string $proxyDirectory = null):
The writeProxiesToFile parameter essentially has no effect if proxyDirectory has anything other than null.

In other words, writeProxiesToFile(false, 'tmp/proxies') has exactly the same effect as writeProxiesToFile(true, 'tmp/proxies') or even

$builder->writeProxiesToFile(true, 'tmp/proxies');
/* other code */
if ($dontWriteProxiesAnymore) {
    $builder->writeProxiesToFile(false);
}

or

$builder->writeProxiesToFile($resultOfSomeLogic, $someProxyDirectory);

Therefore, to fix this bug, I believe this line should be updated to

$this->proxyDirectory = $writeToFile ? $proxyDirectory : null;

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions