Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Undefined index: di #14639

Closed
Jeckerson opened this issue Dec 22, 2019 · 10 comments
Closed

[BUG]: Undefined index: di #14639

Jeckerson opened this issue Dec 22, 2019 · 10 comments
Assignees
Labels
bug A bug report status: low Low

Comments

@Jeckerson
Copy link
Member

Jeckerson commented Dec 22, 2019

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

@ruudboon ruudboon added the 4.0 label Dec 22, 2019
@ruudboon ruudboon self-assigned this Dec 22, 2019
ruudboon added a commit that referenced this issue Dec 22, 2019
@niden
Copy link
Member

niden commented Dec 22, 2019

Resolved

@niden niden closed this as completed Dec 22, 2019
@niden niden added bug A bug report status: low Low and removed Bug - Low labels Dec 23, 2019
niden pushed a commit that referenced this issue Jan 21, 2020
niden pushed a commit that referenced this issue Feb 4, 2020
@eklect
Copy link

eklect commented Mar 6, 2020

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.

@niden niden reopened this Mar 6, 2020
@niden
Copy link
Member

niden commented Mar 10, 2020

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

@eklect
Copy link

eklect commented Mar 11, 2020

I currently am running 4.0.5

@niden
Copy link
Member

niden commented Mar 16, 2020

@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?

@eklect
Copy link

eklect commented Mar 16, 2020

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.

@niden
Copy link
Member

niden commented Mar 16, 2020

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

@eklect
Copy link

eklect commented Mar 17, 2020

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!

niden added a commit that referenced this issue Mar 17, 2020
niden added a commit that referenced this issue Mar 17, 2020
niden added a commit that referenced this issue Mar 17, 2020
@niden
Copy link
Member

niden commented Mar 17, 2020

Closing this

@niden niden closed this as completed Mar 17, 2020
niden added a commit that referenced this issue Mar 20, 2020
* '4.0.x' of github.com:phalcon/cphalcon: (62 commits)
  [#13655] - Added more tests
  [#13655] - Added one more test for get/set
  [#13655] - Hangout test!!
  [4.0.x] - Minor refector
  [4.0.x] - Correcting test
  [4.0.x] - Minor correction
  [4.0.x] - Updated Request tests
  [#14639] - Added test for model paginate
  [#14639] - Trying phpunit 8.5
  [#14639] - Removed sqlite from test
  [#14639] - Added test
  [#14907] - Updated changelog
  [#14907] - Removed cache parsing from Volt
  [#14912] - Updated changelog [ci-skip]
  [#14912] - Updated changelog
  [#14912] - Removed iconv from Volt::convertEncoding
  Deleted Makefile
  [#14866] - Enabling tests
  [#14866] - Updated changelog
  [#14866] - Changed the friendlyTitle to not rely on iconv
  ...
niden added a commit that referenced this issue May 16, 2020
niden added a commit that referenced this issue May 16, 2020
niden added a commit that referenced this issue May 16, 2020
@niden niden moved this to Released in Phalcon v5 Aug 25, 2022
@niden niden added this to Phalcon v5 Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
Archived in project
Development

No branches or pull requests

4 participants