Cannot use object type stdClass as array in classes/statistics/

I’m using OJS version 3.1.2-1
When generating a custom statistics report I get a warning then an error see error log below. The result is just a blank page with a 500 error.
If this is a permission error which directory would this be writing too? It already has write permissions to the cache directory so I’m a bit confused.

[Wed Jan 15 12:14:50.437308 2020] [php7:warn] PHP Warning: file_put_contents(cache/fc-pluginSettings-0-defaultthemeplugin.php): failed to open stream: Permission denied in lib/pkp/classes/cache/ on line 90

PHP Fatal error: Uncaught Error: Cannot use object of type stdClass as array in classes/statistics/
Stack trace:
#0 plugins/generic/usageStats/ MetricsDAO->getMetrics(‘ojs::counter’, Array, Object(stdClass), Array, NULL)
#1 plugins/generic/usageStats/ PKPUsageStatsReportPlugin->getMetrics(‘ojs::counter’, Array, Object(stdClass), Array, NULL)
#2 /lib/pkp/pages/management/ OJSUsageStatsReportPlugin->getMetrics(‘ojs::counter’, Array, Object(stdClass), Array)
#3 /lib/pkp/pages/management/ PKPToolsHandler->generateReport(Array, Object(Request))
#4 /lib/pkp/classes/core/ PKPToolsHandler->tools(Array, Object(Request))
#5 /lib/pkp in /classes/statistics/ on line 34, referer: /management/tools/reportGenerator

Just flagging this! Our custom reports are failing for all of our journals - we’re not sure if this started with our upgrade to 3.1.2-1, but it’s consistent across all of our journals. Other stats reports are still working, but custom reports just generate a 500 error. jhennig (above) captured some error messages from the log, but we need help decoding them and trying to id the problem.

Thanks for any help anyone can provide!

Hi all,

I suspect you need to apply pkp/pkp-lib#5302 Cast stdClass to array to avoid warnings · pkp/pkp-lib@8486017 · GitHub to resolve this. (Please check to see if the patch will apply cleanly e.g. using the --dry-run option to the patch tool before you actually apply it.)

Note that this is already included in OJS since version 3.1.2-3, so upgrading is also an option.

Alec Smecher
Public Knowledge Project Team

Thanks @asmecher - we’ll give that a try and see if it resolves the issue!

1 Like

You may also need this one as well:

If you run custom reports with date ranges.


1 Like