[BUG]: JCB Packager: Custom Gets linked to a Site View are not being packaged correctly #1272

Closed
opened 2025-12-03 14:42:51 +00:00 by Lemuel · 1 comment
Owner

What Happened?

When building a component that contains a Site View with multiple Custom Dynamic Gets linked in the Custom Get area, those gets are not being detected or packaged correctly by the JCB packaging engine.

During packaging:

  • Linked dynamic gets are not listed as dependencies.
  • They are not pushed into the repository.
  • When the component is initialized on another system, the gets are not pulled back, because they were never registered as dependencies or built into the package.
  • In many cases, only one get or none are shipped, even though multiple gets were linked.

After debugging the issue, the root cause was identified in the Dependency Resolver class inside the packaging engine.

The following method did not correctly handle JSON objects embedded in strings:

protected function normalizeToStringArray(mixed $raw): array
{
	return array_values(array_filter(match (true) {
		is_string($raw)               => [$raw],
		is_array($raw)                => $raw,
		$raw instanceof \Traversable   => iterator_to_array($raw),
		default                       => [],
	}, static fn($v) => is_string($v) && trim($v) !== ''));
}

Because Custom Dynamic Gets can be multiple they are stored as JSON encoded objects, this method normalized the input into an empty array, which caused all Custom Gets to be dropped silently.

The method was updated as follows:

protected function normalizeToStringArray(mixed $raw): array
{
	$values = match (true) {
		is_string($raw)               => [$raw],
		is_array($raw)                => $raw,
		$raw instanceof \Traversable  => iterator_to_array($raw),
		is_object($raw)               => get_object_vars($raw),
		default                       => [],
	};

	return array_values(array_filter($values, static function ($v): bool {
		return is_string($v) && trim($v) !== '';
	}));
}

After applying this fix:

  • All linked Custom Dynamic Gets are now detected correctly.
  • Dependencies are registered properly.
  • Gets are pushed to the repository and initialized as expected.

Steps to reproduce the Bug

  1. Create a Site View in JCB.
  2. Link multiple Custom Dynamic Gets in the "Custom Get" field.
  3. Package the component using the JCB packaging engine.
  4. Push the package to a repository.
  5. Initialize it on another Joomla system.

Result:

  • Only one or none of the Dynamic Gets are created in the repository.
  • Missing gets are not re-initialized because they were never shipped.

Which Joomla version are you compiling in?

v5.4.1

Which PHP version are you compiling in?

v8.3

Which Joomla versions are you targeting?

v5.4.1

Which PHP version are you targeting?

v8.3

Which Web server is JCB running on?

Apache Latest

Which Relational Database is JCB running on?

MariaDB Latest

Which OS is JCB running on?

Ubuntu 24.04 LTS

Which JCB version are you using?

v5.1.4-alpha6

Where in JCB did this issue occur?

Site View(admin_view)

On which browsers did you encounter the issue?

Firefox

Additional Comments

This bug has been resolved.

The fix will be included in the next JCB release.

### What Happened? When building a component that contains a **Site View with multiple Custom Dynamic Gets linked in the Custom Get area**, those gets are not being detected or packaged correctly by the JCB packaging engine. During packaging: - Linked dynamic gets are **not listed as dependencies**. - They are **not pushed** into the repository. - When the component is initialized on another system, the gets are **not pulled back**, because they were never registered as dependencies or built into the package. - In many cases, only one get or none are shipped, even though multiple gets were linked. After debugging the issue, the root cause was identified in the **[Dependency Resolver](https://git.vdm.dev/joomla/Component-Builder/src/commit/a708fb5b518f9ac3a221dc77a94c2949ff39920b/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Package/Dependency/Resolver.php#L719)** class inside the packaging engine. The following method did not correctly handle JSON objects embedded in strings: ```php protected function normalizeToStringArray(mixed $raw): array { return array_values(array_filter(match (true) { is_string($raw) => [$raw], is_array($raw) => $raw, $raw instanceof \Traversable => iterator_to_array($raw), default => [], }, static fn($v) => is_string($v) && trim($v) !== '')); } ``` Because Custom Dynamic Gets can be multiple they are stored as JSON encoded objects, this method normalized the input into an empty array, which caused all Custom Gets to be dropped silently. The method was updated as follows: ```php protected function normalizeToStringArray(mixed $raw): array { $values = match (true) { is_string($raw) => [$raw], is_array($raw) => $raw, $raw instanceof \Traversable => iterator_to_array($raw), is_object($raw) => get_object_vars($raw), default => [], }; return array_values(array_filter($values, static function ($v): bool { return is_string($v) && trim($v) !== ''; })); } ``` After applying this fix: - All linked Custom Dynamic Gets are now detected correctly. - Dependencies are registered properly. - Gets are pushed to the repository and initialized as expected. ### Steps to reproduce the Bug 1. Create a Site View in JCB. 2. Link multiple Custom Dynamic Gets in the "Custom Get" field. 3. Package the component using the JCB packaging engine. 4. Push the package to a repository. 5. Initialize it on another Joomla system. Result: - Only one or none of the Dynamic Gets are created in the repository. - Missing gets are not re-initialized because they were never shipped. ### Which Joomla version are you compiling in? v5.4.1 ### Which PHP version are you compiling in? v8.3 ### Which Joomla versions are you targeting? v5.4.1 ### Which PHP version are you targeting? v8.3 ### Which Web server is JCB running on? Apache Latest ### Which Relational Database is JCB running on? MariaDB Latest ### Which OS is JCB running on? Ubuntu 24.04 LTS ### Which JCB version are you using? v5.1.4-alpha6 ### Where in JCB did this issue occur? Site View(admin_view) ### On which browsers did you encounter the issue? Firefox ### Additional Comments This bug has been resolved. The fix will be included in the **next JCB release**.
Lemuel added the Bug label 2025-12-03 14:42:51 +00:00
Robot referenced this issue from a commit 2025-12-04 12:52:26 +00:00
Author
Owner

Tested across multiple installations on both Joomla 5 and Joomla 6 - the issue is now resolved.
If you're experiencing similar problems, please update to the latest beta2 release, which addresses multiple issues in the packaging engine.
Note: This is still a beta version and should be tested carefully before use in production environments.

Tested across multiple installations on both Joomla 5 and Joomla 6 - the issue is now resolved. If you're experiencing similar problems, please update to the [latest beta2 release](https://github.com/joomengine/pkg-component-builder/archive/refs/heads/5.x.zip), which addresses multiple issues in the packaging engine. **Note:** This is still a beta version and should be tested carefully before use in production environments.
Robot referenced this issue from a commit 2026-02-18 14:57:04 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1272