Skip to content

$files->render() returns an empty string instead of an empty array #2116

@BernhardBaumrock

Description

@BernhardBaumrock

I'm using $files->render() in RockFrontend to get the result of AJAX endpoints. If the endpoint returns an array, RockFrontend will automatically set the content type to application/json.

Today I realised that if my file returns an empty array, ProcessWire will not return an empty array but an empty string!

This is ok:

// foo.php
return ['foo' => 'foo'];

// render-foo.php
$result = $files->render(__DIR__ . '/foo.php');

// result will be ['foo' => 'foo']

This is not:

// bar.php
return [];

// render-bar.php
$result = $files->render(__DIR__ . '/bar.php');

// result will be '' and not []

@ryancramerdesign is this intentional?

I have added a workaround in RockFrontend but I think when the files returns and empty array the result should be an empty array and not an empty string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions