Modification méthode de cache suite problème avec chaine de caractère dans les ratios

This commit is contained in:
Michael RICOIS 2011-05-26 15:41:36 +00:00
parent 099ce489bf
commit a5b58ee1df
2 changed files with 44 additions and 49 deletions

View File

@ -26,11 +26,11 @@ class Cache
return true;
}
public function setBlock($block, $array)
public function setBlock($array)
{
//Ajout des blocs sérialisés
if(!empty($this->filename)){
$data = $block.' = '.serialize($array);
$data = base64_encode(serialize($array));
if( !$this->_writefile($data, $this->filename) ) {
return true;
}
@ -38,12 +38,12 @@ class Cache
return false;
}
public function getBlock($block)
public function getBlock()
{
$cache = $this->_readfile($this->filename);
if(isset($cache[$block])){
if(isset($cache)){
//Traitement
$block = unserialize($cache[$block]);
$block = unserialize(base64_decode($cache));
return $block;
} else {
return false;
@ -80,11 +80,7 @@ class Cache
if ( ($this->filename != $this->file_loaded) ) {
$this->file_loaded = $this->filename;
if (is_file($this->filename)) {
$lines = file($this->filename);
foreach ($lines as $line_num => $line) {
list($key, $value) = explode(' = ', $line, 2);
$cache[$key] = $value;
}
$cache = file_get_contents($this->filename);
}
$this->cache_loaded = true;
}

View File

@ -41,7 +41,7 @@ class WsScores
$filename = 'getrapport-'.$siren.'-'.$niveau.'-'.$id;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new stdClass();
$params->siren = $siren;
@ -51,7 +51,7 @@ class WsScores
try {
$reponse = $client->getRapport($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getRapportResult);
$cache->setBlock($reponse->getRapportResult);
return $reponse->getRapportResult;
} catch (SoapFault $fault) {
return false;
@ -136,7 +136,7 @@ class WsScores
$filename = 'getindiscore-'.$siren.'-'.$nic.'-'.$niveau;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new stdClass();
$params->siren = $siren;
@ -147,7 +147,7 @@ class WsScores
try {
$reponse = $client->getIndiScore($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getIndiScoreResult);
$cache->setBlock($reponse->getIndiScoreResult);
return $reponse->getIndiScoreResult;
} catch (SoapFault $fault) {
return false;
@ -296,14 +296,14 @@ class WsScores
$filename = 'listejalcollecte';
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new stdClass();
$client = $this->loadClient('interne');
try {
$reponse = $client->getListeJalCollecte();
$cache->deletefile();
$cache->setBlock('element', $reponse->getListeJalCollecteResult);
$cache->setBlock($reponse->getListeJalCollecteResult);
return $reponse->getListeJalCollecteResult;
} catch (SoapFault $fault) {
return false;
@ -427,7 +427,7 @@ class WsScores
$filename = 'marques-'.$siren.'-'.$idDepot;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new stdClass();
$params->siren = $siren;
@ -436,7 +436,7 @@ class WsScores
try {
$reponse = $client->getMarques($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getMarquesResult);
$cache->setBlock($reponse->getMarquesResult);
return $reponse->getMarquesResult;
} catch (SoapFault $fault) {;
return false;
@ -453,7 +453,7 @@ class WsScores
$filename = 'conventions-'.$siren;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new stdClass();
$params->siren = $siren;
@ -461,7 +461,7 @@ class WsScores
try {
$reponse = $client->getListeConventions($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getListeConventionsResult);
$cache->setBlock($reponse->getListeConventionsResult);
return $reponse->getListeConventionsResult;
} catch (SoapFault $fault) {;
return false;
@ -480,7 +480,7 @@ class WsScores
$filename = 'competences-'.$siret.'-'.$type.'-'.$codeInsee;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new stdClass();
$params->siret = $siret;
@ -490,7 +490,7 @@ class WsScores
try {
$reponse = $client->getListeCompetences($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getListeCompetencesResult);
$cache->setBlock($reponse->getListeCompetencesResult);
return $reponse->getListeCompetencesResult;
} catch (SoapFault $fault) {;
return false;
@ -507,7 +507,7 @@ class WsScores
$filename = 'infosreg-'.$siren.'-'.$id;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new stdClass();
$params->siren = $siren;
@ -516,7 +516,7 @@ class WsScores
try {
$reponse = $client->getInfosReg($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getInfosRegResult);
$cache->setBlock($reponse->getInfosRegResult);
return $reponse->getInfosRegResult;
} catch (SoapFault $fault) {
return false;
@ -536,7 +536,7 @@ class WsScores
$filename = 'annonces-'.$siren.'-'.$filtre.'-'.$idAnn.'-'.$position.'-'.$nbRep;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new stdClass();
$params->siren = $siren;
@ -546,7 +546,7 @@ class WsScores
try {
$reponse = $client->getAnnonces($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getAnnoncesResult);
$cache->setBlock($reponse->getAnnoncesResult);
return $reponse->getAnnoncesResult;
} catch (SoapFault $fault) {
return false;
@ -628,7 +628,7 @@ class WsScores
$filename = 'listebilans-'.$siren;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new StdClass;
$params->siren = $siren;
@ -636,7 +636,7 @@ class WsScores
try {
$reponse = $client->getListeBilans($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getListeBilansResult);
$cache->setBlock($reponse->getListeBilansResult);
return $reponse->getListeBilansResult;
} catch (SoapFault $fault) {
return false;
@ -655,7 +655,7 @@ class WsScores
$filename = 'bilan-'.$siren.'-'.$millesime.'-'.$typeBilan.'-'.$ref;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new StdClass;
$params->siren = $siren;
@ -666,7 +666,7 @@ class WsScores
try {
$reponse = $client->getBilan($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getBilanResult);
$cache->setBlock($reponse->getBilanResult);
return $reponse->getBilanResult;
} catch (SoapFault $fault) {
return false;
@ -682,7 +682,7 @@ class WsScores
$filename = 'banques-'.$siren;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new StdClass;
$params->siren = $siren;
@ -690,7 +690,7 @@ class WsScores
try {
$reponse = $client->getBanques($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getBanquesResult);
$cache->setBlock($reponse->getBanquesResult);
return $reponse->getBanquesResult;
} catch (SoapFault $fault) {
return false;
@ -706,7 +706,7 @@ class WsScores
$filename = 'infosbourse-'.$siren;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new StdClass;
$params->siren = $siren;
@ -714,7 +714,7 @@ class WsScores
try {
$reponse = $client->getInfosBourse($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getInfosBourseResult);
$cache->setBlock($reponse->getInfosBourseResult);
return $reponse->getInfosBourseResult;
} catch (SoapFault $fault) {
return false;
@ -730,8 +730,9 @@ class WsScores
{
$filename = 'ratios-'.$siren.'-'.$page;
$cache = new Cache($filename);
Zend_Registry::get('firebug')->info('getRatios');
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new StdClass();
$params->siren = $siren;
@ -740,7 +741,7 @@ class WsScores
try {
$reponse = $client->getRatios($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getRatiosResult);
$cache->setBlock($reponse->getRatiosResult);
return $reponse->getRatiosResult;
} catch (SoapFault $fault) {
return false;
@ -758,7 +759,7 @@ class WsScores
$filename = 'dirigeants-'.$siren.'-'.$histo;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new StdClass();
$params->siren = $siren;
@ -767,7 +768,7 @@ class WsScores
try {
$reponse = $client->getDirigeants($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getDirigeantsResult);
$cache->setBlock($reponse->getDirigeantsResult);
return $reponse->getDirigeantsResult;
} catch (SoapFault $fault) {
return false;
@ -785,7 +786,7 @@ class WsScores
$filename = 'identite-'.$siret.'-'.$id;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new StdClass();
$params->siret = $siret;
@ -794,7 +795,7 @@ class WsScores
try {
$reponse = $client->getIdentite($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getIdentiteResult);
$cache->setBlock($reponse->getIdentiteResult);
return $reponse->getIdentiteResult;
} catch (SoapFault $fault) {
throw new Zend_Soap_Client_Exception($fault);
@ -813,7 +814,7 @@ class WsScores
$filename = 'liens-'.$siren;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new StdClass();
$params->siren = $siren;
@ -822,7 +823,7 @@ class WsScores
try {
$reponse = $client->getLiens($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getLiensResult);
$cache->setBlock($reponse->getLiensResult);
return $reponse->getLiensResult;
} catch (SoapFault $fault) {
return false;
@ -842,7 +843,7 @@ class WsScores
$filename = 'listeevenements-'.$siren.'-'.$nic.'-'.$position.'-'.$nbRep;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new stdClass();
$params->siren = $siren;
@ -853,7 +854,7 @@ class WsScores
try {
$reponse = $client->getListeEvenements($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getListeEvenementsResult);
$cache->setBlock($reponse->getListeEvenementsResult);
return $reponse->getListeEvenementsResult;
} catch (SoapFault $fault) {
return false;
@ -871,7 +872,7 @@ class WsScores
$filename = 'listeetablissements-'.$siren.'-'.actif;
$cache = new Cache($filename);
if ($cache->exist() && !$this->toNotCache ){
return $cache->getBlock('element');
return $cache->getBlock();
}
$params = new StdClass();
$params->siren = $siren;
@ -883,15 +884,13 @@ class WsScores
try {
$reponse = $client->getListeEtablissements($params);
$cache->deletefile();
$cache->setBlock('element', $reponse->getListeEtablissementsResult);
$cache->setBlock($reponse->getListeEtablissementsResult);
return $reponse->getListeEtablissementsResult;
} catch (SoapFault $fault) {
return false;
}
}
/**
* rechercheEntreprise
* @param unknown_type $type