3

When trying to run a custom module script triggered by the use of a 'one time login' sent by an email for users to reset their passwords I have to include 'user.pages.inc'

This is the URL (edited for anonymity, I hope)

MYSITE/user/THE-USERS-UID/edit?pass-reset-token=DR8wV7YGtmp5Ia8HQvU1YMs94IRBHsa7-lubQuaLTNs

I started off with this:

module_load_include('inc', 'user', 'user.pages');

but that leads to this error when I do finally get to the include in the script.

Fatal error: require_once(): Failed opening required '/var/www/html//user.pages.inc' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/includes/menu.inc on line 515

I imagine this /var/www/html//user.pages.inc might well be where the problem lies as that location definitely doesn't exist, but 1) I'm not sure 2) I don't know how that would be occurring or how to fix it.

It was working fine on my development environment, then when it didn't run on the production environment I tried...

include_once DRUPAL_ROOT . 'modules/user/user.pages.inc';
//module_load_include('inc', 'user', 'user.pages');

which also lead to the same error

I got onto the thread of pear being important etc. (http://ubuntuforums.org/showthread.php?t=1025510)

I followed some guides on installation and set it up....

https://stackoverflow.com/questions/5428778/installing-pear

http://pear.php.net/manual/en/installation.checking.php

The original php.ini....

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: "/path1:/path2"
;include_path = ".:/usr/share/php"

became this...

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: "/path1:/path2"
include_path = ".:/usr/share/php:/usr/share/pear/PEAR"
;

I restarted apache service httpd restart

My error message is now...

Fatal error: require_once(): Failed opening required '/var/www/html//user.pages.inc' (include_path='.:/php/includes:/usr/share/pear') in /var/www/html/includes/menu.inc on line 515

I did some more checking...

# pear config-get php_dir
/usr/share/pear

# php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed:      /etc/php.d/curl.ini,
/etc/php.d/dom.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/gd.ini,
/etc/php.d/json.ini,
/etc/php.d/mbstring.ini,
/etc/php.d/mcrypt.ini,
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
/etc/php.d/phar.ini,
/etc/php.d/sqlite3.ini,
/etc/php.d/wddx.ini,
/etc/php.d/xmlreader.ini,
/etc/php.d/xmlwriter.ini,
/etc/php.d/xsl.ini,
/etc/php.d/zip.ini

I've since written a php info file which tells me this...

include_path .:/php/includes:/usr/share/pear .:/php/includes:/usr/share/pear

I've confirmed that /modules/user/user.pages.inc DOES exist (it's core anyway, right?)

and my other scripts are working (at least they seem to be?!)

By the way - I'm having to include the user.pages.inc because 'user_profile_form' isn't included for some reason.

I lost the drupal.org link to a topic that was set as closed because it's 'working as intended' but here's a token stackoverflow post that might help explain what I mean: https://stackoverflow.com/questions/6572882/drupal-7-insert-user-profile-form-into-a-page

I've just started looking into the idea that it's a permissions problem, but the rest of the codebase seems to have the same 644 permissions and that's running fine.

EDIT: I'm also using Domain Access, but a colleague set that up and is away so I'm not sure if that's relevant at all but I thought I'd point it out.

I've also cleared Drupal's caches

I didn't emphasise it originally but it's important to note that the trigger for this fatal error comes when I use the one-time-only password reset URL that leads to the error. When a user requests a password reset, it is the link from the email sent out that I've been pasting in which has lead to the error. However this is integral, so removing it is not an option (plus it worked on my development environment...)

It leads the user to the hook_menu() in user.module which I've hijacked with hook_admin_menu_alter() in my custom module (MYMODULE) for a bespoke area of the site that required dynamic redirection after.

$items['user/reset/%/%/%'] = array(
    'title' => 'Reset password',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('MYMODULE_user_pass_reset', 2, 3, 4),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
);

Because as you'll see below, the original user_pass_reset callback uses a drupal_goto() and therefore I can't redirect as I would by hooking the form and using redirect (or by adding another submit handler)

  if ($account->login && $current - $timestamp > $timeout) {
    drupal_set_message(t('You have tried to use a one-time login link that has 
expired. Please request a new one using the form below.'));
    drupal_goto('user/password');
  }

So I created an almost duplicate version of it, except for the edit to the above which now retrieves the last place the user tried to go, before resetting their password, from the db and supplying that in the drupal_goto() parameters.

  • Hello. Could you please paste your last edit as an answer? Answering question in it's body is not in the spirit of Q&A site. – Mołot Aug 23 '13 at 14:30
  • Hi, no please don't misunderstand (my bad english there, sorry) It's not the answer, it's just it might be a key part of why the error has occured (because I don't know much about those one-time-only emails) - will edit for clarity – ja_him Aug 23 '13 at 14:32
  • Well it's not like my own English skill is any good ;) And it sure looked like you have solved the problem. If it persists after you fixed that one, it sure requires more work. – Mołot Aug 23 '13 at 14:34
  • Yep, still no luck, although now I've understood more about where the problem lies! :) – ja_him Aug 23 '13 at 14:44
  • I've also posted the following at drupal.org (sorry mods if this isn't OK) which might help to reiterate the problem without drowning my question post with detail drupal.org/node/2072769 – ja_him Aug 23 '13 at 15:37
1

You should implement hook_menu_alter to alter the data of menu items.

This hook is invoked by menu_router_build(). The menu definitions are passed in by reference. Each element of the $items array is one item returned by a module from hook_menu. Additional items may be added, or existing items altered.

code snippets

function custom_menu_alter(&$items) {

  $items['user/reset/%/%/%']['page arguments'] = array('MYMODULE_user_pass_reset', 2, 3, 4);
  $items['user/reset/%/%/%']['file'] = '';
}
  • Unless I'm being stupid, this doesn't in any way answer my question. Is this automated posting? – ja_him Sep 18 '13 at 8:30
  • As you mentioned that you implement "hook_admin_menu_alter()" into your code and I did not find this hook in Drupal api. So, I suggest you to use another hook_menu_alter(&$itemes) to alter the menu item. – Jayendra Kainthola Sep 19 '13 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.