Calling static trait method is deprecated (redux)

Created on 11 September 2024, 8 months ago
Updated 14 September 2024, 8 months ago

Problem/Motivation

On Drupal 10.3.4, I'm getting the error warning below on the edit form form any media items that use oEmbed. I can't dig in at the moment, but I assume the solution is similar to #3278090: Calling static trait method is deprecrated in PHP 8.1 β†’ .

Deprecated function: Calling static trait method Drupal\oembed_providers\Traits\HelperTrait::disabledProviderSecurityWarning is deprecated, it should only be called on a class using the trait in oembed_providers_form_media_type_edit_form_alter() (line 61 of modules/contrib/oembed_providers/oembed_providers.module).
oembed_providers_form_media_type_edit_form_alter(Array, Object, 'media_type_edit_form') (Line: 552)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'media_type_edit_form') (Line: 834)
Drupal\Core\Form\FormBuilder->prepareForm('media_type_edit_form', Array, Object) (Line: 285)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->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: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Visit any oEmbed-based media edit form (e.g. /admin/structure/media/manage/video) to see the warning message.

Proposed resolution

See #3278090: Calling static trait method is deprecrated in PHP 8.1 β†’

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States justcaldwell Austin, Texas

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

Merge Requests

Comments & Activities

  • Issue created by @justcaldwell
  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    It looks like we'll need to remove HelperTrait and just define a procedural function in the module file.

  • Merge request !25Move HelperTrait to vanilla Helper class β†’ (Merged) created by Chris Burge
  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    On second thought, we can just change the trait to a class.

  • Pipeline finished with Skipped
    8 months ago
    #283376
  • Status changed to Fixed 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    @justcaldwell - Thanks for opening this issue!

  • πŸ‡§πŸ‡·Brazil mabho Rio de Janeiro, RJ

    After applying the DIFF made available here (https://git.drupalcode.org/project/oembed_providers/-/merge_requests/25....), I get this exception message:

    The website encountered an unexpected error. Try again later.
    
    Error: Class "Drupal\oembed_providers\Helper" not found in oembed_providers_form_media_type_edit_form_alter() (line 61 of modules/contrib/oembed_providers/oembed_providers.module).
    Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'media_type_edit_form') (Line: 834)
    Drupal\Core\Form\FormBuilder->prepareForm('media_type_edit_form', Array, Object) (Line: 285)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
    Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->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: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
  • πŸ‡ΊπŸ‡ΈUnited States Chris Burge

    @mabho Could you try rebuilding cache?

  • πŸ‡§πŸ‡·Brazil mabho Rio de Janeiro, RJ

    @chris burge: yes, I did clear cache, but the code is still broken after that.

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

Production build 0.71.5 2024