mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Should fix tests.
This commit is contained in:
@@ -4,6 +4,7 @@ namespace FireflyIII\Support;
|
||||
|
||||
|
||||
use Auth;
|
||||
use Cache;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -17,6 +18,8 @@ use Preferences as Prefs;
|
||||
class CacheProperties
|
||||
{
|
||||
|
||||
/** @var string */
|
||||
protected $md5 = '';
|
||||
/** @var Collection */
|
||||
protected $properties;
|
||||
|
||||
@@ -38,39 +41,62 @@ class CacheProperties
|
||||
$this->properties->push($property);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return Cache::get($this->md5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function md5()
|
||||
public function getMd5()
|
||||
{
|
||||
return $this->md5;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function has()
|
||||
{
|
||||
$this->md5();
|
||||
|
||||
return Cache::has($this->md5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function md5()
|
||||
{
|
||||
$string = '';
|
||||
//Log::debug('--- building string ---');
|
||||
foreach ($this->properties as $property) {
|
||||
|
||||
if ($property instanceof Collection || $property instanceof EloquentCollection) {
|
||||
$string .= print_r($property->toArray(), true);
|
||||
$this->md5 .= print_r($property->toArray(), true);
|
||||
continue;
|
||||
}
|
||||
if ($property instanceof Carbon) {
|
||||
$string .= $property->toRfc3339String();
|
||||
$this->md5 .= $property->toRfc3339String();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($property)) {
|
||||
$string .= print_r($property, true);
|
||||
$this->md5 .= print_r($property, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_object($property)) {
|
||||
$string .= $property->__toString();
|
||||
$this->md5 .= $property->__toString();
|
||||
}
|
||||
if (is_array($property)) {
|
||||
$string .= print_r($property, true);
|
||||
$this->md5 .= print_r($property, true);
|
||||
}
|
||||
$string .= (string)$property;
|
||||
$this->md5 .= (string)$property;
|
||||
}
|
||||
|
||||
return md5($string);
|
||||
$this->md5 = md5($this->md5);
|
||||
}
|
||||
}
|
@@ -30,10 +30,10 @@ class Steam
|
||||
$properties->addProperty('balance');
|
||||
$properties->addProperty($date);
|
||||
$properties->addProperty($ignoreVirtualBalance);
|
||||
$md5 = $properties->md5();
|
||||
if (Cache::has($md5)) {
|
||||
return Cache::get($md5);
|
||||
if ($properties->has()) {
|
||||
return $properties->get();
|
||||
}
|
||||
$md5 = $properties->getMd5();
|
||||
|
||||
|
||||
// find the first known transaction on this account:
|
||||
|
@@ -33,10 +33,10 @@ class Journal extends Twig_Extension
|
||||
$prop = new CacheProperties();
|
||||
$prop->addProperty($journal->id);
|
||||
$prop->addProperty('typeIcon');
|
||||
$md5 = $prop->md5();
|
||||
if (Cache::has($md5)) {
|
||||
return Cache::get($md5);
|
||||
if ($prop->has()) {
|
||||
return $prop->get();
|
||||
}
|
||||
$md5 = $prop->getMd5();
|
||||
|
||||
$type = $journal->transactionType->type;
|
||||
|
||||
|
Reference in New Issue
Block a user