doublesecretagency / craft-viewcount

View Count plugin for Craft CMS
Other
6 stars 4 forks source link

[Craft 4]: userId can't be null #22

Closed JeanLucEsser closed 2 years ago

JeanLucEsser commented 2 years ago

When using the plugin in its simplest form, I came across this issue with Craft 4.

A page with {% do craft.viewCount.increment(entry.id) %} returns the following error:

TypeError
doublesecretagency\viewcount\services\View::_updateViewLog(): Argument #3 ($userId) must be of type int, null given, called in /app/vendor/doublesecretagency/craft-viewcount/src/services/View.php on line 78
tom-byrom commented 2 years ago

I found a similar issue/error when using the Total Views fieldtype in Craft 4 you cannot create new elements either from the dashboard or FE. I get a similar error to yours.

error: "doublesecretagency\\viewcount\\services\\Query::total(): Argument #1 ($elementId) must be of type int, null given, called in /srv/users/serverpilot/apps/staging-craft4-web-app/vendor/doublesecretagency/craft-viewcount/src/fields/TotalViews.php on line 118"
lindseydiloreto commented 2 years ago

This is fixed in v1.1.1. Thanks for reporting it! 👍

@tom-byrom That one is also fixed, as noted in #24.