dereuromark / cakephp-queue

Queue plugin for CakePHP - simple, pure PHP and without dependencies.
MIT License
307 stars 136 forks source link

TaskFinder fails to find tasks if app directory is not 'src' #379

Closed fabian-mcfly closed 1 year ago

fabian-mcfly commented 1 year ago

Introduced with changes for the issue https://github.com/dereuromark/cakephp-queue/issues/371 ("Organize task in sub folders"), the following code breaks when the app source code is not inside of the folder "src". For plugins this works fine but for the base application the constant "APP_DIR" must be used.

https://github.com/dereuromark/cakephp-queue/blob/26014bfaa211fd34a5f3cdff434a00b311cb1932/src/Queue/TaskFinder.php#L96-L100

Sorry :o

fabian-mcfly commented 1 year ago

A solution could be


$pos = strpos($path, 'src/Queue/Task/');
if ($pos) {
    $name = substr($path, $pos + strlen('src/Queue/Task/'), -8);
}
else {
    $pos = strpos($path, APP_DIR . '/Queue/Task/');
    if (!$pos) {
        continue;
    }
    $name = substr($path, $pos + strlen(APP_DIR . '/Queue/Task/'), -8);
}
dereuromark commented 1 year ago

What case would have them not in src/ ? Can u make a PR?