verbb / events

Craft CMS Plugin for events management and ticketing.
Other
22 stars 13 forks source link

craft.events.isTicket(item) broken between 1.1.1 and 1.1.6 #29

Closed chadcrowell closed 4 years ago

chadcrowell commented 5 years ago

Description

Im using this method in a Sprout Reports report that is twig template based. I recently ran Craft updates + plugin updates which included

Craft 3.1.31 > 3.3.3 Commerce 2.1.7 > 2.1.13 Events 1.1.1 > 1.1.6 Sprout Reports did not have an update

The report was working fine before this update. Since the update, this code:

{% set items = '' %}
    {% for item in order.lineItems %}
        {% if item and craft.events.isTicket(item) %}
            {% set ticket = item.purchasable %}
            {% set event = ticket.event %}
            {% set items = items~item.qty~' - '~event.title~' - '~ticket.name~lb %}
        {% else %}
            {% set purchasable = item.purchasable %}
            {% set product = purchasable.product %}
            {% set items = items~item.qty~' - '~product.title~lb %}
        {% endif %}
    {% endfor %}

generates this error:

yii\base\ErrorException: get_class() expects parameter 1 to be object, null given in /Users/Chad/Sites/stemple-creek/vendor/verbb/events/src/variables/EventsVariable.php:94
Stack trace:
#0 /Users/Chad/Sites/stemple-creek/vendor/verbb/events/src/variables/EventsVariable.php(94): ::get_class()
#1 /Users/Chad/Sites/stemple-creek/vendor/twig/twig/src/Extension/CoreExtension.php(1485): verbb\events\variables\EventsVariable->isTicket()
#2 /Users/Chad/Sites/stemple-creek/vendor/craftcms/cms/src/helpers/Template.php(105): ::twig_get_attribute()
#3 /Users/Chad/Sites/stemple-creek/storage/runtime/compiled_templates/88/88ab57a3732fdfcaa9d4132b0a9b637293e94bb007972294b7a8d9774f3df5f3.php(121): craft\helpers\Template::attribute()
#4 /Users/Chad/Sites/stemple-creek/vendor/twig/twig/src/Template.php(407): __TwigTemplate_feebf5c4c6a9c5e0670697c60092e9e64ecc6e0aa837e63f7fa867e93f8131de->doDisplay()
#5 /Users/Chad/Sites/stemple-creek/vendor/twig/twig/src/Template.php(380): __TwigTemplate_feebf5c4c6a9c5e0670697c60092e9e64ecc6e0aa837e63f7fa867e93f8131de->displayWithErrorHandling()
#6 /Users/Chad/Sites/stemple-creek/vendor/twig/twig/src/Template.php(392): __TwigTemplate_feebf5c4c6a9c5e0670697c60092e9e64ecc6e0aa837e63f7fa867e93f8131de->display()
#7 /Users/Chad/Sites/stemple-creek/vendor/twig/twig/src/TemplateWrapper.php(45): __TwigTemplate_feebf5c4c6a9c5e0670697c60092e9e64ecc6e0aa837e63f7fa867e93f8131de->render()
#8 /Users/Chad/Sites/stemple-creek/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render()
#9 /Users/Chad/Sites/stemple-creek/vendor/craftcms/cms/src/web/View.php(344): craft\web\twig\Environment->render()
#10 /Users/Chad/Sites/stemple-creek/vendor/barrelstrength/sprout-reports/src/datasources/CustomTwigTemplate.php(205): craft\web\View->renderTemplate()
#11 /Users/Chad/Sites/stemple-creek/vendor/barrelstrength/sprout-reports/src/datasources/CustomTwigTemplate.php(52): barrelstrength\sproutreports\datasources\CustomTwigTemplate->processFrontEndResultsTemplate()
#12 /Users/Chad/Sites/stemple-creek/vendor/barrelstrength/sprout-base-reports/src/controllers/ReportsController.php(138): barrelstrength\sproutreports\datasources\CustomTwigTemplate->getDefaultLabels()
#13 /Users/Chad/Sites/stemple-creek/vendor/yiisoft/yii2/base/InlineAction.php(57): barrelstrength\sproutbasereports\controllers\ReportsController->actionResultsIndexTemplate()
#14 /Users/Chad/Sites/stemple-creek/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/Users/Chad/Sites/stemple-creek/vendor/yiisoft/yii2/base/InlineAction.php:57}()
#15 /Users/Chad/Sites/stemple-creek/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams()
#16 /Users/Chad/Sites/stemple-creek/vendor/craftcms/cms/src/web/Controller.php(187): barrelstrength\sproutbasereports\controllers\ReportsController->runAction()
#17 /Users/Chad/Sites/stemple-creek/vendor/yiisoft/yii2/base/Module.php(528): barrelstrength\sproutbasereports\controllers\ReportsController->runAction()
#18 /Users/Chad/Sites/stemple-creek/vendor/craftcms/cms/src/web/Application.php(299): craft\web\Application->runAction()
#19 /Users/Chad/Sites/stemple-creek/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction()
#20 /Users/Chad/Sites/stemple-creek/vendor/craftcms/cms/src/web/Application.php(284): craft\web\Application->handleRequest()
#21 /Users/Chad/Sites/stemple-creek/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest()
#22 /Users/Chad/Sites/stemple-creek/public_html/index.php(21): craft\web\Application->run()
#23 {main}

https://d.pr/i/RwpeJD

So, the report won't work at this time.

engram-design commented 4 years ago

I've fixed this in 1.1.7, but its also likely that there's a larger issue. The purchasable for the line item is reporting back as null - possibly the purchasable (whatever that might've been) no longer exists in Commerce, and had been deleted?

It'll not throw an error now in any case.