Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to clear caches before updating #522

Merged
merged 3 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/Contracts/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace App\Contracts;

use App\Support\Database;
use DB;
use Illuminate\Support\Facades\Log;

/**
* Class Migration
Expand All @@ -23,6 +25,22 @@ public function down()
{
}

/**
* Seed a YAML file into the database
*
* @param string $file Full path to yml file to seed
*/
public function seedFile($file): void
{
try {
$path = base_path($file);
Database::seed_from_yaml_file($path, false);
} catch (\Exception $e) {
Log::error('Unable to load '.$file.' file');
Log::error($e);
}
}

/**
* Add rows to a table
*
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/Admin/MaintenanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function cache(Request $request)
$calls[] = 'config:cache';
$calls[] = 'cache:clear';
$calls[] = 'route:cache';
$calls[] = 'clear-compiled';
}

// If we want to clear only the views but keep everything else
Expand Down
18 changes: 18 additions & 0 deletions app/Services/Installer/InstallerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Services\Installer;

use App\Contracts\Service;
use Illuminate\Support\Facades\Artisan;
use Nwidart\Modules\Facades\Module;

class InstallerService extends Service
Expand Down Expand Up @@ -38,6 +39,23 @@ public function isUpgradePending(): bool
return false;
}

/**
* Clear whatever caches we can by calling Artisan
*/
public function clearCaches(): void
{
$commands = [
'clear-compiled',
'cache:clear',
'route:clear',
'view:clear',
];

foreach ($commands as $cmd) {
Artisan::call($cmd);
}
}

/**
* Disable the installer and importer modules
*/
Expand Down
2 changes: 2 additions & 0 deletions modules/Updater/Http/Controllers/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public function index()
*/
public function step1(Request $request)
{
$this->installerSvc->clearCaches();

if ($this->installerSvc->isUpgradePending()) {
Log::info('Upgrade is pending');
}
Expand Down