Skip to content

Commit

Permalink
Fix opcache issue where the lang files were cached, resulting in unsa…
Browse files Browse the repository at this point in the history
…ved changes.
  • Loading branch information
sten committed Jul 12, 2021
1 parent 0c14416 commit f57c575
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ChainedTranslationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\App;
use RecursiveArrayIterator;
use RecursiveIteratorIterator;
use Symfony\Component\Finder\SplFileInfo;
use Brick\VarExporter\VarExporter;


class ChainedTranslationManager
{
/**
Expand Down Expand Up @@ -188,7 +190,11 @@ private function saveGroupTranslations(string $locale, string $group, Collection
ksort($translations);

$groupPath = $this->getGroupPath($locale, $group, $languagePath);

// clear the opcache of the group file, because otherwise in the next request, an old cached file can be read in
// and the saved translation can be overwritten...
if(function_exists('opcache_invalidate')) {
opcache_invalidate($groupPath, true);
}
$this->files->put($groupPath, "<?php\n\nreturn " . VarExporter::export($translations) . ';' . \PHP_EOL);
}

Expand Down

0 comments on commit f57c575

Please sign in to comment.