anikesh / web-optimizator

Automatically exported from code.google.com/p/web-optimizator
0 stars 0 forks source link

Various Fixes (*) for Stricter use with PHP5.4.x; for the Latest r3898 svn #590

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
PHP 5.4.x requires a more strict, structured language and these kind of 
'errors' [E' Notices] are part of the new changes!

To save my time [and your time] this is presented as a Linux difference 
'compare' showing the differences in code between what is released [3898] and 
what I changed for more correct operation under PHP 5.4.1 (much more strict 
than your current test environment):

First, a simple summary of the errors / notices under PHP 5.4.x:

1) Notice: undefined index 'wss_minify_js2' -> controller/admin.php
2) Notice: undefined index 'wss_minify_js4' -> controller/admin.php
3) Notice: undefined index: configuration'  -> controller/admin.php
4) Fatal error: Cannot redeclare class  ->  controller/compressor.php
5) String offset cast occurred -> controller/compressor.php
6) Warning:  constant(): Couldn't find constant _WEBO_description & _WEBO_title 
-> view/install_options.php
7) Noticed: undefined index '$memory_limit' -> libs/php/cache_engine.php 
(Notes: I just commented out 3 lines to fix this!)

1)controller/admin.php
Line 1882: yui_possibility' => !$this->restrictions['wss_minify_js2'],

changed to: 'yui_possibility' => !isset($this->restrictions['wss_minify_js2']), 
                          // avoid undefined index 'wss_minify_js2'
Line 1883: 'google_possibility' => !$this->restrictions['wss_minify_js4'],

changed to: 'google_possibility' => 
!isset($this->restrictions['wss_minify_js4']),                        // avoid 
undefined index 'wss_minify_js4'

Line 3835: 'value' => $this->compress_options['unobtrusive']['configuration'],

changed to: 'value' => 
isset($this->compress_options['unobtrusive']['configuration']),      // avoid 
'PHP Notice:  Undefined index: configuration'

2) File: webo-svn/web-optimizator-orig/controller|compressor.php
Line 1282: require($this->options['css']['installdir'] . 
'libs/php/html.sprites.php');

changed to: require($this->options['css']['installdir'] . 
'libs/php/html.sprites.php');

Line 1366: $i = ceil(strlen($old_src)/2);

changed to: $i = intval(ceil(strlen($old_src)/2));          // PHP 5.4x Fix: 
ceil() returns type float! *must* be an int - so use intval()

3) view/install_options.php
Line 202: echo constant('_WEBO_' . ($iis ? str_replace("htaccess", "iis", $key) 
: $key));

changed to:
if (defined('_WEBO_' . ($iis ? str_replace("htaccess", "iis", $key) : $key))) { 
        // avoid "PHP Warning:  constant(): Couldn't find constant 
_WEBO_description & _WEBO_title"
              echo constant('_WEBO_' . ($iis ? str_replace("htaccess", "iis", $key) : $key));
            }

4) libs/php/cache_engine.php
Line 429:       if (round(str_replace("M", "000000", str_replace("K", "000", 
$memory_limit))) < 128000000) {
            @ini_set('memory_limit', '128M');
        }

For now (/), I just commented the above lines out, as my PHP available memory 
is much larger than 128Mb.

Many thanks,

Peter

Original issue reported on code.google.com by peterbowey on 26 May 2012 at 1:25

GoogleCodeExporter commented 9 years ago
Sorry pasting error in the above code!!

The part that states:
2) File: webo-svn/web-optimizator-orig/controller|compressor.php
Line 1282: require($this->options['css']['installdir'] . 
'libs/php/html.sprites.php');

changed to: require($this->options['css']['installdir'] . 
'libs/php/html.sprites.php');

should be this:

2) File: webo-svn/web-optimizator-orig/controller|compressor.php
Line 1282: require($this->options['css']['installdir'] . 
'libs/php/html.sprites.php');

changed to: require_once($this->options['css']['installdir'] . 
'libs/php/html.sprites.php');   // do NOT include class more than ONCE

Further Notes [Use]:

The latest SVN r3898 is working reasonably well for me, in my live production 
sites, for WordPress 3.4-beta4-20725, Drupal 6.22 and Drupal 7.14.

I use PHP 5.4.1 and Nginx/1.3.0 under Fedora 16 [x86-64].

Thank you for the work you have done to make this good performance tool!

Original comment by peterbowey on 26 May 2012 at 1:43

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r3900.

Original comment by sunny.dr...@gmail.com on 27 May 2012 at 3:51

GoogleCodeExporter commented 9 years ago
Thank you. Most of issues fixed, some of them related to out-of-dated 
configuration (must be renewed with update process, need to understand why do 
you have old config files w/o some of options, i.e. unobtrusive configuration).

Original comment by sunny.dr...@gmail.com on 27 May 2012 at 3:54