Circular error created by drupal_get_path() when referring paths inside the same extension

Created on 28 May 2021, about 3 years ago
Updated 25 June 2024, 4 days ago

Problem/Motivation

it is causing weird circular reference problems for me

views_rss.module causing the issue

/**
 * Include file with all preprocess functions.
 */
include_once drupal_get_path('module', 'views_rss_media') .'/views_rss_media.inc';

social_content_block override calls a block function at line 44 of file:
profiles/contrib/social/modules/social_features/social_content_block/src/SocialContentBlockOverride.php

$this->definitions = \Drupal::service('plugin.manager.content_block')->getDefin\
itions();

I think it is calling a block for zoom online that is causing module_load_include in zoom_conference.module to be called in a possible loop

Steps to reproduce

for me it happens at /update.php consistently

Proposed resolution

Avoid drupal_get_path() when referring paths inside the same extension πŸ› Circular error created by drupal_get_path() when referring paths inside the same extension Postponed: needs info | Drupal.org | https://www.drupal.org/project/views_rss/issues/3216220 πŸ› Circular error created by drupal_get_path() when referring paths inside the same extension Postponed: needs info . PHP Deprecated: drupal_get_filename() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use /Drupal/Core/Extension/ExtensionList::getPathname() instead. See  https://www.drupal.org/node/2940438 β†’

https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/functi...

If you're using drupal_get_path in Drupal 8 and are just using it to retrieve the path of your module, try:

$module_handler = Drupal::service('module_handler');
$path = $module_handler->getModule('your_module')->getPath();
As always, if you're in the context of a class, you should inject the 'module_handler' service rather than calling Drupal::service statically.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States SocialNicheGuru

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024