Description
I have the following endpoint set up:
'api/countries.json' => [
'elementType' => Tag::class,
'criteria' => [
'group' => 'blogCountries',
],
'paginate' => true,
'elementsPerPage' => 10,
'pageParam' => 'pg',
'transformer' => function (Tag $tag) {
return [
'title' => $tag->title,
'id' => $tag->id,
];
},
],
Accessing the endpoint at https://uwcblogs.dev/api/countries.json?pg=1 returns an exception:
2017-04-18 19:50:05 [192.168.10.1][1][vtdovftj2juuhu89hgnnken79d][error][yii\base\ErrorException:2] yii\base\ErrorException: Illegal string offset 'page' in /home/vagrant/sites/uwcblogs.com/vendor/craftcms/element-api/src/PaginatorAdapter.php:133
Stack trace:
#0 /home/vagrant/sites/uwcblogs.com/vendor/league/fractal/src/Scope.php(265): League\Fractal\Serializer\ArraySerializer->paginator()
#1 /home/vagrant/sites/uwcblogs.com/vendor/craftcms/element-api/src/controllers/DefaultController.php(89): League\Fractal\Scope->toArray()
#2 /home/vagrant/sites/uwcblogs.com/vendor/yiisoft/yii2/base/InlineAction.php(57): craft\elementapi\controllers\DefaultController->actionIndex()
#3 /home/vagrant/sites/uwcblogs.com/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/home/vagrant/sites/uwcblogs.com/vendor/yiisoft/yii2/base/InlineAction.php:57}()
#4 /home/vagrant/sites/uwcblogs.com/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams()
#5 /home/vagrant/sites/uwcblogs.com/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction()
#6 /home/vagrant/sites/uwcblogs.com/vendor/craftcms/cms/src/web/Application.php(246): yii\base\Module->runAction()
#7 /home/vagrant/sites/uwcblogs.com/vendor/yiisoft/yii2/web/Application.php(102): craft\web\Application->runAction()
#8 /home/vagrant/sites/uwcblogs.com/vendor/craftcms/cms/src/web/Application.php(211): yii\web\Application->handleRequest()
#9 /home/vagrant/sites/uwcblogs.com/vendor/yiisoft/yii2/base/Application.php(380): craft\web\Application->handleRequest()
#10 /home/vagrant/sites/uwcblogs.com/public/index.php(22): yii\base\Application->run()
#11 {main}
The exception is only thrown when the number of countries exceeds the allowed 'elementsPerPage', i.e. when there would be multiple pages.
Turning pagination off also removes the issue.
Additional info
- Craft version: Craft 3-beta.12
- PHP version: 7.1.4
- Database driver & version: MySQL 5.7.17
- Plugins & versions: Element Api 2.0.1
Description
I have the following endpoint set up:
Accessing the endpoint at
https://uwcblogs.dev/api/countries.json?pg=1returns an exception:The exception is only thrown when the number of countries exceeds the allowed
'elementsPerPage', i.e. when there would be multiple pages.Turning pagination off also removes the issue.
Additional info