After bootstrapping Drupal programatically and calling node_save, the following error occurs on line 249 of pathauto.module:
PHP Fatal error: Call to undefined function pathauto_get_placeholders()

I worked around it by adding:
require_once(drupal_get_path('module','pathauto').'/pathauto.inc');
immediately after drupal_bootstrap().

Comments

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

_pathauto_include() is called before that execution, so I don't know how this could go wrong. Maybe you're missing the pathauto.inc file?

greggles’s picture

The code in question is:


      _pathauto_include();
      // Get the specific pattern or the default
      if (variable_get('language_content_type_'. $node->type, 0)) {
        $pattern = trim(variable_get('pathauto_node_'. $node->type .'_'. $node->language .'_pattern', FALSE));
      }
      if (empty($pattern)) {
        $pattern = trim(variable_get('pathauto_node_'. $node->type .'_pattern', FALSE));
        if (empty($pattern)) {
          $pattern = trim(variable_get('pathauto_node_pattern', FALSE));
        }
      }
      // Only do work if there's a pattern
      if ($pattern) {
        // Only create an alias if the checkbox was not provided or if the checkbox was provided and is checked
        if (!isset($node->pathauto_perform_alias) || $node->pathauto_perform_alias) {
          $placeholders = pathauto_get_placeholders('node', $node);
          $src = "node/$node->nid";
          $node->path = pathauto_create_alias('node', $op, $placeholders, $src, $node->nid, $node->type, $node->language);
        }
      }

We could potentially optimize a smidgen by moving the _pathauto_include() closer to the pathauto_get_placeholders, but I agree with Dave that it's hard to see how Pathauto is causing this.

Maybe some other module is using pathauto_get_placeholders?

_vid’s picture

I thought I was having a similar issue, but it turns out that I had updated to 6.x-2.0-alpha2 without realizing it.
Here's the error message I get when I try to edit a node:
"Fatal error: Call to undefined function pathauto_pattern_load_by_entity() in /.../sites/all/modules/pathauto/pathauto.inc on line 365"

I reinstalled 6.x-1.4 and everything works again.

So I suppose that could be an issue for 6.x-2.0-alpha2. Let me know if you'd like me to submit it as such.
I'm just happy that 1.4 is working.

Vid

greggles’s picture

@vidr - did you clear the cache after updating? My guess is that this is a menu/cache related issue.

_vid’s picture

Hi greggles,
I did clear the cache, a couple times in fact; I looked back at my install history in terminal and I found that I had updated the pathauto module to 6.x-2.0-alpha2 back on 8/19/10. Which is probably why I couldn't remember doing it.
I'm not sure why I wanted to update to an alpha install on a production site but I did.
I also installed 6.x-2.0-alpha2 on two other sites and they are working fine!

So I think the error was a result of conflict with some other module I installed recently.
Looking at the install history on the site in question; which wasn't showing that error last week, I had installed the latest version of webform_validation on 9-13 and linkchecker on 9-9.

So the error could have been as a result of a conflict with one of those.

Vid

dave reid’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Fixed

Since no one else has been able to duplicate this and it seems like it has resolved itself, then I'm going to mark this as fixed.

Status: Fixed » Closed (fixed)

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

dasjo’s picture

Version: 6.x-1.4 » 7.x-1.0-rc2
Status: Closed (fixed) » Active

pathauto.inc doesn't get included in my case, when i'm using dpm(pathauto_cleanstring(...)) in the php custom code block.

dave reid’s picture

Version: 7.x-1.0-rc2 » 6.x-1.4
Status: Active » Closed (fixed)

You can't just call the pathauto_cleanstring() function and expect it to work. You need to manually include the file otherwise you get an error:
module_load_include('inc', 'pathauto');

Also please use proper issue queue etiquette and do not re-open closed issues.