Update php7/8 detection code.

This commit is contained in:
James Cole
2021-03-23 06:23:30 +01:00
parent 7f48a1b6ee
commit ccaadd1f52
13 changed files with 119 additions and 106 deletions

View File

@@ -78,7 +78,7 @@ class HomeController extends Controller
// check if the label is "everything" or "Custom range" which will betray
// a possible problem with the budgets.
if ($label === (string) trans('firefly.everything') || $label === (string) trans('firefly.customRange')) {
if ($label === (string)trans('firefly.everything') || $label === (string)trans('firefly.customRange')) {
$isCustomRange = true;
Log::debug('Range is now marked as "custom".');
}
@@ -86,7 +86,7 @@ class HomeController extends Controller
$diff = $start->diffInDays($end) + 1;
if ($diff > 50) {
$request->session()->flash('warning', (string) trans('firefly.warning_much_data', ['days' => $diff]));
$request->session()->flash('warning', (string)trans('firefly.warning_much_data', ['days' => $diff]));
}
$request->session()->put('is_custom_range', $isCustomRange);
@@ -110,14 +110,15 @@ class HomeController extends Controller
*/
public function index(AccountRepositoryInterface $repository)
{
$types = config('firefly.accountTypesByIdentifier.asset');
$count = $repository->count($types);
$result = version_compare(phpversion(), '8.0');
$types = config('firefly.accountTypesByIdentifier.asset');
$count = $repository->count($types);
Log::channel('audit')->info('User visits homepage.');
if (0 === $count) {
return redirect(route('new-user.index'));
}
$subTitle = (string) trans('firefly.welcome_back');
$subTitle = (string)trans('firefly.welcome_back');
$transactions = [];
$frontPage = app('preferences')->getFresh('frontPageAccounts', $repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray());
/** @var Carbon $start */

View File

@@ -35,7 +35,6 @@ use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Laravel\Passport\Passport;
use Log;
/**
* Class InstallController
*
@@ -134,12 +133,18 @@ class InstallController extends Controller
public function keys(): void
{
// switch on PHP version.
// switch on PHP version.
if (7 === PHP_MAJOR_VERSION) {
$result = version_compare(phpversion(), '8.0');
Log::info(sprintf('PHP version is %s', $result));
if (-1 === $result) {
Log::info('Will run PHP7 code.');
// PHP 7
$rsa = new \phpseclib\Crypt\RSA;
$keys = $rsa->createKey(4096);
}
if (8 === PHP_MAJOR_VERSION) {
if ($result >= 0) {
Log::info('Will run PHP8 code.');
// PHP 8
$keys = \phpseclib3\Crypt\RSA::createKey(4096);
}