- Issue created by @eduardo morales alberti
- @eduardo-morales-alberti opened merge request.
- Status changed to Needs review
over 1 year ago 7:38am 27 February 2023 - 🇺🇸United States duckydan
I had to change lines 37-43 of svg_image/src/Plugin/Field/FieldFormatter/SvgImageUrlFormatter.php
to
/** * {@inheritdoc} */ public function __construct($pluginId, $pluginDefinition, FieldDefinitionInterface $fieldDefinition, array $settings, $label, $viewMode, array $thirdPartySettings, EntityStorageInterface $ImageStyleStorage, AccountInterface $currentUser, FileUrlGeneratorInterface $fileUrlGenerator) { parent::__construct($pluginId, $pluginDefinition, $fieldDefinition, $settings, $label, $viewMode, $thirdPartySettings, $currentUser, $ImageStyleStorage); $this->fileUrlGenerator = $fileUrlGenerator; }
Then it works fine.
- 🇺🇸United States carsoncho Kansas City, MO
I'm running into the exact same issue using Drupal core 9.4.12 and svg_image 3.0.1. Here's a patch based off the MR.
- 🇦🇺Australia silverham
This error is also preventing form from on saving my Drupal views. Please commit fix.
Views error:
The website encountered an unexpected error. Please try again later. TypeError: Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter::__construct(): Argument #8 ($current_user) must be of type Drupal\Core\Session\AccountInterface, Drupal\image\ImageStyleStorage given, called in /app/build/web/modules/contrib/svg_image/src/Plugin/Field/FieldFormatter/SvgImageUrlFormatter.php on line 41 in Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter->__construct() (line 78 of core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php). Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter->__construct('image_url', Array, Object, Array, '', '_custom', Array, Object, Object) (Line: 41) Drupal\svg_image\Plugin\Field\FieldFormatter\SvgImageUrlFormatter->__construct('image_url', Array, Object, Array, '', '_custom', Array, Object, Object, Object) (Line: 59) Drupal\svg_image\Plugin\Field\FieldFormatter\SvgImageUrlFormatter::create(Object, Array, 'image_url', Array) (Line: 64) Drupal\Core\Field\FormatterPluginManager->createInstance('image_url', Array) (Line: 126) Drupal\Core\Field\FormatterPluginManager->getInstance(Array) (Line: 1002) Drupal\views\Plugin\views\field\EntityField->getFormatterInstance() (Line: 1020) Drupal\views\Plugin\views\field\EntityField->calculateDependencies() (Line: 71) Drupal\views\Plugin\views\display\DisplayPluginBase->getPluginDependencies(Object) (Line: 89) Drupal\views\Plugin\views\display\DisplayPluginBase->calculatePluginDependencies(Object, 17) array_walk(Array, Array) (Line: 959) Drupal\views\Plugin\views\display\DisplayPluginBase->calculateDependencies() (Line: 71) Drupal\Core\Config\Entity\ConfigEntityBase->getPluginDependencies(Object) (Line: 89) Drupal\Core\Config\Entity\ConfigEntityBase->calculatePluginDependencies(Object) (Line: 282) Drupal\views\Entity\View->calculateDependencies() (Line: 319) Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object) (Line: 292) Drupal\views\Entity\View->preSave(Object) (Line: 562) Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 517) Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 253) Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object) (Line: 339) Drupal\Core\Entity\EntityBase->save() (Line: 607) Drupal\Core\Config\Entity\ConfigEntityBase->save() (Line: 991) Drupal\views_ui\ViewUI->save() (Line: 337) Drupal\views_ui\ViewEditForm->save(Array, Object) call_user_func_array(Array, Array) (Line: 114) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52) Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 592) Drupal\Core\Form\FormBuilder->processForm('view_edit_form', Array, Object) (Line: 320) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48) Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'edit', Array) (Line: 230) Drupal\views_ui\Controller\ViewsUIController->edit(Object, NULL) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50) Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 270) Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 137) Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 709) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
- 🇦🇺Australia silverham
Actually this issue only appears in Drupal 9.4.x. In Drupal 9.5.x/10.x/11.x, the order is correct. Attaching patch to detect version.
- 🇵🇹Portugal Rikkarv
On https://www.drupal.org/project/svg_image/releases/3.0.1 → it says that "Works with Drupal: ^9.3 || ^10".
Shouldn't this be replaced with ^9.5 instead of ^9.3?
- Status changed to Needs work
about 1 year ago 5:13pm 21 September 2023 - 🇮🇳India tdnshah
The patches are not resolving the issue when upgraded to D10, In D10 i am getting the below error
ArgumentCountError: Too few arguments to function Drupal\image\Plugin\Field\FieldFormatter\ImageUrlFormatter::__construct(), 9 passed in /var/www/html/docroot/modules/contrib/svg_image/src/Plugin/Field/FieldFormatter/SvgImageUrlFormatter.php on line 41 and exactly 10 expected in Drupal\image\Plugin\Field\FieldFormatter\ImageUrlFormatter->__construct() (line 74 of core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php).
- Status changed to Needs review
about 1 year ago 8:24pm 21 September 2023 - 🇦🇺Australia silverham
Attaching a new patch that does not override the
__construct()
method, nor does it define the specific parameter order in its owncreate()
method.Rather, it assigns the required extra class property after the class creation by overriding
create()
method, calling the parent create method, then assigning the paramater, so then it is compatible with all versions of Drupal core including Drupal 10. (Thanks to comment #3388971-3: SvgImageUrlFormatter parent construct missing arguments 10 needed 9 passed. → for the pointer).I am closing the duplicate issue in 🐛 SvgImageUrlFormatter parent construct missing arguments 10 needed 9 passed. Active as this patch fixes both issues. Additionally, the reason why the initial patch in the linked ticket does not work is because it defines the parameter order in it's
create()
method, rather reusing the parentcreate()
method. - Status changed to RTBC
about 1 year ago 4:38pm 13 October 2023 - Assigned to imyaro
- Status changed to Fixed
about 1 year ago 5:22am 28 October 2023 Fixed. Thanks, @silverham!
I've also did it for all the Image Formatters.
I will add it into the next release.
Automatically closed - issue fixed for 2 weeks with no activity.