Broken regex in /console/lithium.php - Bugfix #681

Closed
Speedrockracer opened this Issue Nov 16, 2012 · 4 comments

Comments

Projects
None yet
3 participants

Hey guys,

The regex around line 91

if (preg_match("/^define(["']LITHIUM_LIBRARY_PATH["']/m", file_get_contents($path))) {

Wil never return true.

I think it sould be:

"/define(["']LITHIUM_LIBRARY_PATH["']/m"

This way the console command can use the normal bootstrap.

Grtz
Speedrock

Owner

nateabele commented Nov 16, 2012

I'm not sure what you're talking about. The regex is intended to match this line: https://github.com/UnionOfRAD/framework/blob/master/app/config/bootstrap/libraries.php#L62, which it does.

@nateabele nateabele closed this Nov 16, 2012

Oh my bad I Didn't notice the "m" @ the end.
Anyway it didn't match on my end because my code goes like this:

if(isset($_SERVER['LITHIUM_LIBRARY_PATH'])){ // take from the apache config
define('LITHIUM_LIBRARY_PATH', $_SERVER['LITHIUM_LIBRARY_PATH']);
}else{ // command line fallback
define('LITHIUM_LIBRARY_PATH', '/var/lib/lithium/libraries');
}

Notice the tabs in front. Removing them solved my issue.
My question: Is this bad practice?

Greetz,
Speedrock

Owner

nateabele commented Nov 19, 2012

My question: Is this bad practice?

Not really, no. Those files are intended to be user-configurable, and what you're doing is a perfectly legitimate way to configure an application. I think what we can do is change the regex to look like this, which should solve your issue:

"/^\s*define\([\"']LITHIUM_LIBRARY_PATH[\"']/m"

@nateabele nateabele reopened this Nov 19, 2012

Owner

davidpersson commented Jan 8, 2014

Thanks for bringing this to our attention, @Speedrockracer. The issue has been fixed in 2e9baae.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment