Logged PHP 5.x E' Notices captured on clean Drupal D6 (Pressflow) Install:
Notes: at this point no other modules but latest CORE, View and CCK
Prior to installing latest [advagg] no other PHP E' Notices had occurred over 2 hours:

    Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).

Comments

Peter Bowey’s picture

I suspect (tracing sample code) that this problem has been introduced by the new inline JS code in;

advagg_js_compress/advagg_js_compress.module:

$results = drupal_http_request($url, $headers, 'POST', $query_string);
Peter Bowey’s picture

Same D6 'clean install' - with [advagg].
Went to admin/settings/advagg page and got this report:

Notice: Undefined index: description in advagg_admin_settings_form() (line 177 of /var/www/virtual/peterbowey.com.au/sites/all/modules/advagg/advagg.admin.inc).
Peter Bowey’s picture

3# - Changed the [advagg] "IP Address to send all asynchronous requests to:" to -1 and applied!
Got this report:

    Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined index: description in advagg_admin_settings_form() (line 177 of /var/www/virtual/peterbowey.com.au/sites/all/modules/advagg/advagg.admin.inc).
    Notice: Undefined index: description in advagg_admin_settings_form() (line 177 of /var/www/virtual/peterbowey.com.au/sites/all/modules/advagg/advagg.admin.inc).
Peter Bowey’s picture

4# switched to [advagg] admin/settings/advagg/bundler url and got this report:

Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
Notice: Undefined variable: row in advagg_bundler_admin_settings_form() (line 72 of /var/www/virtual/peterbowey.com.au/sites/all/modules/advagg/advagg_bundler/advagg_bundler.admin.inc)
mikeytown2’s picture

Title: Various E' PHP Notices on a CLEAN Install » AdvAgg - Notice: Undefined offset: in drupal_http_request() (in includes/common.inc). Backport D7 drupal_http_request.

What does your the site status message say in regards to advagg? These errors are a by-product of the async worker timing out before it sends a message back. Nothing to really worry about and the fix for this would slow it down quite a bit so I'm tempted to mark this as a won't fix. I should create a patch for pressflow/drupal to "fix" this issue and not have to slow it down... the other option is to backport the D7 drupal_http_request and use that if your using php5... which sounds like a good idea.

Peter Bowey’s picture

Priority: Normal » Major

Checked my [nginx] server logs - after the above. Found this logged report:

2011/05/18 00:06:11 [alert] 2474#0: *307 stalled cache updating, error:0 while closing request, client: 75.125.82.136, server: 0.0.0.0:80
Peter Bowey’s picture

Requested 'status message say in regards to advagg'

Status report
Pressflow	6.20
Access to update.php	Protected
Adv CSS/JS Agg - Asynchronous Mode	Already set to TRUE
Adv CSS/JS Agg - Socket Timeout	Already set to 1 seconds. Raw timer: 22.85
AdvAgg JS Compress - Callback	The callback is working correctly.
Configuration file	Protected
Cron maintenance tasks	Last run 52 min 30 sec ago
Peter Bowey’s picture

#8 - Also found a code bug in [advagg_bundler.admin.inc]

  list($data, $rows) = advagg_form_print_r($data);
  $form['info']['advagg_bundler_info'] = array(
    '#type'         => 'textarea',
-    '#title'        => check_plain($row['filename']),
+    '#title'        => check_plain($rows['filename']),  // Note: $rows is the logic used here
    '#default_value'  => $data,
    '#rows'           => $rows-1,
  );
Peter Bowey’s picture

The code 'idea' to use backport the D7 drupal_http_request is a great idea!
Seems we are battling' between D6 and D7, with the 'really' patient ones are waiting for D8 (ha!)

I am likely to hack-core the D6 with this ->

http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ht...
Peter Bowey’s picture

#10 - Other logged errors noted (since clean install of advagg):

[18-May-2011 01:23:57] PHP Fatal error:  require_once() [<ahref='function.require'>function.require</a>]: Failed opening required './sites/all/modules/cck/theme/theme.inc' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/virtual/peterbowey.com.au/sites/all/modules/cck/content.module on line 176

[18-May-2011 02:06:33] PHP Fatal error:  Call to undefined function advagg_flush_caches() in /var/www/virtual/peterbowey.com.au/sites/all/modules/advagg/advagg_css_compress/advagg_css_compress.install on line 38
Peter Bowey’s picture

Totally clean Pressflow install with barebones [core + views + cck]:

Changes made to [advagg] were:

ONE:

advagg_bundler.admin.inc

  list($data, $rows) = advagg_form_print_r($data);
  $form['info']['advagg_bundler_info'] = array(
    '#type'         => 'textarea',
-    '#title'        => check_plain($row['filename']),
+    '#title'        => check_plain($rows['filename']),
    '#default_value'  => $data,
    '#rows'           => $rows-1,
  );

TWO:

advagg.admin.inc

  $form['advagg_async_generation'] = array(
    '#type'           => 'checkbox',
    '#title'          => t('Generate CSS/JS files on request (async mode)'),
    '#default_value'  => variable_get('advagg_async_generation', ADVAGG_ASYNC_GENERATION),
    '#disabled'       => $ret['advagg_async_generation']['severity'] == REQUIREMENT_ERROR ? TRUE : FALSE,
-    '#description'    => t('Current State: !value', array('!value' => filter_xss($ret['advagg_async_generation']['value'] . ' ' . !empty($ret['advagg_async_generation']['description']) ? $ret['advagg_async_generation']['description'] : ''))),
+    '#description'    => t('Current State: !value', array('!value' => filter_xss($ret['advagg_async_generation']['value'] . ' ' . (!empty($ret['advagg_async_generation']['description']) ? $ret['advagg_async_generation']['description'] : '')))),
  );

With these two changes - I had no PHP 5.x E' notices, with all the same tests as above.

The only last issue is the slow 'async worker'!!! Give it time, and it finally gets 'out of its 'lazy bed' and walks 'slowly' to the kitchen for a coffee treat?? Duh

Peter Bowey’s picture

After the 'above' changes the only 'serious bug' logs I get are these: (advagg)

    Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 556 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 2 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
    Notice: Undefined offset: 1 in drupal_http_request() (line 559 of /var/www/virtual/peterbowey.com.au/includes/common.inc).
mikeytown2’s picture

Looks like the D7 backport isn't exactly what I want... this is closer to my needs
http://hi.baidu.com/%C3%C6%C9%F9%B7%A2%B4%F3%B2%C6/blog/item/26ac9bdd226...

Peter Bowey’s picture

Just installed the new [advagg] (latest .git).

I get this report just after module activation:

    Notice: Undefined variable: filetype in advagg_get_files_in_bundle() (line 1219 of /var/www/virtual/peterbowey.com.au/sites/all/modules/advagg/advagg.module).
    Notice: Undefined variable: filetype in advagg_get_files_in_bundle() (line 1219 of /var/www/virtual/peterbowey.com.au/sites/all/modules/advagg/advagg.module).

I then 'reports' as above consistently in use.

mikeytown2’s picture

Status: Active » Fixed
StatusFileSize
new9.43 KB

Here is the patch that I've committed. I'm going to assume this fixes the issue, let me know if nginx spits out any errors; I might have a workaround for it.

mikeytown2’s picture

@#14 that's a very strange error to get; here is the code in question

/**
 * Get list of files and the filetype given a bundle md5.
 *
 * @param $bundle_md5
 *   Bundle's machine name.
 * @return
 *   array ($filetype, $files)
 */
function advagg_get_files_in_bundle($bundle_md5) {
  $files = array();
  $results = db_query("SELECT filename, filetype FROM {advagg_files} AS af INNER JOIN {advagg_bundles} AS ab USING ( filename_md5 ) WHERE bundle_md5 = '%s' ORDER BY porder ASC", $bundle_md5);
  while ($row = db_fetch_array($results)) {
    $files[] = $row['filename'];
    $filetype = $row['filetype'];
  }
  return array($filetype, $files);
}

I SELECT filename, filetype and then use it in the row... if anything it should throw a SQL error.

EDIT: I see the error... stand by

Peter Bowey’s picture

Just tried the above 'patch', 'after a clear cache event' - it looks good (no E' events logged)!

Went through all the usual events that prev. triggered the log - but is good.

Peter Bowey’s picture

To #16 'EDIT: I see the error... stand by...'
I am one patch behind - already!
I had just done #15 (patch) :)

mikeytown2’s picture

StatusFileSize
new443 bytes

committed this patch for #14 :)

mikeytown2’s picture

Peter Bowey’s picture

#19 Patch works a treat, I see clean logs after several event tests! = Yay!!
Well done... :)

Peter Bowey’s picture

To #20, I will try that later when it hits -> "git clone --branch 6.x-1.x http://git.drupal.org/project/advagg.git"
I must get a life :)

Peter Bowey’s picture

Referring back to #12 - #13, I can see now why Wim Leers wrote his advanced aggregation / compressor in Perl!

Peter Bowey’s picture

I have just done some hard testing, 'rebuilding aggregated files' etc..
I note that the build loop sometimes 'hangs'

Message: This request could not generate correctly. Loop detected. Request data: sites/default/files/advagg_js/js_7e6c60fca057b65f2973751cd2d3e23e_0.js

Referrer:	http://www.peterbowey.com.au/batch?op=start&id=2

Location:	http://www.peterbowey.com.au/sites/default/files/advagg_js/js_7e6c60fca057b65f2973751cd2d3e23e_0.js?redirect_counter=6
Peter Bowey’s picture

StatusFileSize
new147.71 KB

Out of interest, this is how it currently appears at: http://www.webpagetest.org/result/110518_NG_MGX2/2/details/

Keeping in mind that [boost], [cdn] and [memcache] are NOT active (yet).

mikeytown2’s picture

in terms of a redirect loop I have an idea on how they might be caused
#1160890: Create uncompressed aggregate and then overwrite and save the compressed version.

Peter Bowey’s picture

CSSTidy & JSMin+ are very expensive to run. Have an option to output the uncompressed aggregate first and then create a compressed version and do a rename operation to replace the uncompressed with the compressed. Hopefully this will take care of the advagg loops that happen.

'Sounds good'. Yes, I have JSMin+ statically compiled [not with pecl] into PHP-FPM.
Is [advagg] using PHP's [internal] CSSTidy and what advantage is it over some good 'regex' trimming?

Peter Bowey’s picture

Peter Bowey’s picture

I note this 'comment' on the Drupal CSSTidy module project page:

Known Issues
Pressflow

CSSTidy is not currently compatible with Pressflow.

See Pressflow bug: #597718: file.inc function file_create_url() not correct

Peter Bowey’s picture

I am seriously thinking of 'patching' advagg's current "
function advagg_css_compress_css_tidy(&$contents)" to disable/bypass CSSTidy class.

This article made me think about this CSS event:
http://nadeausoftware.com/articles/2008/06/dont_bother_using_css_optimiz...
Thoughts?

mikeytown2’s picture

Just disable the compression module... simple as that. You still get core's regex whitespace compression.

mikeytown2’s picture

https://bugs.launchpad.net/pressflow/+bug/597718

file_create_url() would be an issue with the creation of the link in the HTML. It appears the reference to the CSS is correctly set, so this is something else.

Peter Bowey’s picture

Thanks Mike,

Of interest, I replaced advagg's CSSTidy function in [advagg_css_compress.module] with this 'regex' code, and 'finally' the [Recreate all aggregated files] option actually completes (and without timeouts)....

function advagg_css_compress_css_tidy(&$contents) {
   $contents = preg_replace('!(/\*.*?\*/|^ | $)!is', '', $contents);
   $contents = preg_replace('![\s\t\r\n]+!', ' ', $contents);
   $contents = str_replace(array(' :', ': ', ' ,', ', ', ' ;', '; ', ' {', '{ ', ' }', '} '), array(':', ':', ',', ',', ';', ';', '{', '{', '}', '}'), $contents);
   $contents = str_replace(array(' 0px', ':0px', ';}', ':0 0 0 0', ':0.', ' 0.'), array(' 0', ':0', '}', ':0', ':.', ' .'), $contents);
   $contents = trim($contents);
}

With CSSTidy, I 'gave up' waiting for the completion of 'Recreate all aggregated files'.
No logged events either - with the simple regex (above).
So yes, CSSTidy is heavy hauling...

Peter Bowey’s picture

#33 Regex method benchmarks at 8 seconds [Recreate all aggregated files]
Best case CSSTidy trials varied from 3 minutes to 'never completes' :)

Peter Bowey’s picture

I then tried this 'new' PHP class method -> http://www.codenothing.com/archives/php/css-compressor/

This new code (replacing the CSSTidy Class used in advagg) bench-marked at 10 seconds.

I used 'sane' for the CSS optimize [css-compressor 3.0]
Cool

mikeytown2’s picture

Thanks for the heads up on that; it is MIT Licensed so I can include in the advagg download; which is something I plan on doing.
#1161870: Include the CSS Compressor

mikeytown2’s picture

Status: Fixed » Closed (fixed)