Deprecated Code Errors(realpath) php 8.1

Created on 2 February 2023, almost 2 years ago
Updated 4 February 2023, almost 2 years ago

Problem/Motivation

Multiple warnings of

Deprecated function: realpath(): Passing null to parameter #1 ($path) of type string is deprecated in Drupal\unused_modules\UnusedModulesHelperService::Drupal\unused_modules\{closure}() (line 180 of modules/contrib/unused_modules/src/UnusedModulesHelperService.php).

(Running on 9.5.3)

Offending line is the return [penultimate] line in this extract:

private static function addInfoFileInformation(&$modules = []) {
    // Prepare a composer package list with the install path.
    $packages = array_combine(\Composer\InstalledVersions::getInstalledPackages(), \Composer\InstalledVersions::getInstalledPackages());
    $packages = array_map(function ($package) {
      return realpath(\Composer\InstalledVersions::getInstallPath($package));
    }, $packages);

🐛 Bug report
Status

Fixed

Version

1.4

Component

Code

Created by

🇬🇧United Kingdom robcarr Perthshire, Scotland

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

Comments & Activities

  • Issue created by @robcarr
  • First commit to issue fork.
  • 🇳🇱Netherlands ndf Amsterdam

    It is a php 8.1 deprecation error.
    Good to fix it.

  • 🇦🇹Austria maxilein

    It seems to be working with most modules.
    I get this error for the following modules:

    Could not parse Composer information for module 'bamboo_twig_config'
    Could not parse Composer information for module 'bamboo_twig_extensions'
    Could not parse Composer information for module 'bamboo_twig_file'
    Could not parse Composer information for module 'bamboo_twig_i18n'
    Could not parse Composer information for module 'bamboo_twig_loader'
    Could not parse Composer information for module 'bamboo_twig_path'
    Could not parse Composer information for module 'bamboo_twig_security'
    Could not parse Composer information for module 'bamboo_twig_token'
    Could not parse Composer information for module 'computed_field_example_formatter'
    Could not parse Composer information for module 'computed_field_php_formatter'
    Could not parse Composer information for module 'sophron_guesser'
    Could not parse Composer information for module 'tablefield_cellspan'
    Could not parse Composer information for module 'tablefield_required'
    Could not parse Composer information for module 'views_aggregator_more_functions'

    So how can a module not have a path?
    What is missing in their configuraton/ info file?

    @robcarr: which modules cause your error?

  • 🇦🇹Austria maxilein

    There is also this error:

    Deprecated function: dirname(): Passing null to parameter #1 ($path) of type string is deprecated in Drupal\Core\Extension\Extension->getPath() (line 99 of core/lib/Drupal/Core/Extension/Extension.php).

    Drupal\Core\Extension\Extension->getPath() (Line: 127)
    Drupal\unused_modules\UnusedModulesHelperService::addProjectPath(Array) (Line: 61)
    Drupal\unused_modules\UnusedModulesHelperService::getAvailableModules() (Line: 72)
    Drupal\unused_modules\UnusedModulesHelperService::getEnabledModules() (Line: 19)
    Drupal\unused_modules\UnusedModulesHelperService->getModulesByProject() (Line: 24)
    Drupal\unused_modules\UnusedModulesController->renderProjectsTable('all')
    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: 713)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    • ndf committed 284dc691 on 8.x-1.x
      #3338658 by robcarr, maxilein, ndf: Deprecated Code Errors(realpath) php...
  • Status changed to Fixed almost 2 years ago
  • 🇳🇱Netherlands ndf Amsterdam

    Committed fixes for this and created a new release https://www.drupal.org/project/unused_modules/releases/8.x-1.5

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

Production build 0.71.5 2024