I am getting this:
Fatal error: Call to undefined function drupal_urlencode() in /var/www/html/modules/securepages/securepages.module on line 321

When going to a non-secured URL that should be "switched" to a secured URL. It also happens when I go to a "secure" URL that does not need to be secured.

It's important to note that the particular node I am seeing this on is a webform, but I have seen this on other core forms, like the login page, and regular old "Pages".

Also interesting if I remove the page cache for the node, it works the first time around, but then breaks on a reload.

If I input the function (from drupal's api core) into that securepages.module file, I get an already declared function error.

This also only happens for anonymous users, so that leads me to believe that there is some caching issue causing a problem here.

So here's what I got:
Drupal 5.11
Secure Pages 5.x-1.x-dev

Other possibly conflicting modules or enabled functions
Clean URL's are On
Performance Caching is On
Webform 5.x-2.3

So my option is to make a duplicate function with a different name and call it within the module file? Not sure, but I will give it a try.

Comments

beekerstudios’s picture

Inputing this at line 277....

function drupal_urlencode2($text) {
  if (variable_get('clean_url', '0')) {
    return str_replace(array('%2F', '%26', '%23', '//'),
                       array('/', '%2526', '%2523', '/%252F'),
                       rawurlencode($text));
  }
  else {
    return str_replace('%2F', '/', rawurlencode($text));
  }
}

and changing line 331 (previously line 321) to this:

$path = drupal_urlencode2($path);

Resolved the issue, but I think this is pretty much a kludged solution. Longterm this module doesn't know a thing about drupal_urlencode. Doesn't appear to be a caching issue, but is actually a secure pages issue.

beekerstudios’s picture

P.S. Going to the /?q=url/alias did direct to the proper url, prior to this fix, so it may very well be clean url's acting up here too.

alan d.’s picture

I just the same error on Drupal 6.6 using Beta 1

My temp hack was:

<?php

/**
 * Return a querystring without the q paramter
 */
function securepages_get_query($query) {
  unset($query['q']);
  $q = array();
  // NEW
  if (!function_exists('drupal_urlencode')) {
    include_once 'includes/common.inc';
  }
  // END NEW
  foreach ($query as $key => $value) {
    $q[] = drupal_urlencode($key) .'='. drupal_urlencode($value);
  }

  return implode('&', $q);
}

?>

I'm guessing that this is due to the early calls via hook_boot, but I haven't looked into it.

alexmarkley’s picture

I was also getting this error on Drupal 6 using securepages 6.x-1.7-beta1.

PHP Fatal error: Call to undefined function drupal_urlencode() in /home/web/malexmedia/malexmedia/modules/contrib/securepages/securepages.module on line 491

ebeyrent’s picture

I am getting:

Fatal error: Call to undefined function drupal_urlencode() in sites/all/modules/securepages/securepages.module on line 378

I am also seeing:

extract() First argument should be an array in sites/all/modules/securepages/securepages.module on line 128.

alan d.’s picture

Related to the use of hook_boot, try the latest version or use the above hack. This is fixed in 6 version.

grendzy’s picture

Status: Active » Closed (won't fix)

The 5.x branch is no longer supported. If this issue is still present in a current version of Secure Pages, please update the issue summary, change the version field, and re-open the issue.