phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.79k stars 1.96k forks source link

[BUG]: View: return value of getActiveRenderPath() | low priority #16614

Open TerraTux opened 5 months ago

TerraTux commented 5 months ago

Describe the bug If there's only one viewsDir and more than one renderEngines registered, then getActiveRenderPath() only returns the path with the extension of the first registered renderEngine.

To Reproduce

// during setup of the view service (simplified):

$view->setRenderPath([
    '/path/to/modules'
]);

$view->registerEngines([
    '.volt'     => $volt,       // Phalcon\Mvc\View\Engine\Volt
    '.phtml'    => $php         // Phalcon\Mvc\View\Engine\Php
]);
// ...

then when catching the view:notFoundView event:

public function notFoundView($event)
{
    $notFound = $event->getSource()->getActiveRenderPath();
    if (is_array($notFound))
    {
        // ...
    }

    // more dots...
}

But $notFound never is an array with such setup and only contains (string) '/path/to/modules/moduleName/views/missing_file.volt' while when dumping $view there are both absolute paths with each extension.

This behavior is very obvious in View.zep on Lines 337-341

Setting the renderPath twice to bypass this behavior also duplicates the activeRenderPaths

Expected behavior getActiveRenderPath(): array|string should either really return all possible paths independend from the num of viewDirs, or could get a flag to return the protected variable as it is.

Details Phalcon 5.6.1 on PHP 8.3.8