Skip to content

Fatal PHP Errors: Incompatibility with strict type hinting in recent LibreNMS updates #5

@joachimd90

Description

@joachimd90

Recent updates to the LibreNMS core (specifically observed in version 26.5.1-dev.65+45dc04250) have introduced strict PHP return types and parameter type hinting in base controllers such as TableController, SelectController, and PaginatedAjaxController.

Because this plugin extends these core classes, it now triggers PHP Fatal Errors because the method signatures in the plugin no longer match the parent classes in the LibreNMS core.

To Reproduce

Steps to reproduce the behavior:

  • Update LibreNMS to a recent daily/dev version (e.g., 26.5.1-dev.65).
  • Run ./validate.php or try to load a page containing the widget.
  • See PHP Fatal error in logs or terminal.

Expected behavior

The plugin should be compatible with the strict type hinting required by the current LibreNMS core to prevent the entire application from crashing.

Error dump

PHP Fatal error: Declaration of DotMike\NmsCustomFields\Http\Controllers\Table\CustomFieldController::formatResponse($paginator) must be compatible with App\Http\Controllers\Table\TableController::formatResponse($paginator): Illuminate\Http\JsonResponse

PHP Fatal error: Declaration of DotMike\NmsCustomFields\Http\Controllers\Table\CustomFieldValueController::baseQuery($request) must be compatible with App\Http\Controllers\PaginatedAjaxController::baseQuery(Illuminate\Http\Request $request): Illuminate\Database\Eloquent\Builder|Illuminate\Database\Query\Builder

PHP Fatal error: Declaration of DotMike\NmsCustomFields\Http\Controllers\Table\CustomFieldValueController::generateCsvResponse($data, $headers, $filename) must be compatible with App\Http\Controllers\Table\TableController::generateCsvResponse(Illuminate\Support\Collection $data, array $headers, string $filename): Symfony\Component\HttpFoundation\StreamedResponse

The following methods (at minimum) need updated signatures to include type hints and return types:

formatResponse() -> needs : \Illuminate\Http\JsonResponse

baseQuery() -> needs \Illuminate\Http\Request $request and : \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder

formatItem() -> needs return types and specific parameter models.

searchFields() -> needs : array

generateCsvResponse() -> needs explicit parameter types for $data, $headers, and $filename.

Due to these errors, we were unable to run daily.sh or validate.php and had to manually purge the plugin to restore server operations.

Server Environment
LibreNMS: 26.5.1-dev
PHP: 8.2.31
OS: Rocky Linux 9.7

(Note: This issue was drafted with the assistance of AI to ensure all technical logs and requirements were captured accurately.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions