[Bb-trac] [bbPress] #1063: plugin detection should only look at file headers to prevent false match

bbPress bb-trac at lists.bbpress.org
Thu Apr 2 08:04:39 GMT 2009


#1063: plugin detection should only look at file headers to prevent false match
----------------------+-----------------------------------------------------
 Reporter:  _ck_      |       Owner:          
     Type:  defect    |      Status:  new     
 Priority:  normal    |   Milestone:  1.0-beta
Component:  Back-end  |     Version:  0.9.0.4 
 Severity:  normal    |    Keywords:          
----------------------+-----------------------------------------------------
 `function bb_get_plugin_data` imports the entire plugin with this bit of
 code

 `$plugin_code = implode( '', file( $plugin_file ) );`

 which is a bad idea, not only for performance but because if the string

 "`Plugin Name:`" appears anywhere in the code, it will assume it's a
 plugin that needs activation.

 To speed it up and slow down false matches, how about this:

 `$handle = fopen($plugin_file, "rb"); $plugin_data = fread($handle, 1024);
 fclose($handle);`

 I can't find a single plugin for bbPress (or WordPress) that has a header
 longer than half a K, so 1k should be plenty.

 Some plugins are nearly 100k in size which means the default routine is
 sucking in megabytes of data from the disk which in a NFS environment
 would be bad.

-- 
Ticket URL: <http://trac.bbpress.org/ticket/1063>
bbPress <http://bbpress.org/>
Innovative forum development


More information about the Bb-trac mailing list