mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 08:35:00 +00:00
Warn about expensive code in test environment.
This commit is contained in:
@@ -32,11 +32,15 @@ use Log;
|
||||
*/
|
||||
class FireflyConfig
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function delete(string $name): void
|
||||
{
|
||||
if ('testing' === config('app.env')) {
|
||||
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
|
||||
}
|
||||
$fullName = 'ff-config-' . $name;
|
||||
if (Cache::has($fullName)) {
|
||||
Cache::forget($fullName);
|
||||
@@ -51,12 +55,15 @@ class FireflyConfig
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $default
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return \FireflyIII\Models\Configuration|null
|
||||
*/
|
||||
public function get(string $name, $default = null): ?Configuration
|
||||
{
|
||||
if ('testing' === config('app.env')) {
|
||||
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
|
||||
}
|
||||
$fullName = 'ff-config-' . $name;
|
||||
if (Cache::has($fullName)) {
|
||||
return Cache::get($fullName);
|
||||
@@ -79,12 +86,15 @@ class FireflyConfig
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $default
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return \FireflyIII\Models\Configuration|null
|
||||
*/
|
||||
public function getFresh(string $name, $default = null): ?Configuration
|
||||
{
|
||||
if ('testing' === config('app.env')) {
|
||||
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
|
||||
}
|
||||
$config = Configuration::where('name', $name)->first(['id', 'name', 'data']);
|
||||
if ($config) {
|
||||
|
||||
@@ -106,6 +116,10 @@ class FireflyConfig
|
||||
*/
|
||||
public function put(string $name, $value): Configuration
|
||||
{
|
||||
if ('testing' === config('app.env')) {
|
||||
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
|
||||
}
|
||||
|
||||
return $this->set($name, $value);
|
||||
}
|
||||
|
||||
@@ -117,6 +131,9 @@ class FireflyConfig
|
||||
*/
|
||||
public function set(string $name, $value): Configuration
|
||||
{
|
||||
if ('testing' === config('app.env')) {
|
||||
Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__));
|
||||
}
|
||||
Log::debug('Set new value for ', ['name' => $name]);
|
||||
/** @var Configuration $config */
|
||||
$config = Configuration::whereName($name)->first();
|
||||
|
Reference in New Issue
Block a user