After configuring the Matomo token auth and site id in the Matomo configuration, I get this when I go to run a report:

LogicException: The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller? in Symfony\Component\HttpKernel\HttpKernel->handleRaw() (line 169 of /home/graffio/public_html/vendor/symfony/http-kernel/HttpKernel.php).

Comments

John Graffio created an issue. See original summary.

arefen’s picture

I have a same problem

LogicException: The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller? 
shelane’s picture

Status: Active » Postponed (maintainer needs more info)

I tested with Piwik 2.16.2 and Matomo 3.13.1 and have not been able to replicate this issue. All functions in the MatomoReportsController class have return statements. Please let me know what version of Piwik/Matomo you are using, that you have verified from other methods that the URL and token are accurate, and that the URL to your site is properly formatted (such as https://analytics.example.com/matomo/ in the description).

shadowwolf218’s picture

Confirming the same issue.

Environment:
Drupal 8.8.2
Matomo 3.13.3
MySQL (from Matomo) 5.7.28
PHP 7.2.24

Steps:
> Install Matomo 3.13.3 to web server, configure
> Install Matomo Analytics module to Drupal, enable and configure
> Install Matomo Reports module to Drupal, enable and configure

> Navigate to Matomo Web Analytics Reports tab
> "The website has encountered an unexpected error. Please try again later."
> Navigate to Recent Log Messages
> Find most recent error, as follows:

LogicException: The controller must return a response (null given). Did you forget to add a return statement somewhere in your controller? in Symfony\Component\HttpKernel\HttpKernel->handleRaw()

I checked the formatting for both the server URL and the Token Auth string. The former (URL) includes the trailing slash and points to the correct directory. The latter (token_auth) matches the string given in the Matomo Settings under Platform>API. I tried it both with and without the leading "&token_auth=", just for kicks...still nothing. Between each check, I made sure to clear the Drupal cache. I also listed "Allowed sites" as "1,2,3,4" although I'd rather leave that blank.

Interestingly, as I am writing this summary, I'm seeing a handful of "Warning: Illegal string offset ____ in Drupal\matomo_reports\Form\MatomoReportsSettings" where ____ = 'idsite' and 'name' - no idea if that's useful or not.

Hope this helps.

- Chris

  • shelane committed e063b71 on 8.x-1.x
    Issue #3107603: The controller must return a response
    
    Updates warning...
shelane’s picture

I made a couple of changes that I believe fixes the issue. If you are able to test the dev version and give feedback if you are still seeing the issue, that would be appreciated.

kimberlydb’s picture

The dev branch fixed this particular issue for me, but now that I added a token I am getting the following error:

Error: Call to undefined function Drupal\matomo_reports\Form\array_key_first() in Drupal\matomo_reports\Form\ReportsForm->buildForm()

shelane’s picture

I just learned that array_key_first is php 7.3 or later. @kimberlydb are you on 7.2? I’ll rewrite it to be compatible. Check for that later today.

kimberlydb’s picture

Yes, running 7.2.

  • shelane committed bd4389f on 8.x-1.x
    Issue #3107603: The controller must return a response
    
    Adds...
shelane’s picture

Status: Postponed (maintainer needs more info) » Fixed

I did a test with 7.2 and saw the error. I released a new beta version and called this issue fixed.

kimberlydb’s picture

I can confirm it's working now - thank you!

kimberlydb’s picture

Version: 8.x-1.x-dev » 8.x-1.0-beta3
Status: Fixed » Closed (fixed)