Skip to content

Commit 1fc71c2

Browse files
author
Bradie Tilley
committed
Fix MySQL issue where text fields had default values
1 parent 460ae25 commit 1fc71c2

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

models/ImagePermalink.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ public function __toString()
3636
return $this->permalink_url;
3737
}
3838

39+
/**
40+
* Set default for options (empty array) and path (empty string) on save
41+
*
42+
* @return void
43+
*/
44+
public function beforeSave()
45+
{
46+
if (is_null($this->options)) {
47+
$this->options = [];
48+
}
49+
50+
if (is_null($this->path)) {
51+
$this->path = '';
52+
}
53+
}
54+
3955
/**
4056
* Get an ImagePermalink class by the given identifier (and provide
4157
* defaults for when not resized yet: width, height, options)

updates/create_permalinks_table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public function up()
1717
$table->text('image');
1818
$table->string('mime_type');
1919
$table->string('extension');
20-
$table->text('options')->default('{}');
21-
$table->text('path')->nullable()->default(null);
20+
$table->text('options');
21+
$table->text('path');
2222
$table->dateTime('resized_at')->nullable()->default(null);
2323

2424
$table->timestamps();

updates/version.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@
4747
- Added optional permalinks for images to ensure image URLs always yield the same image after cache flushes
4848
- create_permalinks_table.php
4949
2.2.1:
50-
- Fix issue where REMOTE_ADDR server variable is not set when running through CLI
50+
- Fix issue where REMOTE_ADDR server variable is not set when running through CLI
51+
2.2.2:
52+
- Fix MySQL issue where text fields had default values

0 commit comments

Comments
 (0)