nystudio107 / craft-similar

Similar for Craft lets you find elements, Entries, Categories, Commerce Products, etc, that are similar, based on... other related elements.
https://nystudio107.com/
MIT License
26 stars 5 forks source link

Deprecation error #7

Closed bartrylant closed 6 years ago

bartrylant commented 6 years ago

When setting limit criteria like this: {% set limitCriteria = craft.entries.limit(4) %}, there will be a deprecation error in the CP:

Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping over them.
Plugin Version
Craft edition & version Craft Pro 3.0.18
Similar 1.0.2
Anubarak commented 6 years ago

Could you maybe show a stack trace of something? Because there are actually only 2 loops in the plugin, one is executed right after all() the other one is Yii::configure() and would be a bug in the framework

bartrylant commented 6 years ago

Deprecation error: Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping over them. Called from /srv/users/knvvl/apps/knvvl-app/vendor/craftcms/cms/src/elements/db/ElementQuery.php:456

craft\elements\db\MatrixBlockQuery::getIterator() Called from /srv/users/knvvl/apps/knvvl-app/storage/runtime/compiled_templates/92/9227cac0471c9ba93712391d95351d6bf944a96fd3cf41bbbec1363f42d48c91.php:228

__TwigTemplate_f4e1c47be3ea8ca02230b12a82622ca43acbcadce58a6c968e7d74cdae0a98e9::macro_moreEntry(craft\elements\Entry, 2, "") Called from /srv/users/knvvl/apps/knvvl-app/storage/runtime/compiled_templates/92/9227cac0471c9ba93712391d95351d6bf944a96fd3cf41bbbec1363f42d48c91.php:80

__TwigTemplate_f4e1c47be3ea8ca02230b12a82622ca43acbcadce58a6c968e7d74cdae0a98e9::doDisplay(["entry" => craft\elements\Entry, "variables" => ["entry" => craft\elements\Entry], "view" => craft\web\View, "SORT_ASC" => 4, ...], []) Called from /srv/users/knvvl/apps/knvvl-app/vendor/twig/twig/lib/Twig/Template.php:390

...

Anubarak commented 6 years ago

The stack trace is about a matrix block query, your code about an entry query. Are you really sure this is related?

khalwat commented 6 years ago

Not seeing any deprecation errors coming from Similar