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]: Volt Render Notice : Undefined index: name #16097

Closed
kevcomparadise opened this issue Sep 16, 2022 · 8 comments · Fixed by #16187
Closed

[BUG]: Volt Render Notice : Undefined index: name #16097

kevcomparadise opened this issue Sep 16, 2022 · 8 comments · Fixed by #16187
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: high High

Comments

@kevcomparadise
Copy link

kevcomparadise commented Sep 16, 2022

Describe the bug
When we try to access a public method of a sub class contained in a public property of a root class, Volt generates a Notice.
PS : Return value OK

To Reproduce
Steps to reproduce the behavior:

  • 1 : Create Controller and pass to volt an object contain an sub-object
class TestController extend Controller {

   public function indexAction()
   {

       $subObject = new class {

            public function getValue() {
                return 'Value';
            }

        };

        $rootObject = new class ($subObject) {

            public $sub_object = null;

            public function __construct($subObject)
              {
                  $this->sub_object =  $subObject;
              }
        };

        $this->view->testObject = $rootObject
  }
}
  • 2 : Create related view (/test/index.volt)
{{ testObject.sub_object.getValue() }}

Note : If we use a getter for sub_object (like : getsubObject()) it work

Expected behavior
Render without notice

Details

  • Phalcon version: 5.0RC4
  • PHP Version: 8.1.6
  • Operating System: Debian
  • Installation type: installing via package manager (PECL)
  • Server: Apache
@kevcomparadise kevcomparadise added bug A bug report status: unverified Unverified labels Sep 16, 2022
@niden
Copy link
Member

niden commented Sep 16, 2022

Does it work if you use different files for classes vs the new class syntax?

I have not tested this but I am not sure Volt works with that (yet).

@kevcomparadise
Copy link
Author

Does it work if you use different files for classes vs the new class syntax?

I have not tested this but I am not sure Volt works with that (yet).

Nop same result
This work with Phalcon 3.4

@colinpieper
Copy link

I'm also experiencing this issue (in v5.0.2). A workaround that seems to work for my situation is to first set a variable, and then display that variable. Using your example:

Change:

{{ testObject.sub_object.getValue() }}

To:

{% set foo = testObject.sub_object.getValue() %}
{{ foo }}

@rtiagom
Copy link

rtiagom commented Oct 7, 2022

same problem here. The solution @colinpieper mentioned works but far from ideal especially when you have many templates, like @kevcomparadise said this used to work in Phalcon 3.4.5. Can we expect this to be fixed soon?

@niden niden self-assigned this Oct 10, 2022
@niden niden added status: high High 5.0 The issues we want to solve in the 5.0 release and removed status: unverified Unverified labels Oct 10, 2022
@niden niden added this to Phalcon v5 Oct 10, 2022
@niden niden moved this from Backlog to In Progress in Phalcon v5 Oct 10, 2022
@niden niden moved this to Backlog in Phalcon v5 Oct 10, 2022
@palcoder
Copy link

I have the same issue and the releases from v5.0.0RC4 to v5.0.4 have the issue but the release v5.0.0RC3 works fine

@ccc-nghia-le
Copy link

Any update on when this will be fixed please?

@niden
Copy link
Member

niden commented Oct 25, 2022

We are working on this one guys. Hopefully we can figure out where it comes from.

I checked a bit the code and it seems to fail in the code to ob_start() so that might be happening in Zephir.

@niden niden linked a pull request Oct 26, 2022 that will close this issue
5 tasks
@niden
Copy link
Member

niden commented Oct 26, 2022

This has been resolved in #16187.

Thank you @kevcomparadise @colinpieper

@niden niden closed this as completed Oct 26, 2022
Repository owner moved this from In Progress to Implemented in Phalcon v5 Oct 26, 2022
@niden niden moved this from Implemented to Released in Phalcon v5 Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: high High
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants