Error in line 9 of cas.module
| Project: | CAS |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
I installed the phpCAS package in my server like so:
pear install http://www.ja-sig.org/downloads/cas-clients/php/1.0.1/CAS-1.0.1.tgz
I then downloaded the CAS module for Drupal and attempted to activate it, but received the following error:
Fatal error: require_once() [function.require]: Failed opening required 'CAS/CAS.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/drupal/sites/all/modules/cas/cas.module on line 9
Further investigation showed that the CAS.php file is located at /usr/share/php/CAS.php, so I edited the cas.module file and removed the "CAS/" prefix from the require statement path. After that, the module worked fine.
Is this something that needs fixing?
Thanks!

#1
I have the same problem
#2
I wasn't aware that cas had become available on the pear site. The module sort of assumes you downloaded it manually. I'll try and give this some thought, but there's a pretty big install base that has the cas module installed the other way. I don't want to break it for them. Open to elegant ideas. I suppose I could test for the /usr/share/php but this seems distibution specific. Anyone have some good ideas on how to solve this in a non distribution specific way?
#3
I've done like this:
changed line 9 to:
require_once(_cas_get_CAS_location());added function _cas_get_CAS_location as follows:
function _cas_get_CAS_location() {$path=variable_get('cas_phpCAS_pathname',NULL);
if($path === NULL) {
$search=ini_get('include_path');
$sa=split(':',$search);
foreach($sa as $pa) {
if(file_exists($pa.'/CAS.php')) {
$path=$pa.'/CAS.php';
break;
} else if(file_exists($pa.'/CAS/CAS.php')) {
$path=$pa.'/CAS/CAS.php';
break;
}
}
}
variable_set('cas_phpCAS_pathname',$path);
return $path;
}
Sorry for the indenting...
It works searching CAS.php in the include_path directories first as path/CAS.php then as path/CAS/CAS.php
It saves the results in a db variable for future references.
This could also be done in the install process letting the module only to load the db variable.
#4
I like this as a general concept, but I think I'll want to add this to the CAS settings page so that the user could override it. It could be problematic if things move. I like your detection mechanism for the default, though. If you're willing to tackle the UI, feel free to submit a patch :)
#5
I just tried downloading and installing the CAS module for the first time too. Downloaded from this URL following the readme. http://sourceforge.net/project/showfiles.php?group_id=88445
I tried putting this in sites/all/modules/cas/ and sites/all/modules/cas/CAS and am getting the same "cas.module on line 9" error.
Am I putting this in the right place?
-Tim
#6
I think so CAS.php should be in a folder called CAS that is somewhere in your include path. So inside sites/all/modules/cas you should have a folder CAS, and a CAS.php file in that folder. Does that make sense?
Dave
#7
Hi Dave,
Thanks for the reply. Yeah, that makes sense. I gave that a try and I still get the "Error in line 9 of cas.module". But, I wound up getting it to install okay (I think?)
I got my host to put CAS on my "include path" location....include_path='.:/usr/share/php:/usr/share/pear in the case of the first poster here.
I then got a different error about DB.php and got rid of it after I did this: http://drupal.org/node/192537
It then installed successfully. But, I still can't get CAS login to work for me. I don't know if I am not using/configuring it correctly or what. I'm not exactly sure what's supposed to happen next. But, that's a separate issue, haha! I'll start a different thread for that.
Thanks!
-Tim