masugadesign / link-vault-craft-cms

The Link Vault download link protection plugin for Craft CMS v3.
Other
5 stars 2 forks source link

Link vault reports throws DateTime error when Download Date filter is applied #27

Closed maikbeeldr closed 3 weeks ago

maikbeeldr commented 4 weeks ago

Describe the bug
When generating a download report in Link Vault, I get the error 'Object of class DateTime could not be converted to string' when I apply the Download Date filter in my filter criteria. The attribute() function on line 182 in /vendor/masugadesign/linkvault/src/templates/_reports.twig expects a string instead of the date object provided.

Craft Version & Installed Plugin Version
Craft: 4.12.3 Plugin: 4.0.4

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Link Vault' and then 'Download History Reporting'
  2. Click on the filter and select Download Date, enter a date value
  3. See error below Screenshot 2024-10-17 at 11 53 19

Expected behavior
A correctly working filtered result set shown in the CraftCMS backend under Download History Reporting.

Additional context
I've quick fixed the error with the out-commented line in the screenshot above. But this fix will get lost when running composer install / update again.

{% for fieldName,value in criteria %}
    <td class="filtered" >{{  attribute(download, fieldName) }}</td> {# Throws error #}
    {#      <td class="filtered">{{ fieldName == 'dateCreated' ? download.dateCreated|date("m/d/Y") : attribute(download, fieldName) }}</td> Works  #}
{% endfor %}`

Screenshots See above, seen under URL /admin/linkvault/reports?criteria%5B0%5D%5BfieldHandle%5D=dateCreated&criteria%5B0%5D%5BfilterType%5D=is+greater+than&criteria%5B0%5D%5Bvalue%5D=2024-01-01&title=

benjaminkohl commented 4 weeks ago

Thank you for reporting this! I just released Link Vault 4.0.5 with the fix for this issue. I will release a similar fix for the Craft 5 version as well.

benjaminkohl commented 4 weeks ago

It just occurred to me I forgot to update the changelog file but the release does exist.