When I run drush on my shared hosting account at 1and1, drush_verify_cli() always fails. I did some testing and noticed that php_sapi_name() is returning 'cgi', even when run from the command line.

I've instead tried testing the value of $_SERVER['argc'], which returns 0 when run in the browser and at least 1 when run from the command line.

Is this a safe way to test for whether or not drush is being run from the command line? (If so, I could add in the check against $_SERVER['argc'] if and only if php_sapi_name() comes back as 'cgi'.)

Let me know what you think.

CommentFileSizeAuthor
#1 drush_cli_fix.patch596 bytesSteven Merrill

Comments

Steven Merrill’s picture

StatusFileSize
new596 bytes

Here's my patch anyway. I would still like the community's feedback on if this is a safe approach for drush_verify_cli() on shared hosting that returns 'cgi' for php_sapi_name().

Thanks!

Steven Merrill’s picture

Assigned: Unassigned » Steven Merrill
Status: Active » Needs review

Status change.

moshe weitzman’s picture

Title: 1and1 and drush.php - check for $_SERVER['argc'] rather than php_sapi_name() ? » 1and1 and drush.php - Fails CLI test wen using cgi php
moshe weitzman’s picture

Status: Needs review » Fixed

I came across this on a web host and this fixed the the problem with no ill effects. committed. thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

adrian’s picture

This isn't in the DRUPAL-6--1-0-RC2 release, perhaps we need a new rc ?

moshe weitzman’s picture

6.x-1.0 is released and should have this.