Skip to content

Commit 8be7dd5

Browse files
author
Gaetano Giunta
committed
Fix EZP-26907: avoid 'mysql has gone away' errors
1 parent 20f281e commit 8be7dd5

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

bin/php/updatesearchindexsolr.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,22 @@ protected function forkAndExecute( $nodeID, $offset, $limit )
363363
// Prepare DB-based cluster handler for fork (it will re-connect DB automatically).
364364
eZClusterFileHandler::preFork();
365365

366+
$conn = false;
367+
$ezpKernelContainer = ezpKernel::instance()->getServiceContainer();
368+
if ( $ezpKernelContainer ) // in case we are in pure-legacy mode
369+
{
370+
$conn = $ezpKernelContainer->get('doctrine')->getConnection();
371+
$conn->close();
372+
}
373+
366374
$pid = pcntl_fork();
367375

368376
// reinitialize DB after fork
369377
$this->initializeDB();
378+
if ( $conn )
379+
{
380+
$conn->connect();
381+
}
370382

371383
if ( $pid == -1 )
372384
{

0 commit comments

Comments
 (0)