Cphalcon: [BUG]: Undefined index: di

Created on 22 Dec 2019  路  10Comments  路  Source: phalcon/cphalcon

Describe the bug
QueryBuilder Paginator generate notice during paginate() call. Inside travis build.

PHP Notice:  Undefined index: di in /home/travis/build/phalcon/vokuro/src/Controllers/UsersController.php on line 59

To Reproduce
Steps to reproduce the behavior:

  1. Init builder via Criteria::fromInput()
  2. Pass created builder to Phalcon\Paginator\Adapter\QueryBuilder
  3. Call $paginator->paginate()

Provide minimal script to reproduce the issue

use Phalcon\Mvc\Model\Criteria;
use Phalcon\Paginator\Adapter\QueryBuilder as Paginator;
use Vokuro\Models\Users;

$builder = Criteria::fromInput($this->getDI(), Users::class, $this->request->getQuery());

$paginator = new Paginator([
    'builder'  => $builder->createBuilder(),
    'limit' => 10,
    'page'  => $this->request->getQuery('page', 'int', 1),
]);

$this->view->setVar('page', $paginator->paginate()); // Here is PHP Notice

Expected behavior
Code runs without PHP Norice.

Details

  • Phalcon version: 4.0.0
  • PHP Version: 7.2.24
  • Operating System: Ubuntu 18
  • Installation type: installing via package manager
  • Zephir version (if any):
  • Server: Other
  • Other related info (Database, table schema):

Additional context
https://travis-ci.com/phalcon/vokuro/jobs/269569381#L681

bug low

All 10 comments

Resolved

This is still happening BTW. This is not resolved. I get the errors when accessing the data from a view variable that is set with:

$this->view->setVar('example','Example::findFirst(['blah_blah_opts'])

This view var is set AFTER I paginate(); the Model. I am using the Model Adapter for this. Running almost identical server setup as described in OP's ticket.

@eklect Are you using the latest Phalcon? This was addressed in 4.0.1 from what I see.

I currently am running 4.0.5

@eklect I tried reproducing this but am not having much luck.

I created this test based on the input of this issue:

https://github.com/niden/cphalcon/blob/T14639-undefined-index-di-2/tests/database/Paginator/Adapter/QueryBuilder/PaginateCest.php#L223

And the tests pass just fine:

https://github.com/niden/cphalcon/runs/511189972?check_suite_focus=true

(you can expand the MySQL test run - you will see it's all green).

Any more input you can offer?

My bug I saw wasn't on the QueryBuilder Adapter, but on the Model adapter. I was experiencing the same issues but on a different adapter. My suspicion is that the QueryBuilder bug was fixed, but there might be one on the Model Adapter? That's about as far as I got on troubleshooting it before writing a "quick & dirty" workaround.

Gotcha. I will write a test for the model one and see if I get a fail on it.

Ok Thanks for looking into that for me @niden . Appreciate the help greatly. Thank you again for all your hard work! Phalcon is my absolute fav!

Closing this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ruudboon picture ruudboon  路  3Comments

sharptry picture sharptry  路  3Comments

borisdelev picture borisdelev  路  3Comments

Yakovlev-Melarn picture Yakovlev-Melarn  路  3Comments

gytsen picture gytsen  路  3Comments