Skip to content

Commit afb8008

Browse files
author
Bradie Tilley
committed
Fix migration (2.1.2 migration) that causes installations to fail (due to plugin settings not existing for new projects at time of execution)
1 parent 0073c12 commit afb8008

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

updates/clear_old_cache_dir.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@
33
namespace ABWebDevelopers\Portfolio\Updates;
44

55
use ABWebDevelopers\ImageResize\Classes\Resizer;
6-
use Schema;
7-
use October\Rain\Database\Updates\Migration;
86
use ABWebDevelopers\ImageResize\Models\Settings;
7+
use Illuminate\Support\Facades\DB;
98
use Illuminate\Support\Facades\File;
10-
use Illuminate\Support\Facades\Storage;
9+
use October\Rain\Database\Updates\Migration;
1110

1211
class ClearOldCacheDir extends Migration
1312
{
1413
public function up()
1514
{
16-
$oldpath = base_path('storage/app/media/imageresizecache');
15+
// Check that the settings for this plugin exist
16+
if (DB::table('system_settings')->where('item', 'abwebdevelopers_imageresize')->exists()) {
17+
$oldpath = base_path('storage/app/media/imageresizecache');
1718

18-
if (Settings::instance()->cache_directory !== $oldpath) {
19-
if (is_dir($oldpath)) {
20-
Resizer::clearFiles(null, $oldpath);
19+
if (Settings::instance()->cache_directory !== $oldpath) {
20+
if (is_dir($oldpath)) {
21+
Resizer::clearFiles(null, $oldpath);
2122

22-
File::deleteDirectory($oldpath);
23-
@unlink($oldpath);
23+
File::deleteDirectory($oldpath);
24+
@unlink($oldpath);
25+
}
2426
}
2527
}
2628
}

updates/version.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@
3434
2.1.4:
3535
- Add new Dashboard Widget as an alternative method of clearing the image resize cache
3636
2.1.5:
37-
- Add new setting that runs `imageresize:clear` when `cache:clear` is run (if configured), and fix a Settings bug that was introduced from v2.1.0
37+
- Add new setting that runs `imageresize:clear` when `cache:clear` is run (if configured), and fix a Settings bug that was introduced from v2.1.0
38+
2.1.6:
39+
- Fix migration (2.1.2 migration) that causes installations to fail (due to plugin settings not existing for new projects at time of execution)

0 commit comments

Comments
 (0)