chg: [metaTemplate:migrateMetaField] Ignore metafield with empty value
parent
a872379529
commit
27673b54c9
|
@ -226,13 +226,16 @@ class MetaTemplatesController extends AppController
|
|||
foreach ($newestMetaTemplate->meta_template_fields as $i => $newMetaTemplateField) {
|
||||
if ($metaTemplateField->field == $newMetaTemplateField->field && empty($newMetaTemplateField->metaFields)) {
|
||||
$movedMetaTemplateFields[] = $metaTemplateField->id;
|
||||
$nonEmptyMetaFields = array_filter($metaTemplateField->metaFields, function ($e) {
|
||||
return $e->value !== '';
|
||||
});
|
||||
$copiedMetaFields = array_map(function ($e) use ($newMetaTemplateField) {
|
||||
$e = $e->toArray();
|
||||
$e['meta_template_id'] = $newMetaTemplateField->meta_template_id;
|
||||
$e['meta_template_field_id'] = $newMetaTemplateField->id;
|
||||
unset($e['id']);
|
||||
return $e;
|
||||
}, $metaTemplateField->metaFields);
|
||||
}, $nonEmptyMetaFields);
|
||||
$newMetaTemplateField->metaFields = $this->MetaTemplates->MetaTemplateFields->MetaFields->newEntities($copiedMetaFields);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,9 +94,6 @@ class MetaFieldsTable extends AppTable
|
|||
|
||||
public function isValidType($value, $metaTemplateField)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return __('Metafield value cannot be empty.');
|
||||
}
|
||||
$typeHandler = $this->MetaTemplateFields->getTypeHandler($metaTemplateField['type']);
|
||||
if (!empty($typeHandler)) {
|
||||
$success = $typeHandler->validate($value);
|
||||
|
|
|
@ -1305,7 +1305,7 @@ class MetaTemplatesTable extends AppTable
|
|||
$updateStatus['next_version'] = $template['version'];
|
||||
$updateStatus['new'] = false;
|
||||
$updateStatus['automatically-updateable'] = false;
|
||||
if ($metaTemplate->version >= $template['version']) {
|
||||
if (intval($metaTemplate->version) >= intval($template['version'])) {
|
||||
$updateStatus['up-to-date'] = true;
|
||||
$updateStatus['conflicts'][] = __('Could not update the template. Local version is equal or newer.');
|
||||
return $updateStatus;
|
||||
|
|
Loading…
Reference in New Issue