This commit is contained in:
James Cole 2018-03-10 20:25:11 +01:00
parent c8ecb3e0ee
commit 85dc1263ea
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 26 additions and 1 deletions

View File

@ -56,6 +56,16 @@ class TransactionJournalMetaFactory
if ($data['data'] instanceof Carbon) {
$value = $data['data']->toW3cString();
}
if (strlen($value) === 0) {
// don't store blank strings.
try {
$entry->delete();
} catch (Exception $e) { // @codeCoverageIgnore
Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage())); // @codeCoverageIgnore
}
return null;
}
if (null === $entry) {

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
use Carbon\Carbon;
use Exception;
use FireflyIII\Factory\TransactionJournalFactory;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
@ -376,6 +377,9 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function getMetaField(TransactionJournal $journal, string $field): ?string
{
$class = new \stdClass;
$class->value = 'hi there';
$value = null;
$cache = new CacheProperties;
$cache->addProperty('journal-meta');
@ -394,7 +398,18 @@ class JournalRepository implements JournalRepositoryInterface
$value = $entry->data;
$cache->store($value);
return $value;
if (is_array($value)) {
return join(',', $value);
}
try {
$return = strval($value);
} catch (Exception $e) {
Log::error($e->getMessage());
return '';
}
return $return;
}
/**