Fix BindingResolutionError when debug toolbar isn't present (#465)
* Fix BindingResolutionError when debug toolbar isn't present * Formatting
This commit is contained in:
@@ -18,15 +18,20 @@ if [ "$TRAVIS" = "true" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Write the version out but place the branch ID in there
|
||||||
|
# This is only for the dev branch
|
||||||
BASE_VERSION=$(php artisan phpvms:version --base-only)
|
BASE_VERSION=$(php artisan phpvms:version --base-only)
|
||||||
PKG_NAME=${BASE_VERSION}-${TRAVIS_BRANCH}
|
|
||||||
|
# This now includes the pre-release version, so "-dev" by default
|
||||||
|
PKG_NAME=${BASE_VERSION}
|
||||||
|
|
||||||
# Don't pass in a version here, just write out the latest hash
|
# Don't pass in a version here, just write out the latest hash
|
||||||
php artisan phpvms:version --write > VERSION
|
php artisan phpvms:version --write >VERSION
|
||||||
VERSION=$(cat VERSION)
|
VERSION=$(cat VERSION)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Version: $VERSION"
|
echo "Version: $VERSION"
|
||||||
|
echo "Package name: $TAR_NAME"
|
||||||
|
|
||||||
FILE_NAME="phpvms-$PKG_NAME"
|
FILE_NAME="phpvms-$PKG_NAME"
|
||||||
TAR_NAME="$FILE_NAME.tar.gz"
|
TAR_NAME="$FILE_NAME.tar.gz"
|
||||||
@@ -99,8 +104,6 @@ if [ "$TRAVIS" = "true" ]; then
|
|||||||
composer dump-autoload
|
composer dump-autoload
|
||||||
make clean
|
make clean
|
||||||
|
|
||||||
echo "Writing $TAR_NAME"
|
|
||||||
|
|
||||||
cd /tmp
|
cd /tmp
|
||||||
tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR/../ phpvms
|
tar -czf $TAR_NAME -C $TRAVIS_BUILD_DIR/../ phpvms
|
||||||
sha256sum $TAR_NAME >"$TAR_NAME.sha256"
|
sha256sum $TAR_NAME >"$TAR_NAME.sha256"
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class Version extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Always write out the build ID/build number which is the commit hash
|
||||||
$build_number = $this->versionSvc->getBuildId($cfg);
|
$build_number = $this->versionSvc->getBuildId($cfg);
|
||||||
$cfg['current']['commit'] = $build_number;
|
$cfg['current']['commit'] = $build_number;
|
||||||
$cfg['build']['number'] = $build_number;
|
$cfg['build']['number'] = $build_number;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ use App\Models\Subfleet;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Repositories\SettingRepository;
|
use App\Repositories\SettingRepository;
|
||||||
use App\Services\ModuleService;
|
use App\Services\ModuleService;
|
||||||
|
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\Facades\View;
|
use Illuminate\Support\Facades\View;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
@@ -75,10 +76,13 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config('app.debug_toolbar') === true) {
|
try {
|
||||||
app('debugbar')->enable();
|
if (config('app.debug_toolbar') === true) {
|
||||||
} else {
|
app('debugbar')->enable();
|
||||||
app('debugbar')->disable();
|
} else {
|
||||||
|
app('debugbar')->disable();
|
||||||
|
}
|
||||||
|
} catch (BindingResolutionException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ class VersionService extends Service
|
|||||||
$current_version = $this->cleanVersionString($current_version);
|
$current_version = $this->cleanVersionString($current_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace "dev" with "alpha", since
|
||||||
|
|
||||||
$latest_version = $this->getLatestVersion();
|
$latest_version = $this->getLatestVersion();
|
||||||
|
|
||||||
// Convert to semver
|
// Convert to semver
|
||||||
|
|||||||
@@ -4,6 +4,18 @@ use App\Exceptions\SettingNotFound;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* array_key_first only exists in PHP 7.3+
|
||||||
|
*/
|
||||||
|
if (!function_exists('array_key_first')) {
|
||||||
|
function array_key_first(array $arr)
|
||||||
|
{
|
||||||
|
foreach ($arr as $key => $unused) {
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('in_mask')) {
|
if (!function_exists('in_mask')) {
|
||||||
/**
|
/**
|
||||||
* Return true/false if a value exists in a mask
|
* Return true/false if a value exists in a mask
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Modules\Installer\Http\Controllers;
|
namespace Modules\Installer\Http\Controllers;
|
||||||
|
|
||||||
use App\Contracts\Controller;
|
use App\Contracts\Controller;
|
||||||
|
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Modules\Installer\Services\Importer\ImporterService;
|
use Modules\Installer\Services\Importer\ImporterService;
|
||||||
@@ -15,7 +16,10 @@ class ImporterController extends Controller
|
|||||||
{
|
{
|
||||||
$this->importerSvc = $importerSvc;
|
$this->importerSvc = $importerSvc;
|
||||||
|
|
||||||
app('debugbar')->disable();
|
try {
|
||||||
|
app('debugbar')->disable();
|
||||||
|
} catch (BindingResolutionException $e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +32,10 @@ class ImporterController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
app('debugbar')->disable(); // saves the query logging
|
try {
|
||||||
|
app('debugbar')->disable();
|
||||||
|
} catch (BindingResolutionException $e) {
|
||||||
|
}
|
||||||
|
|
||||||
return view('installer::importer/step1-configure');
|
return view('installer::importer/step1-configure');
|
||||||
}
|
}
|
||||||
@@ -42,7 +49,10 @@ class ImporterController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function config(Request $request)
|
public function config(Request $request)
|
||||||
{
|
{
|
||||||
app('debugbar')->disable(); // saves the query logging
|
try {
|
||||||
|
app('debugbar')->disable();
|
||||||
|
} catch (BindingResolutionException $e) {
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Save the credentials to use later
|
// Save the credentials to use later
|
||||||
@@ -78,7 +88,10 @@ class ImporterController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function run(Request $request)
|
public function run(Request $request)
|
||||||
{
|
{
|
||||||
app('debugbar')->disable(); // saves the query logging
|
try {
|
||||||
|
app('debugbar')->disable();
|
||||||
|
} catch (BindingResolutionException $e) {
|
||||||
|
}
|
||||||
|
|
||||||
$importer = $request->input('importer');
|
$importer = $request->input('importer');
|
||||||
$start = $request->input('start');
|
$start = $request->input('start');
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Services\Installer\MigrationService;
|
|||||||
use App\Services\Installer\SeederService;
|
use App\Services\Installer\SeederService;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
use App\Support\Countries;
|
use App\Support\Countries;
|
||||||
|
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||||
use Illuminate\Database\QueryException;
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
@@ -63,7 +64,10 @@ class InstallerController extends Controller
|
|||||||
$this->seederSvc = $seederSvc;
|
$this->seederSvc = $seederSvc;
|
||||||
$this->userService = $userService;
|
$this->userService = $userService;
|
||||||
|
|
||||||
app('debugbar')->disable();
|
try {
|
||||||
|
app('debugbar')->disable();
|
||||||
|
} catch (BindingResolutionException $e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,17 +20,24 @@ class VersionTest extends TestCase
|
|||||||
public function testGreaterThanVersionStrings(): void
|
public function testGreaterThanVersionStrings(): void
|
||||||
{
|
{
|
||||||
$test = [
|
$test = [
|
||||||
'7.0.0' => '6.0.0',
|
['7.0.0' => '6.0.0'],
|
||||||
'7.0.0+1231s' => '6.0.0',
|
['7.0.0+1231s' => '6.0.0'],
|
||||||
'7.0.0-beta' => '7.0.0-alpha',
|
// ['7.0.0-beta' => '7.0.0-dev'],
|
||||||
'7.0.0-beta.1' => '7.0.0-beta',
|
['7.0.0-beta' => '7.0.0-alpha'],
|
||||||
'7.0.0-beta.2' => '7.0.0-beta.1',
|
['7.0.0-beta.1' => '7.0.0-beta'],
|
||||||
'7.0.0-beta.2+a34sdf' => '7.0.0-beta.1',
|
['7.0.0-beta.2' => '7.0.0-beta.1'],
|
||||||
|
['7.0.0-beta.2+a34sdf' => '7.0.0-beta.1'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$versionSvc = app(VersionService::class);
|
$versionSvc = app(VersionService::class);
|
||||||
foreach ($test as $newVersion => $currentVersion) {
|
foreach ($test as $set) {
|
||||||
$this->assertTrue($versionSvc->isGreaterThan($newVersion, $currentVersion));
|
$newVersion = array_key_first($set);
|
||||||
|
$currentVersion = $set[$newVersion];
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
$versionSvc->isGreaterThan($newVersion, $currentVersion),
|
||||||
|
"{$newVersion} not greater than ${currentVersion}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user