[Bb-trac] Re: [bbPress] #810: You can't activate plugins

bbPress bb-trac at lists.bbpress.org
Mon Mar 10 18:35:37 GMT 2008


#810: You can't activate plugins
----------------------------+-----------------------------------------------
 Reporter:  da3rX           |        Owner:                   
     Type:  defect          |       Status:  new              
 Priority:  normal          |    Milestone:  0.9              
Component:  Administration  |      Version:  1.0-alpha (trunk)
 Severity:  normal          |   Resolution:                   
 Keywords:                  |  
----------------------------+-----------------------------------------------
Comment (by da3rX):

 There seems to be a bug in '''admin-functions.php'''
 '''bb_get_plugin_data''' function.


 {{{
 if (substr($plugin_file, 0, strlen(BB_CORE_PLUGIN_DIR)) ==
 BB_CORE_PLUGIN_DIR) {
         $location = 'core';
 } else {
         $location = 'user';
 }
 }}}

 I added this debug code:

 {{{
 echo '$plugin_file = "' . $plugin_file . '"<br />';
 echo 'substr($plugin_file, 0, strlen(BB_CORE_PLUGIN_DIR)) = "' .
 substr($plugin_file, 0, strlen(BB_CORE_PLUGIN_DIR)) . '"<br />';
 echo 'BB_CORE_PLUGIN_DIR = "' . BB_CORE_PLUGIN_DIR . '"<br />';
 }}}

 ...and it outputs:

 {{{
 $plugin_file = "E:\da3rX\Servers\Root\bbpress-svn/bb-plugins\akismet.php"
 substr($plugin_file, 0, strlen(BB_CORE_PLUGIN_DIR)) =
 "E:\da3rX\Servers\Root\bbpress-svn/bb-plugins\"
 BB_CORE_PLUGIN_DIR = "E:\da3rX\Servers\Root\bbpress-svn/bb-plugins/"
 }}}

 There seems to be a conflict between the Linux forward slashes and Windows
 backslashes. As you can see the last slash is different and that makes the
 comparison to fail, so it thinks the plugin is located in the user folder.
 I'm not sure how to fix this in PHP, but i know that Java has a predefined
 system property  called ''file.separator''.

 A quick and dirty fix for this would be just to strip the last character
 from both of the strings before comparing them:

 {{{
 if (substr($plugin_file, 0, strlen(BB_CORE_PLUGIN_DIR) - 1) ==
 substr(BB_CORE_PLUGIN_DIR, 0, strlen(BB_CORE_PLUGIN_DIR) - 1)) {
         $location = 'core';
 } else {
         $location = 'user';
 }
 }}}

 Probably not the best one, but hey, it works. :)

-- 
Ticket URL: <http://trac.bbpress.org/ticket/810#comment:6>
bbPress <http://bbpress.org/>
Innovative forum development


More information about the Bb-trac mailing list