Error when compiling with module that has a custom get #1133

Open
opened 2024-05-16 22:30:42 +00:00 by kommid · 9 comments
Member

Steps to reproduce the issue

Compile a component with module, that has a cutom get (getCustom(s)). The compiler throws an error

Expected result

component and module are build

Actual result

compiler exits with error Call to a member function get() on null
libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php:449
I tried it with dynamic gets of type getCustoms and getCustom both render the same result, but when I remove the dynamic get from my module, everything compiles fine.
I had set up my module as explained in the video here https://www.youtube.com/watch?v=lriWW3Uzyc8 and everything was fine, but after I updated JCB (skipped many versions) it stopped working. Did I miss any changes on how this must be done?
As a workaround I guess, I can just query the database somewhere in my module helper or somewhere elese, but I think, this wouldn't be the way it's intended

System information (as much as possible)

  • OS Name & Version: Debian 11
  • MySql Version: 10.5.23-MariaDB-0+deb11u1
  • Apache Version: 2.4
  • PHP Version: 8.0.30
  • Joomla Version: 3.10.12
  • JCB Version: 3.2.1
  • Browser: Firefox

Additional comments

### Steps to reproduce the issue Compile a component with module, that has a cutom get (getCustom(s)). The compiler throws an error ### Expected result component and module are build ### Actual result compiler exits with error Call to a member function get() on null libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php:449 I tried it with dynamic gets of type getCustoms and getCustom both render the same result, but when I remove the dynamic get from my module, everything compiles fine. I had set up my module as explained in the video here https://www.youtube.com/watch?v=lriWW3Uzyc8 and everything was fine, but after I updated JCB (skipped many versions) it stopped working. Did I miss any changes on how this must be done? As a workaround I guess, I can just query the database somewhere in my module helper or somewhere elese, but I think, this wouldn't be the way it's intended ### System information (as much as possible) - OS Name & Version: Debian 11 - MySql Version: 10.5.23-MariaDB-0+deb11u1 - Apache Version: 2.4 - PHP Version: 8.0.30 - Joomla Version: 3.10.12 - JCB Version: 3.2.1 - Browser: Firefox ### Additional comments

Just wondering if you got a solution to this? I've got the same issue at the moment. JCB v3.1.28

Just wondering if you got a solution to this? I've got the same issue at the moment. JCB v3.1.28
Author
Member

Nope, unfortunately this still doesn't work and never got any help for this issue. Even upgraded my JCB to Joomla 5 but this is still broken. Either our question is too stupid to be answered or just no one cares...
I removed the custom get and moved my database query to the helper

Nope, unfortunately this still doesn't work and never got any help for this issue. Even upgraded my JCB to Joomla 5 but this is still broken. Either our question is too stupid to be answered or just no one cares... I removed the custom get and moved my database query to the helper

OK. Thanks for the reply. Have gone the same way and got a working module. I'm sticking with 3.1.28 and Joomla 3.x.x at the moment as I know it does what I want and one of my components is a very complex mix which I can't risk breaking. Even PHP 8.2 is a step too far…

OK. Thanks for the reply. Have gone the same way and got a working module. I'm sticking with 3.1.28 and Joomla 3.x.x at the moment as I know it does what I want and one of my components is a very complex mix which I can't risk breaking. Even PHP 8.2 is a step too far…
Owner

I’m sorry to hear that this issue has been persisting and that upgrading hasn’t made a difference. JCB is a very large and flexible tool, and sometimes certain features—like dynamic gets in modules—don’t see widespread use, which makes pinpointing these issues more challenging.

To help move this forward, could anyone who’s experienced this provide more specific details on what they’ve found so far?

Any concrete steps, error logs, or code snippets that you can share would make it much easier to track down the root cause. Once we have some focused details, we can start looking more closely at the relevant code paths and hopefully get a fix or at least a reliable workaround. I’m committed to seeing this resolved and appreciate any insights you can provide.

I’m sorry to hear that this issue has been persisting and that upgrading hasn’t made a difference. JCB is a very large and flexible tool, and sometimes certain features—like dynamic gets in modules—don’t see widespread use, which makes pinpointing these issues more challenging. To help move this forward, could anyone who’s experienced this provide more specific details on what they’ve found so far? Any concrete steps, error logs, or code snippets that you can share would make it much easier to track down the root cause. Once we have some focused details, we can start looking more closely at the relevant code paths and hopefully get a fix or at least a reliable workaround. I’m committed to seeing this resolved and appreciate any insights you can provide.

Thanks, Llewellyn, for looking at this. And, of course, all the effort and time you put into JCB. I'm running a similar system to kommid - Linux/CentOS, Apache 2.4, Joomla 3.10.12, PHP 8.0.30, MySQL 8.0.40

I've just added both a Custom Get and a Custom Gets and the trace is attached.

As mentioned in my post, I've got a work around so, to me, it's not a high priority. Unfortunately, at this level, understanding the code is way beyond my abilities. Thanks again - your commitment is appreciated.

Thanks, Llewellyn, for looking at this. And, of course, all the effort and time you put into JCB. I'm running a similar system to kommid - Linux/CentOS, Apache 2.4, Joomla 3.10.12, PHP 8.0.30, MySQL 8.0.40 I've just added both a Custom Get and a Custom Gets and the trace is attached. As mentioned in my post, I've got a work around so, to me, it's not a high priority. Unfortunately, at this level, understanding the code is way beyond my abilities. Thanks again - your commitment is appreciated.
2.9 KiB

Same problem…
My module is very basic. For the custom get I duplicated a "getListQuery" from my component and made it "getCustoms" type. The Custom name is "getWorlds". Then edited the module and selected it on Custom Gets, allowing the module code field to populate with the default code. I have "Add Class Helper" set to None. I added one config form with the default settings and selected my related form from the component. I add it to the component and then compile it with my component and get the error. I tried removing all entries on the Form tab and it still will not compile.
`
An error has occurred.
0 Call to a member function get() on null
Call Stack

Function Location

1 () JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php:514
2 VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data->getData() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php:264
3 VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data->set() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Model/Joomlamodules.php:69
4 VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules->VDM\Joomla\Componentbuilder\Compiler\Model{closure}()
5 array_map() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Model/Joomlamodules.php:64
6 VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules->set() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php:1186
7 VDM\Joomla\Componentbuilder\Compiler\Component\Data->setModules() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php:457
8 VDM\Joomla\Componentbuilder\Compiler\Component\Data->energize() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php:320
9 VDM\Joomla\Componentbuilder\Compiler\Component\Data->get() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Component.php:38
10 VDM\Joomla\Componentbuilder\Compiler\Component->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/Component.php:99
11 VDM\Joomla\Componentbuilder\Compiler\Service\Component->getCompilerComponent() JROOT/libraries/vendor/joomla/di/src/ContainerResource.php:166
12 Joomla\DI\ContainerResource->getInstance() JROOT/libraries/vendor/joomla/di/src/Container.php:95
13 Joomla\DI\Container->get() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Factory.php:48
14 VDM\Joomla\Abstraction\Factory::_() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Get.php:1111
15 VDM\Joomla\Componentbuilder\Compiler\Helper\Get->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Structure.php:419
16 VDM\Joomla\Componentbuilder\Compiler\Helper\Structure->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php:304
17 VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php:66
18 VDM\Joomla\Componentbuilder\Compiler\Helper\Infusion->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Compiler.php:84
19 VDM\Joomla\Componentbuilder\Compiler\Helper\Compiler->__construct() JROOT/administrator/components/com_componentbuilder/src/Model/CompilerModel.php:299
20 VDM\Component\Componentbuilder\Administrator\Model\CompilerModel->builder() JROOT/administrator/components/com_componentbuilder/src/Controller/CompilerController.php:129
21 VDM\Component\Componentbuilder\Administrator\Controller\CompilerController->compiler() JROOT/libraries/src/MVC/Controller/BaseController.php:730
22 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
23 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
24 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150
25 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:205
26 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:304
27 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58
28 require_once() JROOT/administrator/index.php:32`

Same problem… My module is very basic. For the custom get I duplicated a "getListQuery" from my component and made it "getCustoms" type. The Custom name is "getWorlds". Then edited the module and selected it on Custom Gets, allowing the module code field to populate with the default code. I have "Add Class Helper" set to None. I added one config form with the default settings and selected my related form from the component. I add it to the component and then compile it with my component and get the error. I tried removing all entries on the Form tab and it still will not compile. ` An error has occurred. 0 Call to a member function get() on null Call Stack # Function Location 1 () JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php:514 2 VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data->getData() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php:264 3 VDM\Joomla\Componentbuilder\Compiler\Joomlamodule\Data->set() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Model/Joomlamodules.php:69 4 VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules->VDM\Joomla\Componentbuilder\Compiler\Model\{closure}() 5 array_map() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Model/Joomlamodules.php:64 6 VDM\Joomla\Componentbuilder\Compiler\Model\Joomlamodules->set() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php:1186 7 VDM\Joomla\Componentbuilder\Compiler\Component\Data->setModules() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php:457 8 VDM\Joomla\Componentbuilder\Compiler\Component\Data->energize() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Component/Data.php:320 9 VDM\Joomla\Componentbuilder\Compiler\Component\Data->get() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Component.php:38 10 VDM\Joomla\Componentbuilder\Compiler\Component->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Service/Component.php:99 11 VDM\Joomla\Componentbuilder\Compiler\Service\Component->getCompilerComponent() JROOT/libraries/vendor/joomla/di/src/ContainerResource.php:166 12 Joomla\DI\ContainerResource->getInstance() JROOT/libraries/vendor/joomla/di/src/Container.php:95 13 Joomla\DI\Container->get() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Factory.php:48 14 VDM\Joomla\Abstraction\Factory::_() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Get.php:1111 15 VDM\Joomla\Componentbuilder\Compiler\Helper\Get->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Structure.php:419 16 VDM\Joomla\Componentbuilder\Compiler\Helper\Structure->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php:304 17 VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php:66 18 VDM\Joomla\Componentbuilder\Compiler\Helper\Infusion->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Compiler.php:84 19 VDM\Joomla\Componentbuilder\Compiler\Helper\Compiler->__construct() JROOT/administrator/components/com_componentbuilder/src/Model/CompilerModel.php:299 20 VDM\Component\Componentbuilder\Administrator\Model\CompilerModel->builder() JROOT/administrator/components/com_componentbuilder/src/Controller/CompilerController.php:129 21 VDM\Component\Componentbuilder\Administrator\Controller\CompilerController->compiler() JROOT/libraries/src/MVC/Controller/BaseController.php:730 22 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143 23 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361 24 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150 25 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:205 26 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:304 27 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58 28 require_once() JROOT/administrator/index.php:32`

Solution:
At JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php:514

The bug is $module->custom_get = $this->dynamic->get( needs to be $module->custom_get = $this->dynamicget->get(
I changed that and it compiles now.

Solution: At JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Joomlamodule/Data.php:514 The bug is `$module->custom_get = $this->dynamic->get(` needs to be `$module->custom_get = $this->dynamicget->get(` I changed that and it compiles now.
Owner

We are busy refactoring the whole module engine to build J5 natively like the plugin engine already does and so most of these issues will be resolved automatically. Yet, we are grateful for these PR's that you've pushed... and they are going to be merged. Thank you!

On #1236 you must try to commit a change that does not change the whole file... but just the line in question.

We are busy refactoring the whole **module engine to build J5 natively** like the plugin engine already does and so most of these issues will be resolved automatically. Yet, we are grateful for these PR's that you've pushed... and they are going to be merged. Thank you! On #1236 you must try to commit a change that does not change the whole file... but just the line in question.

Yeah I'm not sure why Git did that. I had only changed line 514.

Yeah I'm not sure why Git did that. I had only changed line 514.
Sign in to join this conversation.
4 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1133
No description provided.