From b79c5c0e450294595240b574f675bea1f69e8bf3 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Wed, 15 Apr 2020 07:06:37 -0400 Subject: [PATCH] Adjustment to prevent irrelevant error messages from appearing when creating new images field --- wire/modules/Fieldtype/FieldtypeFile.module | 11 +++++++++-- wire/modules/Fieldtype/FieldtypeImage.module | 12 ++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/wire/modules/Fieldtype/FieldtypeFile.module b/wire/modules/Fieldtype/FieldtypeFile.module index 0d131d85..f71da9e0 100644 --- a/wire/modules/Fieldtype/FieldtypeFile.module +++ b/wire/modules/Fieldtype/FieldtypeFile.module @@ -174,7 +174,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule { $this->message( $this->_('Settings have not yet been committed.') . "
" . $this->_('Please review the settings on this page and save once more (even if you do not change anything) to confirm you accept them.') . "", - Notice::allowMarkup); + Notice::allowMarkup | Notice::noGroup); } } @@ -1024,6 +1024,13 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule { $hasDate = $fileSchema & self::fileSchemaDate; $hasTags = $fileSchema & self::fileSchemaTags; $useTags = $field->get('useTags') || $contextField->get('useTags'); + + if(!$hasFilesize || !$hasFiledata || !$hasDate || !$hasTags) { + if(!$database->tableExists($table)) { + // new field being created, getting initial schema to create table + return $fileSchema; + } + } // Filesize update (3.0.154): Adds 'filesize', 'created_users_id', 'modified_users_id' columns if(!$hasFilesize) { @@ -1137,7 +1144,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule { if($database->columnExists($table, $column)) { $result = true; } else { - $this->error("Error adding '$column' to '{$field->name}' schema", Notice::log); + $this->error("Error adding '$column' to '{$field->name}' schema", Notice::log | Notice::debug); unset($schema[$column], $schema['keys'][$column]); $result = false; } diff --git a/wire/modules/Fieldtype/FieldtypeImage.module b/wire/modules/Fieldtype/FieldtypeImage.module index 68b5e364..e10c0708 100644 --- a/wire/modules/Fieldtype/FieldtypeImage.module +++ b/wire/modules/Fieldtype/FieldtypeImage.module @@ -98,10 +98,14 @@ class FieldtypeImage extends FieldtypeFile { if(!$hasDimensions) { $numErrors = 0; - $columns = array('width', 'height', 'ratio'); - foreach($columns as $column) { - if(!$this->addColumn($field, $column, $schema)) $numErrors++; - if($numErrors) break; + if($this->wire('database')->tableExists($field->getTable())) { + $columns = array('width', 'height', 'ratio'); + foreach($columns as $column) { + if(!$this->addColumn($field, $column, $schema)) $numErrors++; + if($numErrors) break; + } + } else { + // new field being created that is getting initial schema to create table } if(!$numErrors) { $fileSchema = $fileSchema | self::fileSchemaDimensions;