The bug I ran into looks an awful lot like #2887562-8: Filename not applied when downloading cached export. however the patch from this previous issue has already been applied to 8.x-1.0-beta3 so I am opening a new issue.

Adding a token to the filename causes the following error to be thrown:

Uncaught PHP Exception LogicException: "The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Cache\CacheableResponse." at web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php line 154

Removing the token from the filename cases the data export to work as expected.

Comments

Beanjammin created an issue. See original summary.

sokru’s picture

Faced the same problem. Everything worked fine when I first time created the view with token in filename, but when I exported the views (config) to another site it gave this same error message.

tunaman’s picture

Had this problem. It was to do with one of the date tokens. I changed it to use a custom date format instead [date:custom:Ymd] then it worked again.

santimg’s picture

Hi all, just had the same problem. I fixed it applying this workaround:

        // Add date to filename programmatically to avoid early rendering
        // issues caused by tokens.
        $file_date = '_' . date('Y-m-d') . '.csv';
        $view->display_handler->options['filename'] = str_replace('.csv', $file_date, $view->display_handler->options['filename']);

I placed this bit of code into a hook_views_post_render() and it worked for me. Hope it helps!

colan’s picture

Issue summary: View changes

Switched to d.o markup for the related issue link.

steven jones’s picture

Status: Active » Closed (cannot reproduce)

Seems like this is the same as the error in #3194967: Export using date tokens is not working - cache metadata error?

If you can give the steps for reproducing, then we can take a look.