Problem/Motivation
Trying to use the Node import via file fails because the code still uses the deprecated file_validate function.
https://www.drupal.org/node/3363700
Steps to reproduce
Upload an exported JSON at /admin/content/import/file gets the following error:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "file_validate_extensions" plugin does not exist. Valid plugin IDs for Drupal\Core\Validation\ConstraintManager are: Callback, Blank, NotBlank, Email, Choice, File, Image, PositiveOrZero, IdenticalTo, BlockContentEntityChanged, CKEditor5Element, CKEditor5MediaAndFilterSettingsInSync, CKEditor5EnabledConfigurablePlugins, CKEditor5FundamentalCompatibility, SourceEditingPreventSelfXssConstraint, SourceEditingRedundantTags, StyleSensibleElement, CKEditor5ToolbarItemConditionsMet, CKEditor5ToolbarItem, CKEditor5ToolbarItemDependencyConstraint, UniqueLabelInList, CommentName, DateTimeFormat, FileEncoding, FileExtension, FileExtensionSecure, FileImageDimensions, FileIsImage, FileNameLength, FileSizeLimit, FileUriUnique, FileValidation, LinkAccess, LinkExternalProtocols, LinkNotExistingInternal, LinkType, MenuTreeHierarchy, MenuSettings, PathAlias, TaxonomyHierarchy, ProtectedUserField, RoleExists, UserCancelMethod, UserMailRequired, UserMailUnique, UserName, UserNameUnique, ConfigExists, LangcodeRequiredIfTranslatableValues, RequiredConfigDependencies, Bundle, EntityChanged, EntityHasField, EntityType, EntityUntranslatableFields, ImmutableProperties, ReferenceAccess, ValidReference, ExtensionAvailable, ExtensionExists, ExtensionName, MenuLinkDepth, UniquePathAlias, ValidPath, PluginExists, AllowedValues, AtLeastOneOf, ClassResolver, ComplexData, Count, CountryCode, EntityBundleExists, FullyValidatable, Null, Length, MappingCollection, NotNull, Optional, PrimitiveType, Range, Regex, Required, Sequentially, Serialized, UniqueField, UriHost, Uuid, ValidKeys, ValidSequenceKeys in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /home/wwwuniae/arco/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Proposed resolution
Replace in /node_export/src/Form/NodeImportFile.php line 48 with
$validators = ['FileExtension' => ['extensions' => 'json']];
Issue fork node_export-3565248
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
Anonymous (not verified) commentedjernejmramor made their first commit to this issue’s fork.
Comment #4
Anonymous (not verified) commentedHello,
I've investigated this issue and this happened because file_validate_extensions plugin got deprecated in 10.2 (Changelog for this deprecation : https://www.drupal.org/node/3363700). When testing the proposed solution I encountered on another error where $this was used in a static function in NodeImport service so I've resolved as well. Another thing I've noticed is that module still has compatibility with D9 which was EOL in 2023, so I would also suggest that this gets handled, but in an separate issue.
Comment #5
i-trokhanenkoComment #6
i-trokhanenkoMerged. Thanks!