If you are using drush, and add simpletest to your project, the snippet of code listed in INSTALL.txt is slightly broken because when using drush, $_SERVER['HTTP_USER_AGENT'] is an undefined index. This generates some output (a blank line? not sure); but it results in:

Notice: Undefined index:  HTTP_USER_AGENT in /usr/local/www/drupal_sites/mvcares.org/settings.php on line 231

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /usr/local/www/drupal_sites/mvcares.org/settings.php:231) in /usr/local/www/drupal6-cvs/includes/bootstrap.inc on line 1029

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /usr/local/www/drupal_sites/mvcares.org/settings.php:231) in /usr/local/www/drupal6-cvs/includes/bootstrap.inc on line 1029

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/www/drupal_sites/mvcares.org/settings.php:231) in /usr/local/www/drupal6-cvs/includes/bootstrap.inc on line 630

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/www/drupal_sites/mvcares.org/settings.php:231) in /usr/local/www/drupal6-cvs/includes/bootstrap.inc on line 631

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/www/drupal_sites/mvcares.org/settings.php:231) in /usr/local/www/drupal6-cvs/includes/bootstrap.inc on line 632

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/www/drupal_sites/mvcares.org/settings.php:231) in /usr/local/www/drupal6-cvs/includes/bootstrap.inc on line 633

This is alleviated by inserting an "@" in front of the $_SERVER or perhaps with an if isset e.g.:

$GLOBALS['simpletest_installed'] = TRUE;
if (isset($_SERVER['HTTP_USER_AGENT']) &&
    preg_match("/^simpletest\d+$/", $_SERVER['HTTP_USER_AGENT'])) {
  $db_prefix = $_SERVER['HTTP_USER_AGENT'];
}

I also suspect that this does not show up unless php error_reporting is tuned up to E_ALL or some such.

Comments

boombatower’s picture

Project: SimpleTest » Drush
Version: 6.x-2.7 » 6.x-1.x-dev
Component: Documentation » Code

Shouldn't drush just set it since it is creating an inconsistent environment.

moshe weitzman’s picture

There is no http referer so I think drush is correct not to set this. Personally, I think simpletest's recommended php ought to become less noisy as you've suggested.

boombatower’s picture

http referer?

It is looking for $_SERVER['HTTP_USER_AGENT'] which there should always be...set to "drush"...maybe I'm not following?

ericxb’s picture

I wondered about that myself. I agree drush should set the var; but I wasn't sure if it was correct to assume that USER_AGENT would always be set in the general case.

I will cross post this to the drush group as soon as I work thru their code and have a patch.

ericxb’s picture

This seems to work as a drush patch:

--- /usr/local/www/drupal_sites/all/modules/drush/drush.php~	2008-11-28 12:18:20.000000000 -0500
+++ /usr/local/www/drupal_sites/all/modules/drush/drush.php	2009-03-12 22:11:58.000000000 -0400
@@ -155,6 +155,10 @@
   $_SERVER['REMOTE_ADDR'] = '';
   $_SERVER['REQUEST_METHOD'] = NULL;
   $_SERVER['SERVER_SOFTWARE'] = NULL;
+  # the recommended SimpleText config script in settings.php throws
+  # warnings if HTTP_USER_AGENT is not set.
+  preg_match('/([\d.]+)/', '$Revision: 1.24.2.4 $', $rev);
+  $_SERVER['HTTP_USER_AGENT'] = "Drush {$rev[0]}";
 
   // Change to Drupal root dir.
   chdir(DRUSH_DRUPAL_ROOT);

moshe weitzman’s picture

Status: Active » Fixed

we now set this to NULL, which seems about right. please reopen if needed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

socialnicheguru’s picture

Can this be rerolled into a patch?

I use update regularly and I haven't seen an update for drush which would include this.

Or is it more likely that since drush is not longer a module, update does not pick it up?

C