Skip to main content

Fatal error on One-off Event availability, caused by namespace handling in parseRestHandler

Environment

  • FluentBooking (free): 2.4.0
  • FluentBooking Pro: 2.4.0
  • PHP: 8.3

Issue
Adding available time to a Single One-off Event throws a fatal error:

Class "\FluentBookingPro\App\Http\Controllers\FluentBookingPro\App\Modules\SingleEvent\SingleEventController" does not exist

This happens consistently when opening the availability picker for a One-off Event. I've reproduced it after a full reinstall of both plugins from fresh downloads, so it isn't a corrupted install on my end.

In fluent-booking-pro/app/Core/Application.php, requireRouteFile() wraps the entire app/Http/Routes/api.php file in:

php

$router->namespace($this->bindings['__namespace__'] . '\App\Http\Controllers')->group(function($router) {
    require_once $this['path.http'] . 'Routes/api.php';
});

Every controller referenced in api.php lives in FluentBookingPro\App\Http\Controllers, except SingleEventController, which lives in FluentBookingPro\App\Modules\SingleEvent.

The actual namespace-prepending happens in the free plugin, in parseRestHandler() (vendor/wpfluent/framework/src/WPFluent/Foundation/Concerns/FoundationTrait.php):

php

if ($ns && str_contains($handler, $ns)) {
    if (strpos($handler, $ns) !== false) {
        $handler = trim(str_replace($ns, '', $handler), '\\');
    }
}

$handler = $ns ? $ns . '\\' . $handler : $handler;

For controllers that already live inside the group's namespace, the first block strips it off, and the second line correctly re-adds it once. For SingleEventController, which lives in a different namespace entirely, the first block finds nothing to strip, so the second line unconditionally glues the group's namespace onto the controller's already-complete namespace, producing the doubled string in the error.

Raiyan Marzan

Stephen BonnerΒ The issue is fixed in dev and an update will be released soon. Thanks for your patience!