VDM\Joomla\Abstraction\Registry::get(): Argument #1 ($path) must be of type string, null given...VarExport.php on line 51 #1213

Open
opened 2025-03-26 09:50:43 +00:00 by kommid · 2 comments
Member

Hi,
after unsuccessfully trying to migrate/update my old JCB on J!3 to J!5 I set up a fresh Joomla with a fresh JCB 5.1.1-alpha1 and transfered my component to the new installation by copying every single entry from my old JCB site to the new one.
When I compile my component and my module, JCB throws an error:
VDM\Joomla\Abstraction\Registry::get(): Argument #1 ($path) must be of type string, null given, called in /var/www/clients/client2/web66/web/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry/Traits/VarExport.php on line 51
I searched for this error and found the issue at #1191
I indeed did have the "export/import data" checkboxes ticked in the admin views (JCB -> Joomla Components -> the components admin views), so I disabled them, but the error still persists, so disabling the export/import feature didn't work.

Steps to reproduce the issue

compile a component with export/import data switched off

Expected result

component is being compiled

Actual result

An error has occurred.

0 VDM\Joomla\Abstraction\Registry::get(): Argument #1 ($path) must be of type string, null given, called in /var/www/clients/client2/web66/web/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry/Traits/VarExport.php on line 51 

Call Stack

Function Location

1 () JROOT/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry.php:315
2 VDM\Joomla\Abstraction\Registry->get() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry/Traits/VarExport.php:51
3 VDM\Joomla\Componentbuilder\Compiler\Builder\ComponentFields->varExport() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php:2190
4 VDM\Joomla\Componentbuilder\Compiler\Helper\Infusion->buildFileContent() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php:67
5 VDM\Joomla\Componentbuilder\Compiler\Helper\Infusion->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Compiler.php:84
6 VDM\Joomla\Componentbuilder\Compiler\Helper\Compiler->__construct() JROOT/administrator/components/com_componentbuilder/src/Model/CompilerModel.php:299
7 VDM\Component\Componentbuilder\Administrator\Model\CompilerModel->builder() JROOT/administrator/components/com_componentbuilder/src/Controller/CompilerController.php:129
8 VDM\Component\Componentbuilder\Administrator\Controller\CompilerController->compiler() JROOT/libraries/src/MVC/Controller/BaseController.php:730
9 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
10 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
11 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150
12 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:205
13 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:306
14 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58
15 require_once() JROOT/administrator/index.php:32

System information (as much as possible)

  • OS Name & Version: Debian bookworm
  • MySql Version: 10.5.28-MariaDB-0+deb11u1
  • Apache Version: 2
  • PHP Version: 8.3
  • Joomla Version: 5.2.5
  • JCB Version: 5.1.1-alpha1
  • Browser: 128.8.0esr (64-Bit)

Additional comments

I tried to upload a screenshot, but this seems to be broken....

Hi, after unsuccessfully trying to migrate/update my old JCB on J!3 to J!5 I set up a fresh Joomla with a fresh JCB 5.1.1-alpha1 and transfered my component to the new installation by copying every single entry from my old JCB site to the new one. When I compile my component and my module, JCB throws an error: ` VDM\Joomla\Abstraction\Registry::get(): Argument #1 ($path) must be of type string, null given, called in /var/www/clients/client2/web66/web/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry/Traits/VarExport.php on line 51` I searched for this error and found the issue at https://git.vdm.dev/joomla/Component-Builder/issues/1191 I indeed did have the "export/import data" checkboxes ticked in the admin views (JCB -> Joomla Components -> the components admin views), so I disabled them, but the error still persists, so disabling the export/import feature didn't work. ### Steps to reproduce the issue compile a component with export/import data switched off ### Expected result component is being compiled ### Actual result An error has occurred. 0 VDM\Joomla\Abstraction\Registry::get(): Argument #1 ($path) must be of type string, null given, called in /var/www/clients/client2/web66/web/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry/Traits/VarExport.php on line 51 Call Stack # Function Location 1 () JROOT/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry.php:315 2 VDM\Joomla\Abstraction\Registry->get() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry/Traits/VarExport.php:51 3 VDM\Joomla\Componentbuilder\Compiler\Builder\ComponentFields->varExport() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php:2190 4 VDM\Joomla\Componentbuilder\Compiler\Helper\Infusion->buildFileContent() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Infusion.php:67 5 VDM\Joomla\Componentbuilder\Compiler\Helper\Infusion->__construct() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Compiler.php:84 6 VDM\Joomla\Componentbuilder\Compiler\Helper\Compiler->__construct() JROOT/administrator/components/com_componentbuilder/src/Model/CompilerModel.php:299 7 VDM\Component\Componentbuilder\Administrator\Model\CompilerModel->builder() JROOT/administrator/components/com_componentbuilder/src/Controller/CompilerController.php:129 8 VDM\Component\Componentbuilder\Administrator\Controller\CompilerController->compiler() JROOT/libraries/src/MVC/Controller/BaseController.php:730 9 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143 10 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361 11 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:150 12 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:205 13 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:306 14 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/includes/app.php:58 15 require_once() JROOT/administrator/index.php:32 ### System information (as much as possible) - OS Name & Version: Debian bookworm - MySql Version: 10.5.28-MariaDB-0+deb11u1 - Apache Version: 2 - PHP Version: 8.3 - Joomla Version: 5.2.5 - JCB Version: 5.1.1-alpha1 - Browser: 128.8.0esr (64-Bit) ### Additional comments I tried to upload a screenshot, but this seems to be broken....
kommid changed title from Error compiling component to VDM\Joomla\Abstraction\Registry::get(): Argument #1 ($path) must be of type string, null given...VarExport.php on line 51 2025-03-26 09:52:40 +00:00
Author
Member

...not even a hint, what could be wrong? I'd really like to switch to j!5 with JCB but right now, it seems I really shouldn't because it doesn't seem to be stable enough....

...not even a hint, what could be wrong? I'd really like to switch to j!5 with JCB but right now, it seems I really shouldn't because it doesn't seem to be stable enough....
Owner

We have fixed various issues currently in the 5.1.1-alpha4 version... ALPHA does in fact mean unstable, and not ready for production. The last stable version is found here: https://git.vdm.dev/joomla/pkg-component-builder/releases

Fix in New JCB Release (v5.1.1-alpha4)

The JCB team has addressed this bug in a newer alpha release. In Joomla Component Builder 5.1.1-alpha4, the component compiler no longer triggers the Registry::get() null-path error. Updating to v5.1.1-alpha4 (or later) will include the fix so that compiling your component bypasses this issue. (We noted that the import/export feature was not fully ready in earlier alphas and advised disabling it as a workaround. This update effectively implements that advice in code.) You can download the latest alpha from the official repository – for example, via the v5.1.1-alpha4 tag on JCB’s Git repository.

Manual Fix for v5.1.1-alpha1

If an immediate upgrade isn’t possible, you can apply a small patch to guard against $path being null in the varExport() logic. Open the file libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry/Traits/VarExport.php and locate the varExport function. In v5.1.1-alpha1 it looks like this:

public function varExport(?string $path = null, int $indentation = 2): ?string
{
    // Load the data array
    if ($path === null && $this->isActive()) {
        $data = $this->allActive();
    } else {
        $data = $this->get($path);
    }
    // check if we have data
    if ($data === null) {
        return null;
    }
    // ... (proceeds to process $data) ...
}

To fix the error, prevent the get() call when $path is null. For example, you can change the logic to:

if ($path === null) {
    $data = $this->isActive() ? $this->allActive() : [];
} else {
    $data = $this->get($path);
}

This ensures that when no path is provided, it either exports the entire active registry branch or simply returns an empty array instead of calling $this->get(null). After this change, if $path is null and there’s no “active” sub-section of the registry, JCB will not call Registry::get() at all (avoiding the type error).

Context of the Issue

In JCB 5.1.1-alpha1, the “Export/Import Data” feature for admin views was incomplete. Even with the option turned off, the compiler still attempted to export component data, leading to a null being passed into Registry::get() during the varExport() call.

The fix above (which is included in the latest alpha) simply adds a null-check so that the export routine skips over or safely handles the data export when it’s not enabled. This aligns with the developer’s guidance to disable the feature in earlier versions. With this guard in place, compiling the component will succeed without that error, and the upcoming versions of JCB have this adjustment integrated.

We have fixed various issues currently in the [5.1.1-alpha4](https://git.vdm.dev/joomla/pkg-component-builder/archive/v5.1.1-alpha4.zip) version... ALPHA does in fact mean unstable, and not ready for production. The last stable version is found here: https://git.vdm.dev/joomla/pkg-component-builder/releases ## Fix in New JCB Release (v5.1.1-alpha4) The JCB team has addressed this bug in a newer alpha release. In **Joomla Component Builder 5.1.1-alpha4**, the component compiler no longer triggers the `Registry::get()` null-path error. Updating to v5.1.1-alpha4 (or later) will include the fix so that compiling your component bypasses this issue. (We noted that the import/export feature was not fully ready in earlier alphas and advised disabling it as a workaround. This update effectively implements that advice in code.) You can download the latest alpha from the official repository – for example, via the [v5.1.1-alpha4](https://git.vdm.dev/joomla/pkg-component-builder/archive/v5.1.1-alpha4.zip) tag on JCB’s Git repository. ## Manual Fix for v5.1.1-alpha1 If an immediate upgrade isn’t possible, you can apply a small patch to **guard against `$path` being null** in the `varExport()` logic. Open the file `libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Registry/Traits/VarExport.php` and locate the `varExport` function. In v5.1.1-alpha1 it looks like this: ```php public function varExport(?string $path = null, int $indentation = 2): ?string { // Load the data array if ($path === null && $this->isActive()) { $data = $this->allActive(); } else { $data = $this->get($path); } // check if we have data if ($data === null) { return null; } // ... (proceeds to process $data) ... } ``` To fix the error, **prevent the `get()` call when `$path` is `null`**. For example, you can change the logic to: ```php if ($path === null) { $data = $this->isActive() ? $this->allActive() : []; } else { $data = $this->get($path); } ``` This ensures that when no path is provided, it either exports the entire active registry branch or simply returns an empty array instead of calling `$this->get(null)`. After this change, if `$path` is null and there’s no “active” sub-section of the registry, JCB will not call `Registry::get()` at all (avoiding the type error). ## Context of the Issue In JCB 5.1.1-alpha1, the “Export/Import Data” feature for admin views was incomplete. Even with the option **turned off**, the compiler still attempted to export component data, leading to a null being passed into `Registry::get()` during the `varExport()` call. The fix above (which is included in the latest alpha) simply adds a null-check so that the export routine skips over or safely handles the data export when it’s not enabled. This aligns with the developer’s guidance to disable the feature in earlier versions. With this guard in place, compiling the component will succeed without that error, and the upcoming versions of JCB have this adjustment integrated.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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