Deprecated code warning when inserting images

Created on 2 June 2023, about 1 year ago
Updated 14 December 2023, 7 months ago

Problem/Motivation

When inserting images in Presentations, I am seeing the following code deprecation warning...

Deprecated function: Constant FILTER_SANITIZE_STRING is deprecated in H5peditorFile->__construct() (line 14 of vendor/h5p/h5p-editor/h5peditor-file.class.php).
H5peditorFile->__construct(Object) (Line: 160)
H5PEditorAjax->fileUpload('242') (Line: 134)
H5PEditorAjax->action('files', 'dfb8ee5138487', '242') (Line: 88)
Drupal\h5peditor\Controller\H5PEditorAJAXController->filesCallback('dfb8ee5138487', '242')
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: 270)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 226)
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: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
🐛 Bug report
Status

Needs review

Version

2.0

Component

Miscellaneous

Created by

🇬🇧United Kingdom SirClickALot Somerset

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

Comments & Activities

  • Issue created by @SirClickALot
  • 🇬🇧United Kingdom SirClickALot Somerset

    EDIT: This is not just in Presentations, it appears to happen in multiple different H5P content types.

  • Status changed to Needs review about 1 year ago
  • 🇬🇧United Kingdom SirClickALot Somerset

    Thanks @Adil_Siddiqui , patch in #3 seems to have fixed it.

  • Status changed to RTBC about 1 year ago
  • 🇮🇳India keshav.k

    Patch is good to merge.

  • 🇨🇦Canada ryanrobinson_wlu

    I can replicate this problem (PHP 8.1 tests). Patch worked after adding it to my composer.json like this, updating the h5p/h5p-editor package in vendor, not patching the Drupal module:

            "patches": {
                "h5p/h5p-editor": {
                    "Drupal issue 3364451: Fixed file upload error for PHP 8.1": "./patches/h5p_files_3364451-3.patch"
                }
            }
    

    I'm hoping to see all these PHP 8.1 and Drupal 10 patches rolled into a proper release soon.

  • Status changed to Needs review 7 months ago
  • 🇩🇪Germany stefan.korn Jossgrund

    Question is whether FILTER_UNSAFE_RAW is a replacement for FILTER_SANITIZE_STRING. Imho it is not. Reading https://www.php.net/manual/de/filter.filters.sanitize.php the recommendation is to use htmlspecialchars() and FILTER_SANITIZE_FULL_SPECIAL_CHARS is defined as "Equivalent to calling htmlspecialchars() with ENT_QUOTES set". So FILTER_SANITIZE_FULL_SPECIAL_CHARS might be a better replacement as FILTER_UNSAFE_RAW, but it is still not the same as FILTER_SANITIZE_STRING.

    So assuming that FILTER_SANITIZE_STRING was used for a purpose, FILTER_UNSAFE_RAW is probably not fulfilling that purpose.

Production build 0.69.0 2024