We are getting the following error when running drush rr:

WD php: Error: Call to undefined function drupal_get_path_alias() in url() (line 2308 of [error]
.../includes/common.inc).
Error: Call to undefined function drupal_get_path_alias() in url() (line 2308 of .../includes/common.inc).
Drush command terminated abnormally due to an unrecoverable error. [error]

The problem started with commit 29bb82d. The error is fixed by removing this line:

bootstrap_invoke_all('registry_rebuild');

Issue fork drupal-2842762

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Liam Morland created an issue. See original summary.

Liam Morland’s picture

Title: Call to undefined function drupal_get_path_alias() » Call to undefined function drupal_get_path_alias() in url()
Project: Registry Rebuild » Drupal core
Version: 7.x-2.3 » 7.x-dev
Component: Code » base system
Priority: Major » Normal
Status: Active » Needs review
FileSize
572 bytes

This is actually a core bug. url() calls drupal_get_path_alias(), but it is not certain that /includes/path.inc, which defines drupal_get_path_alias(), will have been included when this happens, leading to an undefined function error. Patch attached.

Status: Needs review » Needs work
zipymonkey’s picture

I've notice the same error using the drush rr command on some sites but not others. The patch in #2 resolved this issue for me.

Liam Morland’s picture

The PHP 7 test failures do not appear to be related to the patch.

cafuego’s picture

Status: Needs review » Needs work

I hit this issue on a postgres D7 install after I restore a database backup and try to do a registry rebuild.

The patch from #5 works but *only* if I disable redis caching. If I leave redis enabled (configured via settings.php) then drush fails with:

Drush command terminated abnormally due to an unrecoverable error.       [error]
Error: Cannot redeclare drupal_path_initialize() (previously declared
in /srv/www/html/sites/all/modules/contrib/redis/redis.path.inc:36)
in /srv/www/html/includes/path.inc, line 22

Looking at the redis module, it does indeed define a drupal_path_initialize() function, so either this include needs to be conditional *or* the redis config needs to be conditional and check if it's run via drush or not.

Liam Morland’s picture

Status: Needs work » Needs review

The redis module should not be declaring its own versions of Drupal core functions unless it takes care of any issues resulting from doing so. I suggest making a child ticket in the redis queue.

cafuego’s picture

Dunno, if you make that require conditional (eg: if (!function_exists('drupal_get_path_alias')) { } ) it should work in both cases. That logic is used elsewhere in common.inc as well.

cafuego’s picture

I did a little bit more looking and found what looks like a nice solution in #2474499: Conflict with Redis module.

Updated patch attached - this one does work for me locally with redis configured and without it on PHP7/PgSQL 9.5.

jenlampton’s picture

Priority: Normal » Critical

Hi all, and thanks for sleuthing out this problem. I had been checking my contrib modules for calls to url() in hook_init() or hook_boot() but didn't think about potentially fixing url() itself!

I'm going to upgrade this ticket's Priority to Critical as these php fatals were causing intermittent downtime for my site.

I've applied the patch in #10 and it seems to be working so far, but I'd like to let the site run for a whole day to see if any additional errors appear.

jenlampton’s picture

Priority: Critical » Major

Update: The problem I ran into was actually caused by the Acquia purge module which registered a shutdown function that happened to call core functions. Since Drupal isn't always fully bootstrapped during the shutdown runtime phase I was getting PHP fatals that caused site downtime.

Applying the patch here fixed part of the problem, and enabled me to find the rest of the contrib code that was causing my problems.

I'm lowering the priority of this ticket from Critical to Major, because even though this problem was causing downtime for my site - it wasn't core's fault. Core could still prevent the downtime in some cases, however, so I'm leaving the status at Major.

ZenDoodles’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #14 also fixed this for me. Thanks!

I can haz test(s)?

cafuego’s picture

I mean, the patch doesn't break core Path alias tests?

Path alias functionality 135 passes, 0 fails, and 0 exceptions

Can't really make the core tests depend on a contrib module, unless you mean make a failing test when path_inc is set?

cafuego’s picture

Just a heads-up, if you're using (or have inherited) path_alias_xt module with the patch to core path.inc applied, you will need to patch your redis.path.inc as well.

jenlampton’s picture

Patch in #14 still applies cleanly to 7.70, 7.71, 7.72, 7.73, 7.74 and 7.75.

izmeez’s picture

Was added to #3179845: [meta] Priorities for 2020-12-02 bugfix release of Drupal 7.76 / 7.77 on weekend to raise it's visibility, did not make the cut for next release this week but might in 3 months.

jenlampton’s picture

Thanks for the update @izmeez! Patch in #14 still applies cleanly to 7.77.

Liam Morland’s picture

Created merge request with the patch in #14.

jenlampton’s picture

Patch in #14 still applies to 7.78.

Liam Morland’s picture

Rebased.

mcdruid’s picture

Is this problem always caused by contrib (or custom) code?

I see several modules mentioned; I believe the problem @jenlampton mentioned in #12 has since been fixed in Acquia Purge. Redis has also been mentioned a few times.

Is this core's problem to solve or are we talking about "babysitting" broken code from elsewhere?

Liam Morland’s picture

It is core that is calling drupal_get_path_alias() so core should be responsible for making sure that function is available.

Liam Morland’s picture

Rebased.

  • mcdruid committed 619286b on 7.x
    Issue #2842762 by Liam Morland, cafuego, jenlampton, ZenDoodles: Call to...
mcdruid’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all!

Status: Fixed » Closed (fixed)

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