cms icon indicating copy to clipboard operation
cms copied to clipboard

Wrong return type of parse and parseLoop functions

Open kevinmeijer97 opened this issue 3 years ago • 3 comments

Bug description

The parse() and parseLoop functions in vendor/statamic/cms/src/Tags/Tags.php return an array when $this->parser is false. Resulting in array to string conversions while using blade.

How to reproduce

Run the parse functions without a parser.

Logs

No response

Versions

Statamic 3.3.16 Pro Laravel 8.83.6 PHP 8.1.7 doublethreedigital/simple-commerce 3.2.11 edalzell/blade-directives 3.7 spatie/statamic-responsive-images 2.12.3

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

No response

Additional details

Returning an empty string should be fine.

kevinmeijer97 avatar Jun 21 '22 12:06 kevinmeijer97

Can you be more specific with your problem? Which tag is giving your an issue?

jasonvarga avatar Jun 21 '22 14:06 jasonvarga

After update 3.3.14 the Statamic::tag('{tag}')->fetch() causes this error. In vendor/statamic/cms/src/Tags/FluentTag.php inside the fetch() function there is a call to the load() function. In the parameters for this function the 'parser' parameter is now null.

That means whenever it reaches the parse() function in src/Tags/Tags.php it will return the $data because the $this->parser is false, and this causes a array to string conversion error because the return is expected to be a string.

If this isn't specific enough i will create a repo somewhere tomorrow to give you a better example, let me know :)

kevinmeijer97 avatar Jun 21 '22 14:06 kevinmeijer97

I understand that, but which tag are you using? A custom one?

jasonvarga avatar Jun 21 '22 15:06 jasonvarga

I'm going to close this issue since it's been open for over a year and there hasn't been a response to the last comment.

However, if you're still having issues with this and you're able to provide steps to reproduce, then feel free to re-open.

duncanmcclean avatar Nov 20 '23 21:11 duncanmcclean