Commit 8b05c8f1 authored by Patrick Barroca's avatar Patrick Barroca 🎮

Merge branch...

Merge branch 'hotline#91081_bouton_inspector_gadget_serveur_de_cache_present_plusieurs_fois' into 'hotline'

hotline #91081 : Cache serveur calls in Inspector Gadget Webservice calls button

See merge request afi/opacce!3119
parents 7c610a4b d7252734
- ticket #91081 : Inspecteur Gadget : Les appels au serveur de cache AFI s'affiche par le bouton "Appels webservices"
\ No newline at end of file
......@@ -23,7 +23,19 @@
class Class_Notice_Thumbnail_ProviderCacheServer
extends Class_Notice_Thumbnail_ProviderAbstract {
protected static $_is_tracking_seen = true;
protected static $_seen = [];
/** @category testing */
public static function doNotTrackSeen() {
static::$_is_tracking_seen = false;
}
public function updateNotice() {
if ($this->_shouldIgnore())
return $this;
if (!$urls = $this->_getUrls())
return $this->noWebThumbRecord();
......@@ -36,6 +48,18 @@ class Class_Notice_Thumbnail_ProviderCacheServer
}
protected function _shouldIgnore() {
if (!static::$_is_tracking_seen)
return false;
if (in_array($this->_record->getId(), static::$_seen))
return true;
static::$_seen[] = $this->_record->getId();
return false;
}
protected function _getUrls() {
$record = $this->_record;
$numero = $record->isPeriodique() ? $record->getTomeAlpha() : '';
......
......@@ -184,26 +184,11 @@ class Class_WebService_AllServices {
$response = json_decode(self::httpGet($url_service, $args), true);
static::_addInspectorGadget($url_service, $args, $response);
return $response;
}
protected static function _addInspectorGadget($url, $args, $response) {
if (!$ig = Zend_Controller_Front::getInstance()
if ($ig = Zend_Controller_Front::getInstance()
->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget'))
return;
if(!$ig->isEnabled())
return;
$ig->log();
$ig->addButton(new Class_Entity(['Label' => 'Serveur de cache',
'Content' => 'URL : ' . $url
. BR
. 'args : ' . implode(BR, $args)
. BR
. 'response : ' . implode(BR, $response)]));
return $response;
}
......
......@@ -192,9 +192,11 @@ create: function(event, ui) { if (ui.panel.hasClass(\'ig-accordion\')) ui.panel.
public function log() {
if (!$httpClient = Class_HttpClientFactory::getInstance()->getLastHttpClient()) {
if (!$this->isEnabled())
return $this;
if (!$httpClient = Class_HttpClientFactory::getInstance()->getLastHttpClient())
return $this;
}
$response_code = $response_body = null;
if ($response = $httpClient->getLastResponse()) {
......@@ -246,10 +248,10 @@ create: function(event, ui) { if (ui.panel.hasClass(\'ig-accordion\')) ui.panel.
if (!$this->isEnabled())
return $this;
if(!$instance)
if (!$instance)
return $this;
$this->_buttons []= $instance;
$this->_buttons[]= $instance;
return $this;
}
}
......@@ -146,6 +146,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe
->whenCalled('password_hash')
->willDo(function($pass, $crypt) { return $pass; }));
Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()->whenCalled('execTimedScript')->answers(''));
Class_Notice_Thumbnail_ProviderCacheServer::doNotTrackSeen();
}
......
......@@ -85,6 +85,7 @@ abstract class ModelTestCase extends Storm_Test_ModelTestCase {
->willDo(function($pass, $crypt) { return $pass; }));
Class_WebService_BibNumerique_RessourceNumerique::setCommand($this->mock()
->whenCalled('execTimedScript')->answers(''));
Class_Notice_Thumbnail_ProviderCacheServer::doNotTrackSeen();
$this->fixture('Class_CodifLangue',
['id' => 'fre',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment