Open Chrisedmo opened 8 years ago
I was just trying out your plug in and exported some fields from a site, then tried to import them via the import tab on the plugin and am getting the following error:
PHP warning array_filter() expects parameter 1 to be array, null given /Users/username/Documents/Sites/website.com/private_html/craft/app/fieldtypes/PositionSelectFieldType.php(61) 49 )); 50 } 51 52 /** 53 * @inheritDoc ISavableComponentType::prepSettings() 54 * 55 * @param array $settings 56 * 57 * @return array 58 */ 59 public function prepSettings($settings) 60 { 61 $settings['options'] = array_keys(array_filter($settings['options'])); 62 return $settings; 63 } 64 65 /** 66 * @inheritDoc IFieldType::getInputHtml() 67 * 68 * @param string $name 69 * @param mixed $value 70 * 71 * @return string 72 */ 73 public function getInputHtml($name, $value) Stack Trace #0 – /Users/username/Documents/Sites/website.com/private_html/craft/app/etc/web/WebApp.php(681): CApplication->handleError(2, "array_filter() expects parameter 1 to be array, null given", "/Users/username/Documents/Sites/website.com/private_html/c...", 61) 676 if (version_compare(PHP_VERSION, '7', '>=') && $code === 2 && strpos($message, 'should be compatible with') !== false) 677 { 678 return; 679 } 680 681 parent::handleError($code, $message, $file, $line); 682 } 683 684 // Private Methods 685 // ========================================================================= 686 #1 unknown(0): Craft\WebApp->handleError(2, "array_filter() expects parameter 1 to be array, null given", "/Users/username/Documents/Sites/website.com/private_html/c...", 61, ...) #2 – /Users/username/Documents/Sites/website.com/private_html/craft/app/fieldtypes/PositionSelectFieldType.php(61): array_filter(null) 56 * 57 * @return array 58 */ 59 public function prepSettings($settings) 60 { 61 $settings['options'] = array_keys(array_filter($settings['options'])); 62 return $settings; 63 } 64 65 /** 66 * @inheritDoc IFieldType::getInputHtml() #3 – /Users/username/Documents/Sites/website.com/private_html/craft/app/services/FieldsService.php(462): Craft\PositionSelectFieldType->prepSettings(null) 457 458 // Get the field type 459 $fieldType = $field->getFieldType(); 460 461 // Give the field type a chance to prep the settings from post 462 $preppedSettings = $fieldType->prepSettings($field->settings); 463 464 // Set the prepped settings on the FieldRecord and the field type 465 $fieldRecord->settings = $preppedSettings; 466 $fieldType->setSettings($preppedSettings); 467 #4 + /Users/username/Documents/Sites/website.com/private_html/craft/app/services/MatrixService.php(183): Craft\FieldsService->validateField(Craft\FieldModel) #5 + /Users/username/Documents/Sites/website.com/private_html/craft/app/services/MatrixService.php(234): Craft\MatrixService->validateBlockType(Craft\MatrixBlockTypeModel) #6 + /Users/username/Documents/Sites/website.com/private_html/craft/plugins/artvandelay/services/ArtVandelay_FieldsService.php(312): Craft\MatrixService->saveBlockType(Craft\MatrixBlockTypeModel) #7 + /Users/username/Documents/Sites/website.com/private_html/craft/plugins/artvandelay/services/ArtVandelay_ImportExportService.php(71): Craft\ArtVandelay_FieldsService->import(array("Default" => array("articleBody" => array("name" => "Article Body", "context" => "global", "instructions" => "", "translatable" => 0, ...), "backgroundColor" => array("name" => "Background Color", "context" => "global", "instructions" => "Hex value for alternate background color.", "translatable" => 0, ...), "body" => array("name" => "Body", "context" => "global", "instructions" => null, "translatable" => 1, ...), "featuredImage" => array("name" => "Featured Image", "context" => "global", "instructions" => "", "translatable" => 0, ...), ...))) #8 + /Users/username/Documents/Sites/website.com/private_html/craft/plugins/artvandelay/services/ArtVandelay_ImportExportService.php(14): Craft\ArtVandelay_ImportExportService->importFromExportedDataModel(Craft\ArtVandelay_ExportedDataModel) #9 + /Users/username/Documents/Sites/website.com/private_html/craft/plugins/artvandelay/controllers/ArtVandelayController.php(39): Craft\ArtVandelay_ImportExportService->importFromJson("{ "assets": [], "categories": [], "fields": { "Default": {...") #10 + /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/actions/CInlineAction.php(49): Craft\ArtVandelayController->actionImportStep3() #11 + /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(array("p" => "admin/artVandelay/import/1")) #12 + /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/CController.php(286): CController->runAction(CInlineAction) #13 + /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(CInlineAction, array()) #14 + /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/web/CWebApplication.php(282): CController->run("importstep3") #15 + /Users/username/Documents/Sites/website.com/private_html/craft/app/etc/web/WebApp.php(811): CWebApplication->runController("artVandelay/importstep3") #16 + /Users/username/Documents/Sites/website.com/private_html/craft/app/etc/web/WebApp.php(281): Craft\WebApp->_processActionRequest() #17 + /Users/username/Documents/Sites/website.com/private_html/craft/app/framework/base/CApplication.php(184): Craft\WebApp->processRequest() #18 + /Users/username/Documents/Sites/website.com/private_html/craft/app/index.php(62): CApplication->run() #19 + /Users/username/Documents/Sites/website.com/public_html/index.php(19): require_once("/Users/username/Documents/Sites/website.com/private_html/c...") 2016-01-14 22:58:22 Apache/2.2.29 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.8 PHP/5.5.18 mod_ssl/2.2.29 OpenSSL/0.9.8zg DAV/2 mod_perl/2.0.8 Perl/v5.20.0 / Craft 2.5.2759
I can confirm that Pull Request #18 works as I have just used that as the plugin and it imported successfully.
I was just trying out your plug in and exported some fields from a site, then tried to import them via the import tab on the plugin and am getting the following error: