Problem/Motivation

Module doesn't work with Drupal 9.

Proposed resolution

Make compatible with Drupal 9.

Remaining tasks

  • Patch - done
  • Review
  • Commit

User interface changes

None

API changes

None

Data model changes

None

Original description

Problem/Motivation

Clicking the "Add Download option config" link the /admin/config/media/download_options/add page results in :


The website encountered an unexpected error. Please try again later.
Error: Typed property Drupal\file_downloader\Entity\DownloadOptionConfig::$extensions must not be accessed before initialization in Drupal\file_downloader\Entity\DownloadOptionConfig->getExtensions() (line 107 of modules/contrib/file_downloader/src/Entity/DownloadOptionConfig.php).

Drupal\file_downloader\Entity\DownloadOptionConfig->getExtensions() (Line: 108)
Drupal\file_downloader\Form\DownloadOptionConfigForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 534)
Drupal\Core\Form\FormBuilder->retrieveForm('download_option_config_add_form', Object) (Line: 281)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
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: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 38)
Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 713)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Additional info:

  • Drupal version 9.5.3
  • Module version 2.0.1
  • PHP version 8.0.27
  • MySQL version 5.7.29

Steps to reproduce

  • Install the latest 2.0.1version of this module
  • Enable it
  • Navigate to the /admin/config/media/download_options/add page
  • Click the "Add Download option config" link

Proposed resolution

Fix the bug.

Command icon 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

RoSk0 created an issue. See original summary.

rosk0’s picture

Title: Impossible to create "Download Option Config" entity » make compatible with Drupal 9

The problem looked simple at the first glance - not initialised extensions property, but when I fixed this and hit save it told me that config_export is missing on the ConfigEntity, which is this https://www.drupal.org/node/2949023 change record for Drupal 8.6.

Than it thrown TypeError: Drupal\file_downloader\DownloadOptionPluginBase::addContextAssignmentElement(): Argument #1 ($plugin) must be of type Drupal\Core\Plugin\ContextAwarePluginInterface, Drupal\file_downloader\Plugin\DownloadOption\OriginalFile given, called in /app/web/modules/contrib/file_downloader/src/DownloadOptionPluginBase.php on line 118 in Drupal\file_downloader\DownloadOptionPluginBase->addContextAssignmentElement() (line 37 of /app/web/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php) at me on the edit screen...

Fixed that , and than it was time of Error: Call to undefined method Drupal\Core\File\FileSystem::getScheme() in Drupal\file_downloader\DownloadOptionPluginBase->deliver() (line 71 of modules/contrib/file_downloader/src/DownloadOptionPluginBase.php). , which is this https://www.drupal.org/node/3035273 change record for Drupal 8.8...

It looks like this module wasn't tested with Drupal 9 at all...

Will run an full compatibility check a bit later and do some more testing.

rosk0’s picture

Title: make compatible with Drupal 9 » Make compatible with Drupal 9
Assigned: rosk0 » Unassigned
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new7.19 KB

What was done/changed:

  • ContextAwarePluginInterface interface added to the list of implemented by the DownloadOptionPluginBase class (was implemented via ContextAwarePluginTrait)
  • replaced file system service with stream wrapper manager services in DownloadOptionPluginBase and Drupal\file_downloader\Plugin\DownloadOption\ImageStyle classes
  • Extended config entity type annotation with the config_export property , listing all the properties from the configuration schema
  • set default value for the list of allowed extensions for the download option
rassoni’s picture

Status: Needs review » Needs work
StatusFileSize
new179.46 KB
new449.92 KB

Clicking the "Add Download option config" link the /admin/config/media/download_options/add page results in : issue resolved. But when we tried to add any download option then issue are coming.

 The website encountered an unexpected error. Please try again later.

Drupal\Core\Config\Schema\SchemaIncompleteException: Entity type 'Drupal\file_downloader\Entity\DownloadOptionConfig' is missing 'config_export' definition in its annotation in Drupal\Core\Config\Entity\ConfigEntityBase->toArray() (line 253 of core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).
Drupal\Core\Config\Entity\ConfigEntityStorage->mapToStorageRecord(Object) (Line: 273)
Drupal\Core\Config\Entity\ConfigEntityStorage->doSave('small', Object) (Line: 520)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 253)
Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 608)
Drupal\Core\Config\Entity\ConfigEntityBase->save() (Line: 152)
Drupal\file_downloader\Form\DownloadOptionConfigForm->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: 595)
Drupal\Core\Form\FormBuilder->processForm('download_option_config_add_form', Array, Object) (Line: 323)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
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: 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: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19) 

Steps to reproduce

  1. Install the latest 2.0.1version of this module
  2. Enable it
  3. Navigate to the /admin/config/media/download_options/add page

when tried to add any option issues are coming

rosk0’s picture

Have you applied the patch correctly? Have you cleared the cache after that?

I've already tested it on two different code bases - works as expected.

omkar_yewale’s picture

Assigned: Unassigned » omkar_yewale
omkar_yewale’s picture

Assigned: omkar_yewale » Unassigned
Status: Needs work » Reviewed & tested by the community

Thanks for the patch. The patch was applied successfully and is working as expected after clearing the cache.
Moving RTBC.

rassoni’s picture

StatusFileSize
new107.01 KB

Thanks @RoSk0, After clear cache working as expected. Please review screenshot for more reference,hence created MR.

ericgsmith’s picture

Title: Make compatible with Drupal 9 » Make compatible with Drupal 9/10
Version: 2.0.1 » 3.0.0
StatusFileSize
new6.9 KB

Rerolling against 3.0.0

The same issue is present on the 3.0.0 branch - I would encourage engagement from the maintainers on this issue, it would have been fantastic to have it resolved before 3.0.0 was released.

sjerdo made their first commit to this issue’s fork.

sjerdo’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.