craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

Message: Looping through element queries directly has been deprecated. #1983

Closed crazyx13th closed 7 years ago

crazyx13th commented 7 years ago

Description

I got an Deprecation Error Looping through element queries directly has been deprecated. I'm not using Twig, only the Element-API with NodeJS

Origin

/.../vendor/league/fractal/src/Scope.php:317

Stacktrace

13  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 /.../vendor/craftcms/cms/src/elements/db/ElementQuery.php:398
12  craft\elements\db\EntryQuery::getIterator()
Called from /.../vendor/league/fractal/src/Scope.php:317
11  League\Fractal\Scope::executeResourceTransformers()
Called from /.../vendor/league/fractal/src/Scope.php:234
10  League\Fractal\Scope::toArray()
Called from /.../vendor/craftcms/element-api/src/controllers/DefaultController.php:155
9   craft\elementapi\controllers\DefaultController::actionIndex("api/structure/faqs/<languageID:[a-z]{2}>")
8   call_user_func_array([craft\elementapi\controllers\DefaultController, "actionIndex"], ["api/structure/faqs/<languageID:[a-z]{2}>"])
Called from /.../vendor/yiisoft/yii2/base/InlineAction.php:57
7   yii\base\InlineAction::runWithParams(["pattern" => "api/structure/faqs/<languageID:[a-z]{2}>", "languageID" => "de", "p" => "api/structure/faqs/de"])
Called from /.../vendor/yiisoft/yii2/base/Controller.php:156
6   craft\elementapi\controllers\DefaultController::runAction("", ["pattern" => "api/structure/faqs/<languageID:[a-z]{2}>", "languageID" => "de", "p" => "api/structure/faqs/de"])
Called from /.../vendor/yiisoft/yii2/base/Module.php:523
5   craft\web\Application::runAction("element-api", ["pattern" => "api/structure/faqs/<languageID:[a-z]{2}>", "languageID" => "de", "p" => "api/structure/faqs/de"])
Called from /.../vendor/craftcms/cms/src/web/Application.php:241
4   craft\web\Application::runAction("element-api", ["pattern" => "api/structure/faqs/<languageID:[a-z]{2}>", "languageID" => "de", "p" => "api/structure/faqs/de"])
Called from /.../vendor/yiisoft/yii2/web/Application.php:102
3   craft\web\Application::handleRequest(craft\web\Request)
Called from /.../vendor/craftcms/cms/src/web/Application.php:206
2   craft\web\Application::handleRequest(craft\web\Request)
Called from /.../vendor/yiisoft/yii2/base/Application.php:380
1   craft\web\Application::run()
Called from /.../web/index.php:21

Additional info

Thanks!

Greetings crazyx13th

brandonkelly commented 7 years ago

Thanks. FFR please post plugin issues to their own repos (e.g. https://github.com/craftcms/element-api/issues)

crazyx13th commented 7 years ago

yeah... in the middle of this Ticket I thought the the same (After I noticed that it Element-API could be the small problem). Thanks!

crazyx13th commented 7 years ago

Origin

/var/www/vhosts/citis2go.com/cms.citis2go.com/vendor/craftcms/cms/src/controllers/EntriesController.php:250

Stacktrace

11  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 /.../vendor/craftcms/cms/src/elements/db/ElementQuery.php:398
10  craft\elements\db\EntryQuery::getIterator() 
Called from /.../vendor/craftcms/cms/src/controllers/EntriesController.php:250
9   craft\controllers\EntriesController::actionEditEntry("city", 54, null, null, ...)
8   call_user_func_array([craft\controllers\EntriesController, "actionEditEntry"], ["city", "54", null, null, ...]) 
Called from /.../vendor/yiisoft/yii2/base/InlineAction.php:57
7   yii\base\InlineAction::runWithParams(["sectionHandle" => "city", "entryId" => "54", "slug" => "-cp-town", "p" => "admin/entries/city/54-cp-town"]) 
Called from /.../vendor/yiisoft/yii2/base/Controller.php:156
6   craft\controllers\EntriesController::runAction("edit-entry", ["sectionHandle" => "city", "entryId" => "54", "slug" => "-cp-town", "p" => "admin/entries/city/54-cp-town"]) 
Called from /.../vendor/yiisoft/yii2/base/Module.php:523
5   craft\web\Application::runAction("entries/edit-entry", ["sectionHandle" => "city", "entryId" => "54", "slug" => "-cp-town", "p" => "admin/entries/city/54-cp-town"]) 
Called from /.../vendor/craftcms/cms/src/web/Application.php:241
4   craft\web\Application::runAction("entries/edit-entry", ["sectionHandle" => "city", "entryId" => "54", "slug" => "-cp-town", "p" => "admin/entries/city/54-cp-town"]) 
Called from /.../vendor/yiisoft/yii2/web/Application.php:102
3   craft\web\Application::handleRequest(craft\web\Request) 
Called from /.../vendor/craftcms/cms/src/web/Application.php:206
2   craft\web\Application::handleRequest(craft\web\Request) 
Called from /.../vendor/yiisoft/yii2/base/Application.php:380
1   craft\web\Application::run() 
Called from /.../web/index.php:21
crazyx13th commented 7 years ago

Origin

/var/www/vhosts/citis2go.com/cms.citis2go.com/vendor/craftcms/cms/src/fields/Matrix.php:442

Stacktrace

18  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 /.../vendor/craftcms/cms/src/elements/db/ElementQuery.php:398
17  craft\elements\db\MatrixBlockQuery::getIterator() 
Called from /.../vendor/craftcms/cms/src/fields/Matrix.php:442
16  craft\fields\Matrix::validateBlocks(craft\elements\Entry, null) 
Called from /.../vendor/craftcms/cms/src/base/Element.php:967
15  craft\elements\Entry::validateCustomFieldAttribute("apiEmailContentMatrix", [craft\fields\Matrix, "validateBlocks", null], yii\validators\InlineValidator)
14  call_user_func([craft\elements\Entry, "validateCustomFieldAttribute"], "apiEmailContentMatrix", [craft\fields\Matrix, "validateBlocks", null], yii\validators\InlineValidator) 
Called from /.../vendor/yiisoft/yii2/validators/InlineValidator.php:72
13  yii\validators\InlineValidator::validateAttribute(craft\elements\Entry, "apiEmailContentMatrix") 
Called from /.../vendor/yiisoft/yii2/validators/Validator.php:266
12  yii\validators\InlineValidator::validateAttributes(craft\elements\Entry, ["apiEmailContentMatrix"]) 
Called from /.../vendor/yiisoft/yii2/base/Model.php:358
11  craft\elements\Entry::validate() 
Called from /.../vendor/craftcms/cms/src/services/Elements.php:397
10  craft\services\Elements::saveElement(craft\elements\Entry) 
Called from /.../vendor/craftcms/cms/src/controllers/EntriesController.php:490
9   craft\controllers\EntriesController::actionSaveEntry()
8   call_user_func_array([craft\controllers\EntriesController, "actionSaveEntry"], []) 
Called from /.../vendor/yiisoft/yii2/base/InlineAction.php:57
7   yii\base\InlineAction::runWithParams(["p" => "admin/entries/apiOrder/982-api-order/c_de"]) 
Called from /.../vendor/yiisoft/yii2/base/Controller.php:156
6   craft\controllers\EntriesController::runAction("save-entry", ["p" => "admin/entries/apiOrder/982-api-order/c_de"]) 
Called from /.../vendor/yiisoft/yii2/base/Module.php:523
5   craft\web\Application::runAction("entries/save-entry", ["p" => "admin/entries/apiOrder/982-api-order/c_de"]) 
Called from /.../vendor/craftcms/cms/src/web/Application.php:241
4   craft\web\Application::runAction("entries/save-entry", ["p" => "admin/entries/apiOrder/982-api-order/c_de"]) 
Called from /.../vendor/craftcms/cms/src/web/Application.php:385
3   craft\web\Application::_processActionRequest(craft\web\Request) 
Called from /.../vendor/craftcms/cms/src/web/Application.php:201
2   craft\web\Application::handleRequest(craft\web\Request) 
Called from /.../vendor/yiisoft/yii2/base/Application.php:380
1   craft\web\Application::run() 
Called from /.../web/index.php:21
crazyx13th commented 7 years ago

sorry :-)