Plugins.css refreshes on every request

A place to report and discuss bugs - please mention CMSimple-version, server, platform and browser version
Post Reply
Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Plugins.css refreshes on every request

Post by Holger » Sat Feb 07, 2015 10:08 am

Hi,

there's a little bug in function XH_pluginStylesheet() that causes a regeneration of plugins.css on every request.
Depending on the server filesystem, everything might work on a fresh installation. But after the installation of a new plugin (on a linux host) $expired will always become true.

The code compares an array generated from a comment in plugins.css with the returned array from function XH_plugins():

Example:
$oldPlugins generated from plugins.css:

Code: Select all

array(9) {
  [0]=>
  string(11) "filebrowser"
  [1]=>
  string(6) "hi_CnC"
  [2]=>
  string(14) "hi_updatecheck"
  [3]=>
  string(6) "jquery"
  [4]=>
  string(9) "meta_tags"
  [5]=>
  string(11) "pagemanager"
  [6]=>
  string(11) "page_params"
  [7]=>
  string(7) "tinymce"
  [8]=>
  string(4) "utf8"
}
$plugins from XH_Plugins()

Code: Select all

array(9) {
  [0]=>
  string(11) "filebrowser"
  [8]=> 
  string(6) "hi_CnC"  //  <-- new installed plugin gets key #8
  [1]=>
  string(14) "hi_updatecheck"
  [2]=>
  string(6) "jquery"
  [3]=>
  string(9) "meta_tags"
  [4]=>
  string(11) "pagemanager"
  [5]=>
  string(11) "page_params"
  [6]=>
  string(7) "tinymce"
  [7]=>
  string(4) "utf8"
}
With this two arrays the validation

Code: Select all

$expired = $plugins != $oldPlugins; 
will always return $expired === true.

Sorting of $plugins is done at the end of XH_Plugins by

Code: Select all

natcasesort($plugins); 
but this way only the values are affected.

I think a fix is simple possible by using

Code: Select all

$plugins = array_values($plugins);
after natcasesort.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Plugins.css refreshes on every request

Post by cmb » Sat Feb 07, 2015 11:24 am

Holger wrote:Sorting of $plugins is done at the end of XH_Plugins by

Code: Select all

natcasesort($plugins);
but this way only the values are affected.
Good catch!
I think a fix is simple possible by using

Code: Select all

$plugins = array_values($plugins);
after natcasesort.
ACK. I suggest to do an array_values($admPlugins) also.

Since PHP 5.4.0 the following is possible, which should give the desired result without calling array_values() (we may add an respective TODO):

Code: Select all

sort($plugins, SORT_NATURAL | SORT_FLAG_CASE)
I've put the issue on the 1.6.6 roadmap, but it's a simple bug fix, so we might fix it right away. Holger?
Christoph M. Becker – Plugins for CMSimple_XH

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: Plugins.css refreshes on every request

Post by Holger » Sat Mar 07, 2015 11:49 am

Done.

Post Reply