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
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:
- 2842762-call-to-undefined changes, plain diff MR !146
Comments
Comment #2
Liam MorlandThis 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.
Comment #4
zipymonkey CreditAttribution: zipymonkey commentedI'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.Comment #5
Liam MorlandReroll
Comment #6
Liam MorlandThe PHP 7 test failures do not appear to be related to the patch.
Comment #7
cafuego CreditAttribution: cafuego at United Nations commentedI 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:
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.
Comment #8
Liam MorlandThe 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.
Comment #9
cafuego CreditAttribution: cafuego at United Nations commentedDunno, 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.Comment #10
cafuego CreditAttribution: cafuego at United Nations commentedI 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.
Comment #11
jenlamptonHi all, and thanks for sleuthing out this problem. I had been checking my contrib modules for calls to
url()
inhook_init()
orhook_boot()
but didn't think about potentially fixingurl()
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.
Comment #12
jenlamptonUpdate: 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.
Comment #14
cafuego CreditAttribution: cafuego at United Nations commentedPoked the patch so it applies to the current 7.x HEAD.
Comment #15
ZenDoodles CreditAttribution: ZenDoodles at Platform.sh commentedPatch in #14 also fixed this for me. Thanks!
I can haz test(s)?
Comment #16
cafuego CreditAttribution: cafuego at United Nations commentedI mean, the patch doesn't break core Path alias tests?
Can't really make the core tests depend on a contrib module, unless you mean make a failing test when path_inc is set?
Comment #17
cafuego CreditAttribution: cafuego at United Nations commentedJust 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.
Comment #18
jenlamptonPatch in #14 still applies cleanly to 7.70, 7.71, 7.72, 7.73, 7.74 and 7.75.
Comment #19
izmeez CreditAttribution: izmeez commentedWas 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.
Comment #20
jenlamptonThanks for the update @izmeez! Patch in #14 still applies cleanly to 7.77.
Comment #22
Liam MorlandCreated merge request with the patch in #14.
Comment #23
jenlamptonPatch in #14 still applies to 7.78.
Comment #24
Liam MorlandRebased.
Comment #25
mcdruidIs 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?
Comment #26
Liam MorlandIt is core that is calling drupal_get_path_alias() so core should be responsible for making sure that function is available.
Comment #27
Liam MorlandRebased.
Comment #29
mcdruidThanks all!