Getting the following error when installing the CBP modulePHP Fatal error: Cannot redeclare drupal_path_initialize() (previously declared in ..../includes/path.inc:18) in ..../sites/all/modules/contrib/redis/redis.path.inc on line 40

I believe its because you're including the path.inc file directly in your execute_cbp_remote_command function. Since redis sets up its own include for caching paths I believe the proper action would be to call from the path_inc variable instead of the inc file directly. Maybe this? :

if (!function_exists('current_path')) { require_once(variable_get('path_inc')); }

I'll test and verify.

Comments

alanpuccinelli created an issue. See original summary.

crystaldawn’s picture

Hmm, idk. From the errors you posted, this looks to be an issue with Redis and nothing to do with CBP at all since it does not redefine any functions. If Redi's is redefining core functions, then the issue should be reported there instead. Not sure why its trying to redefine core functions though since thats generally bad practice in php unless it's within a class and extending a method. Let me know what you find. Adding an if clause to check for a function's existence and running an include is nothing big but redefining of functions is a little different. However, I dont use include. I make sure to use require_once() so that the file is only included once no matter what. If everything is coded properly, there should be no need for the if clause check on the function existence to begin with. The fact that somehting isnt coded properly though is what is causing the problem and thus causing redefinition where there shouldnt be any at all.

DaPooch’s picture

Normally I'd agree with you but in this case I think it has to do with the special circumstances surrounding the Redis module. Redis redefines the caching system and does so by making some less conventional updates to the settings.php file. I can't really say what the best practice is in this situation. There may be other modules that override the functions in the path.inc file which lead to the creation of a distinct path_inc variable... not sure.

I do know that the update I proposed above works for me, but I'm not sure if its best for those with and without the Redis module installed.

crystaldawn’s picture

Ok well there is no reason not to have an if clause there, it wont hurt anything. I can add it in, but there is a possibility that it still wouldnt work for others depending upon the load order of the php files. Example, if redis is included/require_once'd AFTER cbp, then all bets are off :/ Not sure what scenario that would happen in but it could be a possibility. Hopefully it uses require_once and not include() ;) I cant remember the last time I actually used the include() method.

DaPooch’s picture

Redis requires the configuration to go straight into settings.php so if installed properly its includes will supersede any other modules. I think the cleanest thing would be to check for the existence of the path_inc variable, if avail use that, if not then do the include as you've written it, seems like that would cover all the bases.

crystaldawn’s picture

See if this fixes the issue or not, if so, I'll add this in now. The "path_inc" variable was not available on my default D7 so it isnt going to exist for most people. The elseif should cover those of us who do not run Redis.

$inc_path_var = variable_get('path_inc');
   if (!empty($inc_path_var) && !function_exists('current_path')) { require_once($inc_path_var); }

  • crystaldawn committed db9a60e on 7.x-1.x
    Fix 2 minor bugs as reported here:  #2626962 #2626028
    
crystaldawn’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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