mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Reduce connection overhead
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Alchemy\Phrasea;
|
||||
use Alchemy\Phrasea\Command\CommandInterface;
|
||||
use Alchemy\Phrasea\Core\CLIProvider\TranslationExtractorServiceProvider;
|
||||
use Alchemy\Phrasea\Core\CLIProvider\WebsocketServerServiceProvider;
|
||||
use Alchemy\Phrasea\Core\PhraseaCLIExceptionHandler;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Symfony\Component\Console;
|
||||
use Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider;
|
||||
@@ -23,6 +24,7 @@ use Alchemy\Phrasea\Core\CLIProvider\LessBuilderServiceProvider;
|
||||
use Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider;
|
||||
use Alchemy\Phrasea\Core\CLIProvider\SignalHandlerServiceProvider;
|
||||
use Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
|
||||
/**
|
||||
* Phraseanet Command Line Application
|
||||
@@ -66,6 +68,10 @@ class CLI extends Application
|
||||
$this->register(new DoctrineMigrationServiceProvider());
|
||||
|
||||
$this->bindRoutes();
|
||||
|
||||
error_reporting(-1);
|
||||
ErrorHandler::register();
|
||||
PhraseaCLIExceptionHandler::register();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -955,13 +955,16 @@ class Collection implements ControllerProviderInterface
|
||||
$success = false;
|
||||
|
||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||
$prefs = $request->request->get('str');
|
||||
|
||||
try {
|
||||
if ('' !== trim($prefs)) {
|
||||
$domdoc = new \DOMDocument();
|
||||
if ($domdoc->loadXML($request->request->get('str'))) {
|
||||
if (true === $domdoc->loadXML($prefs)) {
|
||||
$collection->set_prefs($domdoc);
|
||||
$success = true;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
@@ -116,13 +116,8 @@ class ReconnectableConnection implements ConnectionInterface
|
||||
private function tryMethod($method, $args)
|
||||
{
|
||||
try {
|
||||
set_error_handler(function ($errno, $errstr) { throw new \Exception($errstr, $errno); });
|
||||
$ret = call_user_func_array([$this->connection, $method], $args);
|
||||
restore_error_handler();
|
||||
|
||||
return $ret;
|
||||
return call_user_func_array([$this->connection, $method], $args);
|
||||
} catch (\Exception $exception) {
|
||||
restore_error_handler();
|
||||
$e = $exception;
|
||||
while ($e->getPrevious() && !$e instanceof \PDOException) {
|
||||
$e = $e->getPrevious();
|
||||
@@ -133,7 +128,11 @@ class ReconnectableConnection implements ConnectionInterface
|
||||
|
||||
return call_user_func_array([$this->connection, $method], $args);
|
||||
}
|
||||
if ((false !== strpos($exception->getMessage(), 'MySQL server has gone away')) || (false !== strpos($exception->getMessage(), 'errno=32 Broken pipe'))) {
|
||||
if (
|
||||
(false !== strpos($exception->getMessage(), 'MySQL server has gone away'))
|
||||
|| (false !== strpos($exception->getMessage(), 'Error while sending QUERY packet'))
|
||||
|| (false !== strpos($exception->getMessage(), 'errno=32 Broken pipe'))
|
||||
) {
|
||||
$this->connection->close();
|
||||
$this->connection->connect();
|
||||
|
||||
|
22
lib/Alchemy/Phrasea/Core/PhraseaCLIExceptionHandler.php
Normal file
22
lib/Alchemy/Phrasea/Core/PhraseaCLIExceptionHandler.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core;
|
||||
|
||||
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
|
||||
|
||||
class PhraseaCLIExceptionHandler extends SymfonyExceptionHandler
|
||||
{
|
||||
public function handle(\Exception $exception)
|
||||
{
|
||||
throw $exception;
|
||||
}
|
||||
}
|
@@ -14,6 +14,8 @@ use Symfony\Component\Debug\ErrorHandler;
|
||||
|
||||
require_once __DIR__ . "/../lib/autoload.php";
|
||||
|
||||
error_reporting(-1);
|
||||
|
||||
ErrorHandler::register();
|
||||
|
||||
$environment = Application::ENV_DEV;
|
||||
|
Reference in New Issue
Block a user