Skip to content

Commit 7af8b84

Browse files
committed
Re-register the composer autoloader so that Resque from _this_ repo is used and not another version from APP_INCLUDE.
Requiring composer from external apps causes their autoloader to register which takes precedence over any prior registered autoloaders. This may cause issues when using an APP_INCLUDE that depends on an older version of Resque which ends up replacing this version.
1 parent 40d910c commit 7af8b84

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bin/resque

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ $files = array(
99
__DIR__ . '/../vendor/autoload.php',
1010
);
1111

12-
$found = false;
12+
$loader = null;
1313
foreach ($files as $file) {
1414
if (file_exists($file)) {
15-
require_once $file;
15+
$loader = require_once $file;
1616
break;
1717
}
1818
}
1919

20-
if (!class_exists('Composer\Autoload\ClassLoader', false)) {
20+
if (!($loader instanceof Composer\Autoload\ClassLoader)) {
2121
die(
2222
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
2323
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
@@ -44,10 +44,11 @@ $REDIS_BACKEND = getenv('REDIS_BACKEND');
4444
// A redis database number
4545
$REDIS_BACKEND_DB = getenv('REDIS_BACKEND_DB');
4646
if(!empty($REDIS_BACKEND)) {
47-
if (empty($REDIS_BACKEND_DB))
47+
if (empty($REDIS_BACKEND_DB)) {
4848
Resque::setBackend($REDIS_BACKEND);
49-
else
49+
} else {
5050
Resque::setBackend($REDIS_BACKEND, $REDIS_BACKEND_DB);
51+
}
5152
}
5253

5354
$logLevel = false;
@@ -70,6 +71,9 @@ if($APP_INCLUDE) {
7071
require_once $APP_INCLUDE;
7172
}
7273

74+
// re-register the composer autoloader so that we use Resque here, in case APP_INCLUDE depends on a different version
75+
$loader->register();
76+
7377
// See if the APP_INCLUDE containes a logger object,
7478
// If none exists, fallback to internal logger
7579
if (!isset($logger) || !is_object($logger)) {

0 commit comments

Comments
 (0)