diff --git a/data/mysql/cleandata.sql b/data/mysql/cleandata.sql index 900106b453c..e0accc71b8d 100644 --- a/data/mysql/cleandata.sql +++ b/data/mysql/cleandata.sql @@ -49,7 +49,7 @@ INSERT INTO `ezcontentclass_attribute` (`can_translate`, `category`, `contentcla INSERT INTO `ezcontentclass_attribute` (`can_translate`, `category`, `contentclass_id`, `data_float1`, `data_float2`, `data_float3`, `data_float4`, `data_int1`, `data_int2`, `data_int3`, `data_int4`, `data_text1`, `data_text2`, `data_text3`, `data_text4`, `data_text5`, `data_type_string`, `id`, `identifier`, `is_information_collector`, `is_required`, `is_searchable`, `placement`, `serialized_data_text`, `serialized_description_list`, `serialized_name_list`, `version`) VALUES (1,'',12,0,0,0,0,10,0,0,0,'','','','',NULL,'ezrichtext',147,'description',0,0,1,2,NULL,NULL,'a:2:{s:6:\"eng-GB\";s:11:\"Description\";s:16:\"always-available\";s:6:\"eng-GB\";}',0); INSERT INTO `ezcontentclass_attribute` (`can_translate`, `category`, `contentclass_id`, `data_float1`, `data_float2`, `data_float3`, `data_float4`, `data_int1`, `data_int2`, `data_int3`, `data_int4`, `data_text1`, `data_text2`, `data_text3`, `data_text4`, `data_text5`, `data_type_string`, `id`, `identifier`, `is_information_collector`, `is_required`, `is_searchable`, `placement`, `serialized_data_text`, `serialized_description_list`, `serialized_name_list`, `version`) VALUES (1,'',12,0,0,0,0,0,0,0,0,'','','','',NULL,'ezbinaryfile',148,'file',0,1,0,3,NULL,NULL,'a:2:{s:6:\"eng-GB\";s:4:\"File\";s:16:\"always-available\";s:6:\"eng-GB\";}',0); INSERT INTO `ezcontentclass_attribute` (`can_translate`, `category`, `contentclass_id`, `data_float1`, `data_float2`, `data_float3`, `data_float4`, `data_int1`, `data_int2`, `data_int3`, `data_int4`, `data_text1`, `data_text2`, `data_text3`, `data_text4`, `data_text5`, `data_type_string`, `id`, `identifier`, `is_information_collector`, `is_required`, `is_searchable`, `placement`, `serialized_data_text`, `serialized_description_list`, `serialized_name_list`, `version`) VALUES (1,'',2,0,0,0,0,255,0,0,0,'','','','','','ezstring',152,'short_title',0,0,1,2,NULL,NULL,'a:2:{s:6:\"eng-GB\";s:11:\"Short title\";s:16:\"always-available\";s:6:\"eng-GB\";}',0); -INSERT INTO `ezcontentclass_attribute` (`can_translate`, `category`, `contentclass_id`, `data_float1`, `data_float2`, `data_float3`, `data_float4`, `data_int1`, `data_int2`, `data_int3`, `data_int4`, `data_text1`, `data_text2`, `data_text3`, `data_text4`, `data_text5`, `data_type_string`, `id`, `identifier`, `is_information_collector`, `is_required`, `is_searchable`, `placement`, `serialized_data_text`, `serialized_description_list`, `serialized_name_list`, `version`) VALUES (1,'',2,0,0,0,0,0,0,0,0,'','','','','','ezauthor',153,'author',0,0,0,3,NULL,NULL,'a:2:{s:6:\"eng-GB\";s:6:\"Author\";s:16:\"always-available\";s:6:\"eng-GB\";}',0); +INSERT INTO `ezcontentclass_attribute` (`can_translate`, `category`, `contentclass_id`, `data_float1`, `data_float2`, `data_float3`, `data_float4`, `data_int1`, `data_int2`, `data_int3`, `data_int4`, `data_text1`, `data_text2`, `data_text3`, `data_text4`, `data_text5`, `data_type_string`, `id`, `identifier`, `is_information_collector`, `is_required`, `is_searchable`, `placement`, `serialized_data_text`, `serialized_description_list`, `serialized_name_list`, `version`) VALUES (1,'',2,0,0,0,0,1,0,0,0,'','','','','','ezauthor',153,'author',0,0,0,3,NULL,NULL,'a:2:{s:6:\"eng-GB\";s:6:\"Author\";s:16:\"always-available\";s:6:\"eng-GB\";}',0); INSERT INTO `ezcontentclass_attribute` (`can_translate`, `category`, `contentclass_id`, `data_float1`, `data_float2`, `data_float3`, `data_float4`, `data_int1`, `data_int2`, `data_int3`, `data_int4`, `data_text1`, `data_text2`, `data_text3`, `data_text4`, `data_text5`, `data_type_string`, `id`, `identifier`, `is_information_collector`, `is_required`, `is_searchable`, `placement`, `serialized_data_text`, `serialized_description_list`, `serialized_name_list`, `version`) VALUES (1,'',2,0,0,0,0,0,0,0,0,'','','','','','ezobjectrelation',154,'image',0,0,1,7,NULL,NULL,'a:2:{s:6:\"eng-GB\";s:5:\"Image\";s:16:\"always-available\";s:6:\"eng-GB\";}',0); INSERT INTO `ezcontentclass_attribute` (`can_translate`, `category`, `contentclass_id`, `data_float1`, `data_float2`, `data_float3`, `data_float4`, `data_int1`, `data_int2`, `data_int3`, `data_int4`, `data_text1`, `data_text2`, `data_text3`, `data_text4`, `data_text5`, `data_type_string`, `id`, `identifier`, `is_information_collector`, `is_required`, `is_searchable`, `placement`, `serialized_data_text`, `serialized_description_list`, `serialized_name_list`, `version`) VALUES (1,'',1,NULL,NULL,NULL,NULL,100,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'ezstring',155,'short_name',0,0,1,2,'N;','a:0:{}','a:1:{s:6:\"eng-GB\";s:10:\"Short name\";}',0); INSERT INTO `ezcontentclass_attribute` (`can_translate`, `category`, `contentclass_id`, `data_float1`, `data_float2`, `data_float3`, `data_float4`, `data_int1`, `data_int2`, `data_int3`, `data_int4`, `data_text1`, `data_text2`, `data_text3`, `data_text4`, `data_text5`, `data_type_string`, `id`, `identifier`, `is_information_collector`, `is_required`, `is_searchable`, `placement`, `serialized_data_text`, `serialized_description_list`, `serialized_name_list`, `version`) VALUES (1,'',1,NULL,NULL,NULL,NULL,20,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'ezrichtext',156,'description',0,0,1,4,'N;','a:0:{}','a:1:{s:6:\"eng-GB\";s:11:\"Description\";}',0); diff --git a/eZ/Publish/API/Repository/Tests/FieldType/AuthorIntegrationTest.php b/eZ/Publish/API/Repository/Tests/FieldType/AuthorIntegrationTest.php index 529c262bf59..9c53d044b80 100644 --- a/eZ/Publish/API/Repository/Tests/FieldType/AuthorIntegrationTest.php +++ b/eZ/Publish/API/Repository/Tests/FieldType/AuthorIntegrationTest.php @@ -42,7 +42,7 @@ public function getSettingsSchema() return array( 'defaultAuthor' => array( 'type' => 'choice', - 'default' => Type::DEFAULT_CURRENT_USER, + 'default' => Type::DEFAULT_VALUE_EMPTY, ), ); } @@ -55,7 +55,7 @@ public function getSettingsSchema() public function getValidFieldSettings() { return array( - 'defaultAuthor' => Type::DEFAULT_CURRENT_USER, + 'defaultAuthor' => Type::DEFAULT_VALUE_EMPTY, ); } diff --git a/eZ/Publish/Core/FieldType/Author/Type.php b/eZ/Publish/Core/FieldType/Author/Type.php index fe433332f84..8d714e701f4 100644 --- a/eZ/Publish/Core/FieldType/Author/Type.php +++ b/eZ/Publish/Core/FieldType/Author/Type.php @@ -23,21 +23,21 @@ class Type extends FieldType { /** - * Flag which stands for prefilling Author FieldType with current user by default. + * Flag which stands for setting Author FieldType empty by default. * It is used in a Content Type edit view. */ - const DEFAULT_CURRENT_USER = 1; + const DEFAULT_VALUE_EMPTY = 0; /** - * Flag which stands for setting Author FieldType empty by default. + * Flag which stands for prefilling Author FieldType with current user by default. * It is used in a Content Type edit view. */ - const DEFAULT_EMPTY = -1; + const DEFAULT_CURRENT_USER = 1; protected $settingsSchema = [ 'defaultAuthor' => [ 'type' => 'choice', - 'default' => self::DEFAULT_CURRENT_USER, + 'default' => self::DEFAULT_VALUE_EMPTY, ], ]; @@ -234,8 +234,8 @@ private function validateSettingName($name) private function validateDefaultAuthorSetting($name, $value) { $definedValues = [ + self::DEFAULT_VALUE_EMPTY, self::DEFAULT_CURRENT_USER, - self::DEFAULT_EMPTY, ]; if (!in_array($value, $definedValues, true)) { diff --git a/eZ/Publish/Core/FieldType/Tests/AuthorTest.php b/eZ/Publish/Core/FieldType/Tests/AuthorTest.php index da21c768d80..13b1b01b8c5 100644 --- a/eZ/Publish/Core/FieldType/Tests/AuthorTest.php +++ b/eZ/Publish/Core/FieldType/Tests/AuthorTest.php @@ -75,7 +75,7 @@ protected function getSettingsSchemaExpectation() return array( 'defaultAuthor' => array( 'type' => 'choice', - 'default' => AuthorType::DEFAULT_CURRENT_USER, + 'default' => AuthorType::DEFAULT_VALUE_EMPTY, ), ); } @@ -356,7 +356,7 @@ public function provideValidFieldSettings() ), array( array( - 'defaultAuthor' => AuthorType::DEFAULT_EMPTY, + 'defaultAuthor' => AuthorType::DEFAULT_VALUE_EMPTY, ), ), array( diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/FieldValue/Converter/AuthorConverter.php b/eZ/Publish/Core/Persistence/Legacy/Content/FieldValue/Converter/AuthorConverter.php index d105b83add9..b9208e84c88 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/FieldValue/Converter/AuthorConverter.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/FieldValue/Converter/AuthorConverter.php @@ -8,7 +8,6 @@ */ namespace eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter; -use eZ\Publish\Core\FieldType\Author\Type as AuthorType; use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter; use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue; use eZ\Publish\Core\FieldType\FieldSettings; @@ -76,7 +75,7 @@ public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefin { $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings( [ - 'defaultAuthor' => $storageDef->dataInt1 ? $storageDef->dataInt1 : AuthorType::DEFAULT_CURRENT_USER, + 'defaultAuthor' => $storageDef->dataInt1, ] ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/AuthorTest.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/AuthorTest.php index 4463d928931..0497c049952 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/AuthorTest.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/AuthorTest.php @@ -162,7 +162,7 @@ public function testToStorageFieldDefinitionDefaultEmpty() $fieldTypeConstraints = new FieldTypeConstraints(); $fieldTypeConstraints->fieldSettings = new FieldSettings( array( - 'defaultAuthor' => AuthorType::DEFAULT_EMPTY, + 'defaultAuthor' => AuthorType::DEFAULT_VALUE_EMPTY, ) ); $fieldDef = new SPIFieldDefinition( @@ -173,7 +173,7 @@ public function testToStorageFieldDefinitionDefaultEmpty() $this->converter->toStorageFieldDefinition($fieldDef, $storageFieldDef); self::assertSame( - AuthorType::DEFAULT_EMPTY, + AuthorType::DEFAULT_VALUE_EMPTY, $storageFieldDef->dataInt1 ); } diff --git a/eZ/Publish/Core/REST/Common/FieldTypeProcessor/AuthorProcessor.php b/eZ/Publish/Core/REST/Common/FieldTypeProcessor/AuthorProcessor.php index 4b7feff01b8..a0e120a2dfd 100644 --- a/eZ/Publish/Core/REST/Common/FieldTypeProcessor/AuthorProcessor.php +++ b/eZ/Publish/Core/REST/Common/FieldTypeProcessor/AuthorProcessor.php @@ -20,11 +20,11 @@ public function preProcessFieldSettingsHash($incomingSettingsHash) { if (isset($incomingSettingsHash['defaultAuthor'])) { switch ($incomingSettingsHash['defaultAuthor']) { - case 'DEFAULT_EMPTY': - $incomingSettingsHash['defaultAuthor'] = Type::DEFAULT_EMPTY; + case 'DEFAULT_CURRENT_USER': + $incomingSettingsHash['defaultAuthor'] = Type::DEFAULT_CURRENT_USER; break; default: - $incomingSettingsHash['defaultAuthor'] = Type::DEFAULT_CURRENT_USER; + $incomingSettingsHash['defaultAuthor'] = Type::DEFAULT_VALUE_EMPTY; } } @@ -38,11 +38,11 @@ public function postProcessFieldSettingsHash($outgoingSettingsHash) { if (isset($outgoingSettingsHash['defaultAuthor'])) { switch ($outgoingSettingsHash['defaultAuthor']) { - case Type::DEFAULT_EMPTY: - $outgoingSettingsHash['defaultAuthor'] = 'DEFAULT_EMPTY'; + case Type::DEFAULT_CURRENT_USER: + $outgoingSettingsHash['defaultAuthor'] = 'DEFAULT_CURRENT_USER'; break; default: - $outgoingSettingsHash['defaultAuthor'] = 'DEFAULT_CURRENT_USER'; + $outgoingSettingsHash['defaultAuthor'] = 'DEFAULT_VALUE_EMPTY'; } } diff --git a/eZ/Publish/Core/REST/Common/Tests/FieldTypeProcessor/AuthorProcessorTest.php b/eZ/Publish/Core/REST/Common/Tests/FieldTypeProcessor/AuthorProcessorTest.php index e43a160f1d4..132f4629f50 100644 --- a/eZ/Publish/Core/REST/Common/Tests/FieldTypeProcessor/AuthorProcessorTest.php +++ b/eZ/Publish/Core/REST/Common/Tests/FieldTypeProcessor/AuthorProcessorTest.php @@ -14,8 +14,8 @@ class AuthorProcessorTest extends TestCase { protected $constants = [ + 'DEFAULT_VALUE_EMPTY', 'DEFAULT_CURRENT_USER', - 'DEFAULT_EMPTY', ]; public function fieldSettingsHashes() diff --git a/eZ/Publish/SPI/Tests/FieldType/AuthorIntegrationTest.php b/eZ/Publish/SPI/Tests/FieldType/AuthorIntegrationTest.php index 2b8e2d220cf..818820bacbe 100644 --- a/eZ/Publish/SPI/Tests/FieldType/AuthorIntegrationTest.php +++ b/eZ/Publish/SPI/Tests/FieldType/AuthorIntegrationTest.php @@ -92,7 +92,7 @@ public function getFieldDefinitionData() array( 'fieldSettings' => new FieldType\FieldSettings( array( - 'defaultAuthor' => 1, + 'defaultAuthor' => 0, ) ), )