Bug #5467

CSV transform does not accept empty mysql passwords

Added by Misty De Meo almost 9 years ago. Updated almost 9 years ago.

Status:VerifiedStart date:08/14/2013
Priority:LowDue date:
Assignee:Misty De Meo% Done:

100%

Category:CSV importEstimated time:0.50 hour
Target version:Release 1.4.0
Google Code Legacy ID: Tested version:
Sponsored:No Requires documentation:

Description

The CSV transform script requires access to a temporary mysql database as a staging area for transforms, and requires that the MYSQL_PASSWORD environment variable be set to provide access. However, this will fail if the mysql user has an empty password - for example, the mysql root user in mysql's default configuration. This happens because of the way the password is checked:

if (!getEnv("MYSQL_PASSWORD"))
{
  throw new sfException('You must set the MYSQL_PASSWORD environmental variable. This script will use the "root" user and a database called "import".');
}

getEnv() returns false if the environment variable is unset:

getEnv("MYSQL_PASSWORD"); # → false

And an empty string if it's set but empty:

getEnv("MYSQL_PASSWORD"); # → ''

But since PHP considers an empty string to be false, it believes no password was passed and the transform aborts.

I'd suggest doing the following instead:

if (getEnv("MYSQL_PASSWORD") == false) # ...

History

#1 Updated by Misty De Meo almost 9 years ago

  • Description updated (diff)

#2 Updated by Misty De Meo almost 9 years ago

  • Category set to CSV import
  • Assignee set to Misty De Meo
  • Target version set to Release 1.4.0

#3 Updated by Misty De Meo almost 9 years ago

  • Status changed from New to QA/Review
  • Estimated time set to 0.50

Fix applied in e08152e3ac809c43655613a152dcc42cc95d1c2c, and tested to work correctly.

#4 Updated by Misty De Meo almost 9 years ago

  • % Done changed from 0 to 100

Applied in changeset atom|commit:e08152e3ac809c43655613a152dcc42cc95d1c2c.

#5 Updated by Jesús García Crespo almost 9 years ago

  • Status changed from QA/Review to Verified

Also available in: Atom PDF