barrelstrength / sprout

Sprout Marketing Suite modules for Craft CMS applications
https://sprout.barrelstrengthdesign.com
Other
2 stars 9 forks source link

PHP error Call to a member function setTimezone() on bool #208

Open jamesmacwhite opened 3 years ago

jamesmacwhite commented 3 years ago

Description

Error: Call to a member function setTimezone() on bool in /app/vendor/barrelstrength/sprout-base-reports/src/services/Reports.php:185
Stack trace:
#0 /app/vendor/barrelstrength/sprout-base-reports/src/elements/Report.php(529): barrelstrength\sproutbasereports\services\Reports->getUtcDateTime(Array)
barrelstrength/craft-sprout-reports#66 /app/vendor/barrelstrength/sprout-forms/src/integrations/sproutreports/datasources/EntriesDataSource.php(86): barrelstrength\sproutbasereports\elements\Report->getStartEndDate()
barrelstrength/craft-sprout-base-reports#2 /app/vendor/barrelstrength/sprout-base-reports/src/controllers/ReportsController.php(160): barrelstrength\sproutforms\integrations\sproutreports\datasources\EntriesDataSource->getResults(Object(barrelstrength\sproutbasereports\elements\Report))
barrelstrength/craft-sprout-base-reports#3 [internal function]: barrelstrength\sproutbasereports\controllers\ReportsController->actionResultsIndexTemplate(Object(barrelstrength\sproutbasereports\elements\Report), 294240)
barrelstrength/craft-sprout-base-reports#4 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
barrelstrength/craft-sprout-base-reports#5 /app/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
barrelstrength/craft-sprout-base-reports#6 /app/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('results-index-t...', Array)
barrelstrength/craft-sprout-base-reports#7 /app/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('results-index-t...', Array)
barrelstrength/craft-sprout-base-reports#8 /app/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('sprout-base-rep...', Array)
barrelstrength/craft-sprout-reports#96 /app/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('sprout-base-rep...', Array)
barrelstrength/craft-sprout-base-reports#10 /app/vendor/craftcms/cms/src/web/Application.php(259): yii\web\Application->handleRequest(Object(craft\web\Request))
barrelstrength/craft-sprout-reports#100 /app/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
barrelstrength/craft-sprout-base-reports#12 /app/web/index.php(23): yii\base\Application->run()
barrelstrength/craft-sprout-base-reports#13 {main}

Steps to reproduce

Export a Sprout Forms report from the Craft Admin CP.

Additional info

jamesmacwhite commented 3 years ago

This seems to be triggered based on certain environment conditions or parameters. It happens on my dev using Craft CMS docker images, but not on our staging environment.

Dumping $dateSetting, it appears there is no date or time value being set.

/app/vendor/barrelstrength/sprout-base-reports/src/services/Reports.php:185:
array (size=3)
  'date' => string '' (length=0)
  'timezone' => string 'Europe/London' (length=13)
  'time' => string '' (length=0)
jamesmacwhite commented 3 years ago

I think I know what's going on, I'm not putting a start or end date deliberately as I want to get all records without any date limiting criteria, however it appears this might be an issue, although start and end date isn't a mandatory field when creating the report.