Skip to content

Commit d3e0176

Browse files
committed
Perform the waiting for lock file earlier in the process, this prevents the kernel from being created AT ALL while the cache is being cleared
1 parent d3feb3b commit d3e0176

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

admin-api/index.php

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* @copyright Since 2007 PrestaShop SA and Contributors
2424
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
2525
*/
26+
27+
use PrestaShop\PrestaShop\Core\Util\CacheClearLocker;
2628
use Symfony\Component\Dotenv\Dotenv;
2729
use Symfony\Component\ErrorHandler\Debug;
2830
use Symfony\Component\HttpFoundation\Request;
@@ -60,6 +62,10 @@
6062
->loadEnv($dotEnvFile)
6163
;
6264

65+
// Block the process until the cache clear is in progress, this must be done before the kernel is created so it doesn't
66+
// try to use the old container
67+
CacheClearLocker::waitUntilUnlocked(_PS_ENV_, _PS_APP_ID_);
68+
6369
$kernel = new AdminAPIKernel(_PS_ENV_, _PS_MODE_DEV_);
6470
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
6571
//Request::enableHttpMethodParameterOverride();

admin-dev/index.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
* @copyright Since 2007 PrestaShop SA and Contributors
2424
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
2525
*/
26+
27+
use PrestaShop\PrestaShop\Core\Util\CacheClearLocker;
2628
use Symfony\Component\Dotenv\Dotenv;
2729
use Symfony\Component\ErrorHandler\Debug;
2830
use Symfony\Component\HttpFoundation\Request;
29-
use Symfony\Component\HttpFoundation\RequestStack;
30-
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
3131
use Symfony\Component\HttpKernel\HttpKernelInterface;
3232

3333
if (!defined('_PS_ADMIN_DIR_')) {
@@ -70,6 +70,10 @@
7070
->loadEnv($dotEnvFile)
7171
;
7272

73+
// Block the process until the cache clear is in progress, this must be done before the kernel is created so it doesn't
74+
// try to use the old container
75+
CacheClearLocker::waitUntilUnlocked(_PS_ENV_, _PS_APP_ID_);
76+
7377
$kernel = new AdminKernel(_PS_ENV_, _PS_MODE_DEV_);
7478
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
7579
Request::enableHttpMethodParameterOverride();

app/AppKernel.php

-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use PrestaShop\PrestaShop\Adapter\Module\Repository\ModuleRepository;
2828
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
2929
use PrestaShop\PrestaShop\Core\Exception\CoreException;
30-
use PrestaShop\PrestaShop\Core\Util\CacheClearLocker;
3130
use PrestaShop\PrestaShop\Core\Version;
3231
use PrestaShop\TranslationToolsBundle\TranslationToolsBundle;
3332
use Symfony\Component\Config\Loader\LoaderInterface;
@@ -94,7 +93,6 @@ public function registerBundles(): iterable
9493
*/
9594
public function boot()
9695
{
97-
CacheClearLocker::waitUntilUnlocked($this->environment, $this->getAppId());
9896
parent::boot();
9997
$this->cleanKernelReferences();
10098
}

index.php

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
2525
*/
2626

27+
use PrestaShop\PrestaShop\Core\Util\CacheClearLocker;
2728
use Symfony\Component\Dotenv\Dotenv;
2829
use Symfony\Component\ErrorHandler\Debug;
2930
use Symfony\Component\HttpFoundation\Request;
@@ -50,6 +51,10 @@
5051
Debug::enable();
5152
}
5253

54+
// Block the process until the cache clear is in progress, this must be done before the kernel is created so it doesn't
55+
// try to use the old container
56+
CacheClearLocker::waitUntilUnlocked(_PS_ENV_, _PS_APP_ID_);
57+
5358
// Starting Kernel
5459
$kernel = new FrontKernel(_PS_ENV_, _PS_MODE_DEV_);
5560
$request = Request::createFromGlobals();

0 commit comments

Comments
 (0)