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\Command\CommandInterface;
|
||||||
use Alchemy\Phrasea\Core\CLIProvider\TranslationExtractorServiceProvider;
|
use Alchemy\Phrasea\Core\CLIProvider\TranslationExtractorServiceProvider;
|
||||||
use Alchemy\Phrasea\Core\CLIProvider\WebsocketServerServiceProvider;
|
use Alchemy\Phrasea\Core\CLIProvider\WebsocketServerServiceProvider;
|
||||||
|
use Alchemy\Phrasea\Core\PhraseaCLIExceptionHandler;
|
||||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
use Symfony\Component\Console;
|
use Symfony\Component\Console;
|
||||||
use Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider;
|
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\PluginServiceProvider;
|
||||||
use Alchemy\Phrasea\Core\CLIProvider\SignalHandlerServiceProvider;
|
use Alchemy\Phrasea\Core\CLIProvider\SignalHandlerServiceProvider;
|
||||||
use Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider;
|
use Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider;
|
||||||
|
use Symfony\Component\Debug\ErrorHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Phraseanet Command Line Application
|
* Phraseanet Command Line Application
|
||||||
@@ -66,6 +68,10 @@ class CLI extends Application
|
|||||||
$this->register(new DoctrineMigrationServiceProvider());
|
$this->register(new DoctrineMigrationServiceProvider());
|
||||||
|
|
||||||
$this->bindRoutes();
|
$this->bindRoutes();
|
||||||
|
|
||||||
|
error_reporting(-1);
|
||||||
|
ErrorHandler::register();
|
||||||
|
PhraseaCLIExceptionHandler::register();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -955,12 +955,15 @@ class Collection implements ControllerProviderInterface
|
|||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
$collection = \collection::get_from_base_id($app, $bas_id);
|
$collection = \collection::get_from_base_id($app, $bas_id);
|
||||||
|
$prefs = $request->request->get('str');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$domdoc = new \DOMDocument();
|
if ('' !== trim($prefs)) {
|
||||||
if ($domdoc->loadXML($request->request->get('str'))) {
|
$domdoc = new \DOMDocument();
|
||||||
$collection->set_prefs($domdoc);
|
if (true === $domdoc->loadXML($prefs)) {
|
||||||
$success = true;
|
$collection->set_prefs($domdoc);
|
||||||
|
$success = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
|
@@ -116,13 +116,8 @@ class ReconnectableConnection implements ConnectionInterface
|
|||||||
private function tryMethod($method, $args)
|
private function tryMethod($method, $args)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
set_error_handler(function ($errno, $errstr) { throw new \Exception($errstr, $errno); });
|
return call_user_func_array([$this->connection, $method], $args);
|
||||||
$ret = call_user_func_array([$this->connection, $method], $args);
|
|
||||||
restore_error_handler();
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
restore_error_handler();
|
|
||||||
$e = $exception;
|
$e = $exception;
|
||||||
while ($e->getPrevious() && !$e instanceof \PDOException) {
|
while ($e->getPrevious() && !$e instanceof \PDOException) {
|
||||||
$e = $e->getPrevious();
|
$e = $e->getPrevious();
|
||||||
@@ -133,7 +128,11 @@ class ReconnectableConnection implements ConnectionInterface
|
|||||||
|
|
||||||
return call_user_func_array([$this->connection, $method], $args);
|
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->close();
|
||||||
$this->connection->connect();
|
$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";
|
require_once __DIR__ . "/../lib/autoload.php";
|
||||||
|
|
||||||
|
error_reporting(-1);
|
||||||
|
|
||||||
ErrorHandler::register();
|
ErrorHandler::register();
|
||||||
|
|
||||||
$environment = Application::ENV_DEV;
|
$environment = Application::ENV_DEV;
|
||||||
|
Reference in New Issue
Block a user