avoid deprecated function error in drupal_get_path function

Created on 4 April 2024, 8 months ago

Problem/Motivation

When migrating a website to php 8.2 I notice some errors with drupal_get_path() function

Deprecated function: dirname(): Passing null to parameter #1 ($path) of type string is deprecated in drupal_get_path() (line 2970 of /data/www/front-truc.viadirect.com/www/includes/common.inc).

Steps to reproduce

Theses errors may happens when for some reasons an inexistant module or a empty parameter is passed to the function.

Proposed resolution

I propose to strengthen a bit the drupal_get_path function to ensure:

  1. arguments are not empty
  2. result of drupal_get_filename() is not null before passing it to dirname

For sure, tracking the root of the incorrect calls would be better (I've a possible case on menu.inc for example), but this proposal at least ensure to get website working like it worked on earlier versions.

🐛 Bug report
Status

Active

Version

7.0 ⚰️

Component
File system 

Last updated about 3 hours ago

Created by

🇫🇷France ceonizm Marseille

Live updates comments and jobs are added and updated live.
  • PHP 8.2

    The issue particularly affects sites running on PHP version 8.2.0 or later.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024