Remove references to include_once
samo - November 6, 2009 - 22:06
| Project: | CAS |
| Version: | HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
References to include_once should be replaced with D6 function module_load_include:
- include_once('modules/ldap_integration/ldapgroups.module');
+ module_load_include('module', 'ldap_integration', 'ldapgroups');

#1
Here's a patch that does this and also uses the correct version of module_invoke for user hooks.
#2
Corrected and committed to head.
#3
getting error after updating to 6.x-2.x-dev 2009-Nov-10
Fatal error: Call to undefined function module_user_invoke() in /net/www/fsd-intranet/sites/all/modules/cas/cas.module on line 336
resolved by changing 336 back to:
module_invoke_all('user', 'login', $edit, $user);
Which also resulted in another error fixed by changing line 958 to:
module_load_include('module', 'ldap_integration', 'ldapauth');
but now landing on the user page when I log in instead of the homepage, regardless of CAS redirect setting.
#4
Forgot to roll a patch. Here's the corrected diff for review and the record.
--- cas.module 9 Nov 2009 20:24:15 -0000 1.59
+++ cas.module 10 Nov 2009 16:08:06 -0000
@@ -1,5 +1,5 @@
<?php
-// $Id: cas.module,v 1.59 2009/11/09 20:24:15 metzlerd Exp $
+// $Id: cas.module,v 1.60 2009/11/10 15:58:51 metzlerd Exp $
/**
* @file Enables users to authenticate via a Central Authentication Service (CAS)
@@ -274,8 +274,9 @@
$user = user_save("", $user_default);
session_save_session(TRUE);
watchdog("user", 'new user: %n (CAS)', array('%n' => $user->name), WATCHDOG_NOTICE, l(t("edit user"), "admin/user/edit/$user->uid"));
+ $edit = array();
if (($user->uid) && ($user->uid > 0) && $cas_authmap) {
- module_user_invoke_( 'login', NULL, $user);
+ user_module_invoke( 'login', $edit, $user);
unset($_SESSION['cas_goto']);
watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
drupal_goto("user/". $user->uid ."/edit");
@@ -333,7 +334,7 @@
if (module_exists('persistent_login') && $_SESSION['cas_remember']) {
$edit['persistent_login'] = 1;
}
- module_user_invoke('login', $edit, $user);
+ user_module_invoke('login', $edit, $user);
drupal_set_message(t(variable_get('cas_login_message', 'Logged in via CAS as %cas_username.'), array('%cas_username' => $user->name)));
if ($edit['persistent_login'] == 1) {
drupal_set_message(t('You will remain logged in on this computer even after you close your browser.'));
@@ -753,7 +754,8 @@
// Destroy the current session:
session_destroy();
- module_user_invoke('user', 'logout', NULL, $user);
+ $edit = array();
+ user_module_invoke( 'logout', $edit, $user);
// We have to use $GLOBALS to unset a global variable:
$user = user_load(array('uid' => 0));
@@ -955,7 +957,7 @@
* LDAP Auxiliary functions
*/
function _get_ldap_config_name($user_name) {
- include_once('modules/ldap_integration/ldapauth.module');
+ module_load_include('module', 'ldap_integration', 'ldapauth');
$user_found = FALSE;
$result = db_query("SELECT name FROM {ldapauth} WHERE status = '%d' ORDER BY sid", 1);
while ($row = db_fetch_object($result)) {
#5
Commited to head and drupal 6 dev. Sorry for the bad commits.
#6
yep, thats fixed it.. thanks metzlerd
#7
Automatically closed -- issue fixed for 2 weeks with no activity.