-
Notifications
You must be signed in to change notification settings - Fork 223
Closed
Description
Q | A |
---|---|
Bug report? | maybe |
Feature request? | no |
BC Break report? | no |
Version/Branch | 0.14 |
I've noticed some strange codes, when it comes to cacheDir
/baseCacheDir
in the TypeGenerator
.
Check out the method getCacheDir
:
public function getCacheDir(bool $useDefault = true): ?string
{
if ($useDefault) {
return $this->cacheDir ?: $this->baseCacheDir.'/overblog/graphql-bundle/__definitions__';
} else {
return $this->cacheDir;
}
}
The $useDefault
parameter doesn't affect anything:
- If it's
true
, then the method returns$this->cacheDir
- If it's
false
, then it also returns$this->cacheDir
So the method can be simplified to this:
public function getCacheDir(): ?string
{
return $this->cacheDir ?? $this->baseCacheDir.'/overblog/graphql-bundle/__definitions__';
}
But then I checked where this method is used. It is called only in one place: Overblog\GraphQLBundle\CacheWarmer\CompileCacheWarmer::warmUp
public function warmUp($cacheDir)
{
if ($this->compiled) {
// use warm up cache dir if type generator cache dir not already explicitly declare
$baseCacheDir = $this->typeGenerator->getBaseCacheDir();
if (null === $this->typeGenerator->getCacheDir(false)) {
$this->typeGenerator->setBaseCacheDir($cacheDir);
}
$this->typeGenerator->compile(TypeGenerator::MODE_WRITE | TypeGenerator::MODE_OVERRIDE);
if (null !== $baseCacheDir) {
$this->typeGenerator->setBaseCacheDir($baseCacheDir);
}
}
return [];
}
@mcg-web please review these methods and check if the cacheDir
and baseCacheDir
are used correctly.
Metadata
Metadata
Assignees
Labels
No labels