? includes/table.inc
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/README.txt,v
retrieving revision 1.51
diff -u -p -r1.51 README.txt
--- README.txt	20 Oct 2010 17:41:41 -0000	1.51
+++ README.txt	8 Nov 2010 06:02:20 -0000
@@ -34,13 +34,12 @@ For Linux/Unix/Mac:
   2. Make the 'drush' command executable:
        $ chmod u+x /path/to/drush/drush
   3. (Optional, but recommended:) To ease the use of drush,
-     - create a link to drush in a directory that is in your $PATH, e.g.:
+     - create a link to drush in a directory that is in your PATH, e.g.:
        $ ln -s /path/to/drush/drush /usr/local/bin/drush
      OR
-     - create an alias to drush:
-       $ alias drush='/path/to/drush/drush'
-       For example, if drush is in your home directory:
-       $ alias drush='~/drush/drush'
+     - add the folder that contains drush to your PATH
+       PATH=$PATH:/path/to/drush
+
        This goes into .profile, .bash_aliases or .bashrc in your home folder.
        NOTE:  You must log out and then log back in again or re-load your bash
        configuration file to apply your changes to your current session:
@@ -48,13 +47,39 @@ For Linux/Unix/Mac:
 
      NOTE FOR ADVANCED USERS
      - If you want to run drush with a specific version of php, rather than the
-       one found by the drush command, you can instead create an alias that
-       executes the drush.php file directly and passes that path to drush:
-       $ alias drush='/path/to/php/php5 /path/to/drush/drush.php --php=/path/to/php/php5'
-       If you do this, to allow Drush to detect the number of available columns,
+       one found by the drush command, you can define an environment variable
+       DRUSH_PHP that points to the php to execute:
+       export DRUSH_PHP=/usr/bin/php5
+     OR
+     - If you want to exactly control how drush is called, you may define an alias
+       that executes the drush.php file directly and passes that path to drush:
+       $ alias drush='/path/to/php/php5 -d memory_limit=128M /path/to/drush/drush.php --php="/path/to/php/php5 -d memory_limit=128M"'
+       Note that it is necessary to pass the '--php' option to drush to define
+       how drush should call php if it needs to do so.
+       If you define an alias, to allow Drush to detect the number of available columns,
        you need to add the line 'export COLUMNS' to the .profile file in your
        home folder.
 
+     NOTE ON PHP.INI FILES
+     - Usually, php is configured to use separate php.ini files for the web server
+       and the command line.  To see which php.ini file drush is using, run:
+       $ drush status
+     - Compare the php.ini that drush is using with the php.ini that the webserver is
+       using.  Make sure that drush's php.ini is given as much memory to work with as
+       the web server is; otherwise, Drupal might run out of memory when drush
+       bootstraps it.
+     - Drush requires a fairly unrestricted php environment to run in.  In particular,
+       you should insure that safe_mode, open_basedir, disable_functions and
+       disable_classes are empty.
+     - If drush is using the same php.ini file as the web server, you can create
+       a php.ini file exclusively for drush by copying your web server's php.ini
+       file to the folder $HOME/.drush or the folder /etc/drush.  Then you may edit
+       this file and change the settings described above without affecting the
+       php enviornment of your web server.  Alternately, if you only want to
+       override a few values, copy example.drush.ini from the "examples" folder
+       into $HOME/.drush or the folder /etc/drush and edit to suit.  See comments
+       in example.drush.ini for more details.
+       
   4. Start using drush by running "drush" from your Drupal root directory.
 
      (or, if you did not follow step 3, by running "/path/to/drush/drush"
Index: drush
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/drush,v
retrieving revision 1.23
diff -u -p -r1.23 drush
--- drush	30 Oct 2010 17:52:28 -0000	1.23
+++ drush	8 Nov 2010 06:02:20 -0000
@@ -41,28 +41,46 @@ if [ -z $COLUMNS ]; then
   fi
 fi
 
-# Default to using the php that we find on the PATH.
-# Note that we need the full path to php here for Dreamhost, which behaves oddly.  See http://drupal.org/node/662926
-php=`which php`
-
-# We check for a command line (cli) version of php, and if found use that.
-which php-cli >/dev/null 2>&1
-if [ "$?" = 0 ] ; then
-  php=`which php-cli`
+if [ ! -z "$DRUSH_PHP" ] ; then
+  # Use the DRUSH_PHP environment variable if it is available.
+  php="$DRUSH_PHP"
+else
+  # Default to using the php that we find on the PATH.
+  # Note that we need the full path to php here for Dreamhost, which behaves oddly.  See http://drupal.org/node/662926
+  php=`which php`
+
+  # We check for a command line (cli) version of php, and if found use that.
+  which php-cli >/dev/null 2>&1
+  if [ "$?" = 0 ] ; then
+    php=`which php-cli`
+  fi
+
+  # Special case for *AMP installers, since they normally don't set themselves as the default cli php out of the box.
+  for amp_php in /Applications/MAMP/bin/php5/bin/php /Applications/MAMP/bin/php5.2/bin/php /Applications/MAMP/bin/php5.3/bin/php /opt/lampp/bin/php /Applications/xampp/xamppfiles/bin/php /Applications/acquia-drupal/php/bin/php; do
+    if [ -x $amp_php ]; then
+      php=$amp_php
+    fi
+  done
 fi
 
-# Special case for *AMP installers, since they normally don't set themselves as the default cli php out of the box.
-for amp_php in /Applications/MAMP/bin/php5/bin/php /Applications/MAMP/bin/php5.2/bin/php /Applications/MAMP/bin/php5.3/bin/php /opt/lampp/bin/php /Applications/xampp/xamppfiles/bin/php /Applications/acquia-drupal/php/bin/php; do
-  if [ -x $amp_php ]; then
-    php=$amp_php
+# Check to see if the user has provided a php.ini file or drush.ini file in any conf dir
+# Last found wins, so search in reverse priority order
+for conf_dir in /etc/drush $HOME/.drush ; do
+  if [ -f $conf_dir/php.ini ] ; then
+    drush_php_ini=$conf_dir/php.ini
+  fi
+  if [ -f $conf_dir/drush.ini ] ; then
+    drush_php_override=$conf_dir/drush.ini
   fi
 done
 
-# Check to see if the user has provided a php.ini file particularly for drush
-if [ -f $HOME/.drush/php.ini ] ; then
-  php="$php --php-ini $HOME/.drush/php.ini"
-elif [ -f /etc/drush/php.ini ] ; then
-  php="$php --php-ini /etc/drush/php.ini"
+# Add in the php file location and/or the php override variables as appropriate
+if [ "x$drush_php_ini" != "x" ] ; then
+  php="$php --php-ini $drush_php_ini"
+fi
+if [ "x$drush_php_override" != "x" ] ; then
+  drush_override_vars=`grep '^[a-z_A-Z0-9]\+ *=' $drush_php_override | sed -e 's|\([^ =]*\) *= *\(.*\)|\1="\2"|' -e 's| ||g' -e 's|^|-d |' | tr '\n\r' '  '`
+  php="$php $drush_override_vars"
 fi
 
 # Pass in the path to php so that drush knows which one
Index: examples/example.drush.ini
===================================================================
RCS file: examples/example.drush.ini
diff -N examples/example.drush.ini
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ examples/example.drush.ini	8 Nov 2010 06:02:20 -0000
@@ -0,0 +1,61 @@
+;$Id: $
+;
+; Example of a drush php settings override file
+;
+; Use this file in instances when your system is
+; -not- configured to use separate php.ini files for
+; webserver and cli use.  You can determine which
+; php.ini file drush is using by running "drush status".
+; If the php.ini file shown is your webserver ini
+; file, then rename this file to drush.ini and copy it
+; to one of the following locations:
+;
+; 1. User's .drush folder (i.e. ~/.drush/drush.ini)
+; 2. System wide configuration folder (e.g. /etc/drush/drush.ini)
+;
+; When in use, the variables defined in this file
+; will override the setting values that appear in
+; your php.ini file.  See the examples below for
+; some values that may need to be set in order for
+; drush to work.
+;
+; NOTE:  There is a certain amount of overhead
+; required for each override, so drush.ini should
+; only be used for a relatively small number
+; of variables.  Comment out any variable that
+; has the same value as the webserver php.ini
+; to keep the size of the override list small.
+;
+; To fully specify the value of all php.ini variables, 
+; copy your webserver php.ini file to one of the 
+; locations mentioned above (e.g. /etc/drush/php.ini)
+; and edit it to suit.
+; 
+
+;
+; drush needs as much memory as Drupal in order
+; to run; make the memory limit setting match
+; what you have in your webserver's php.ini.
+;
+memory_limit = 128M
+
+;
+; Show all errors and direct them to stderr
+; when running drush.
+;
+error_reporting = E_ALL | E_NOTICE | E_STRICT
+display_errors = stderr
+
+;
+; If your php.ini for your webserver is too
+; restrictive, you can re-enable functionality
+; for drush by adjusting values in this file.
+;
+; Here are some examples of settings that are
+; sometimes set to restrictive values in a
+; webserver's php.ini:
+;
+;safe_mode = 
+;open_basedir = 
+;disable_functions =
+;disable_classes =
Index: includes/environment.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/environment.inc,v
retrieving revision 1.97
diff -u -p -r1.97 environment.inc
--- includes/environment.inc	8 Nov 2010 05:31:22 -0000	1.97
+++ includes/environment.inc	8 Nov 2010 06:02:20 -0000
@@ -420,9 +420,15 @@ function drush_bootstrap_value($context,
  * Validate initial Drush bootstrap phase.
  */
 function _drush_bootstrap_drush_validate() {
-  // Test safe mode is off.
-  if (ini_get('safe_mode')) {
-    return drush_bootstrap_error('DRUSH_SAFE_MODE', dt('PHP safe mode is activated. Drush requires that safe mode is disabled.'));
+  // Test to insure that certain php ini restrictions have not been enabled
+  $prohibited_list = array();
+  foreach (array('safe_mode', 'open_basedir', 'disable_functions', 'disable_classes') as $prohibited_mode) {
+    if (ini_get($prohibited_mode)) {
+      $prohibited_list[] = $prohibited_mode;
+    }
+  }
+  if (!empty($prohibited_list)) {
+    return drush_bootstrap_error('DRUSH_SAFE_MODE', dt('The following restricted PHP modes have non-empty values: !prohibited_list. This configuration is incompatible with drush; see examples/example.drush.ini for details.', array('!prohibited_list' => implode(' and ', $prohibited_list))));
   }
 
   // try using the PEAR installed version of Console_Table
