Make compatible with Drupal 9/10

Created on 22 February 2023, almost 2 years ago
Updated 19 October 2023, about 1 year ago

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.

🐛 Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

🇳🇿New Zealand RoSk0 Wellington

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @RoSk0
  • 🇳🇿New Zealand RoSk0 Wellington

    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.

  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • 🇳🇿New Zealand RoSk0 Wellington

    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
  • Status changed to Needs work almost 2 years ago
  • 🇮🇳India rassoni Bangalore

    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

  • 🇳🇿New Zealand RoSk0 Wellington

    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.

  • Assigned to omkar_yewale
  • Issue was unassigned.
  • Status changed to RTBC almost 2 years ago
  • 🇮🇳India omkar_yewale Mumbai

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

  • @rashmisoni opened merge request.
  • 🇮🇳India rassoni Bangalore

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

  • 🇳🇿New Zealand ericgsmith

    Rerolling against 3.0.0

    The same issue is present on the 3.0.0 branch - I am rather disheartened that a new 3.0.0 version has been released with this issue still present and no engagement from the maintainers on this issue despite it being RTBC'd for over 6 months.

Production build 0.71.5 2024