Fix null pointer.

This commit is contained in:
James Cole 2018-03-11 08:22:20 +01:00
parent aad0864018
commit 7d6c8aa9dc
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
4 changed files with 10 additions and 15 deletions

View File

@ -30,7 +30,6 @@ use League\Fractal\Manager;
use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
* Class AboutController
*/
@ -44,7 +43,6 @@ class AboutController extends Controller
public function __construct()
{
parent::__construct();
}
/**
@ -64,7 +62,6 @@ class AboutController extends Controller
'php_version' => $phpVersion,
'os' => $phpOs,
'driver' => $currentDriver,
];
return response()->json(['data' => $data], 200)->header('Content-Type', 'application/vnd.api+json');
@ -84,5 +81,4 @@ class AboutController extends Controller
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
}
}

View File

@ -43,7 +43,6 @@ use Preferences;
*/
class AccountController extends Controller
{
/** @var CurrencyRepositoryInterface */
private $currencyRepository;
/** @var AccountRepositoryInterface */
@ -59,7 +58,7 @@ class AccountController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var AccountRepositoryInterface repository */
// @var AccountRepositoryInterface repository
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
@ -74,7 +73,7 @@ class AccountController extends Controller
/**
* Remove the specified resource from storage.
*
* @param \FireflyIII\Models\Account $account
* @param \FireflyIII\Models\Account $account
*
* @return \Illuminate\Http\Response
*/
@ -153,7 +152,7 @@ class AccountController extends Controller
{
$data = $request->getAll();
// if currency ID is 0, find the currency by the code:
if ($data['currency_id'] === 0) {
if (0 === $data['currency_id']) {
$currency = $this->currencyRepository->findByCodeNull($data['currency_code']);
$data['currency_id'] = is_null($currency) ? 0 : $currency->id;
}
@ -165,7 +164,6 @@ class AccountController extends Controller
$resource = new Item($account, new AccountTransformer($this->parameters), 'accounts');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
}
/**
@ -180,7 +178,7 @@ class AccountController extends Controller
{
$data = $request->getAll();
// if currency ID is 0, find the currency by the code:
if ($data['currency_id'] === 0) {
if (0 === $data['currency_id']) {
$currency = $this->currencyRepository->findByCodeNull($data['currency_code']);
$data['currency_id'] = is_null($currency) ? 0 : $currency->id;
}

View File

@ -58,10 +58,12 @@ class TransactionJournalMetaFactory
}
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
if (!is_null($entry)) {
try {
$entry->delete();
} catch (Exception $e) { // @codeCoverageIgnore
Log::error(sprintf('Could not delete transaction journal meta: %s', $e->getMessage())); // @codeCoverageIgnore
}
}
return null;

File diff suppressed because one or more lines are too long