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);

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

robcarr created an issue. See original summary.

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

ndf’s picture

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

maxilein’s picture

I get this error too.

maxilein’s picture

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)

maxilein’s picture

Title: Deprecated Code Errors(realpath) » Deprecated Code Errors(realpath) php 8.1

  • ndf committed 284dc691 on 8.x-1.x
    #3338658 by robcarr, maxilein, ndf: Deprecated Code Errors(realpath) php...
ndf’s picture

Status: Active » Fixed

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

Status: Fixed » Closed (fixed)

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