[BUG]: Componentbuiilder/Compiler/Language/Purge.php passing array to /Update.php - expecting string (J3) #1235

Open
opened 2025-07-21 23:32:02 +00:00 by cpaschen · 3 comments

What Happened?

I'm getting the following error when trying to compile with JCB 3.2.4 on Joomla 3.10.12:

 0 VDM\Joomla\Componentbuilder\Compiler\Language\Update::set(): Argument #2 ($target) must be of type string, array given, called in /var/www/html/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Purge.php on line 165
/var/www/html/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Update.php:75 

Call stack

Function Location

1 () JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Update.php:75
2 VDM\Joomla\Componentbuilder\Compiler\Language\Update->set() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Purge.php:165
3 VDM\Joomla\Componentbuilder\Compiler\Language\Purge->handleUnlinkedString() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Purge.php:115

Steps to reproduce the Bug

Make some changes to several lines of codes throughout the component that use the enqueueMessage function, changing the string inside the message area.

Re-compile.

Then the bug happens

Which Joomla version are you compiling in?

3.10.12

Which PHP version are you compiling in?

8.0

Which Joomla versions are you targeting?

3.10.12

Which PHP version are you targeting?

8.0

Which Web server is JCB running on?

Apache/2.4.56 (on Octojoom)

Which Relational Database is JCB running on?

MariDB 11.7.2

Which OS is JCB running on?

Octojoom on Kubuntu

Which JCB version are you using?

3.2.4

Where in JCB did this issue occur?

Compilation of a component

On which browsers did you encounter the issue?

Firefox

Additional Comments

In the /libraries/vendor_jcb/VDM_Joomla/src/Componentbuilder/Compiler/Language/Purge.php file,
in the handleUnlinkedString() function, at line ~165
it calls the $this->update-set() function
it passes the variable "$targets" to that function as argument #2.
That variable ($targets) is provided when the handleUnlinkedString() function is called, and is of the type array.

So it appears that there is a miss-match in this.

set() in Purge is expecting a string ($target),
but handleUnlinkedString is passing an array ($targets).

I realize that this version of JCB is now EOL, but wondering if there is a simple fix to resolve this bug.

Can I just manually 'purge' all the language strings from the project and have them rebuild all of them to get around this issue?

(I have this project on JCB3 that we need to get somewhat stable before moving to JCB4/5, and we're almost there, pending this error).

### What Happened? I'm getting the following error when trying to compile with JCB 3.2.4 on Joomla 3.10.12: 0 VDM\Joomla\Componentbuilder\Compiler\Language\Update::set(): Argument #2 ($target) must be of type string, array given, called in /var/www/html/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Purge.php on line 165 /var/www/html/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Update.php:75 Call stack # Function Location 1 () JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Update.php:75 2 VDM\Joomla\Componentbuilder\Compiler\Language\Update->set() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Purge.php:165 3 VDM\Joomla\Componentbuilder\Compiler\Language\Purge->handleUnlinkedString() JROOT/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Language/Purge.php:115 ### Steps to reproduce the Bug Make some changes to several lines of codes throughout the component that use the enqueueMessage function, changing the string inside the message area. Re-compile. Then the bug happens ### Which Joomla version are you compiling in? 3.10.12 ### Which PHP version are you compiling in? 8.0 ### Which Joomla versions are you targeting? 3.10.12 ### Which PHP version are you targeting? 8.0 ### Which Web server is JCB running on? Apache/2.4.56 (on Octojoom) ### Which Relational Database is JCB running on? MariDB 11.7.2 ### Which OS is JCB running on? Octojoom on Kubuntu ### Which JCB version are you using? 3.2.4 ### Where in JCB did this issue occur? Compilation of a component ### On which browsers did you encounter the issue? Firefox ### Additional Comments In the /libraries/vendor_jcb/VDM_Joomla/src/Componentbuilder/Compiler/Language/Purge.php file, in the handleUnlinkedString() function, at line ~165 it calls the $this->update-set() function it passes the variable "$targets" to that function as argument #2. That variable ($targets) is provided when the handleUnlinkedString() function is called, and is of the type array. So it appears that there is a miss-match in this. set() in Purge is expecting a string ($target), but handleUnlinkedString is passing an array ($targets). I realize that this version of JCB is now EOL, but wondering if there is a simple fix to resolve this bug. Can I just manually 'purge' all the language strings from the project and have them rebuild all of them to get around this issue? (I have this project on JCB3 that we need to get somewhat stable before moving to JCB4/5, and we're almost there, pending this error).
cpaschen added the
Bug
label 2025-07-21 23:32:02 +00:00
Author

FYI ... here's the existing code snippets ...

From Purge.php:



/**
	 * Handle strings that are unlinked from the current component.
	 *
	 * This method checks if a string is linked to other extensions and either updates,
	 * archives, or deletes it based on the conditions.
	 *
	 * @param array  $item          The language string item.
	 * @param array  $targetTypes  The target extension types.
	 * @param array  $targets       The targets to update.
	 * @param string $today         The current date.
	 * @param int    $counter       The update counter.
	 *
	 * @return void
	 * @since  5.0.2
	 */
	protected function handleUnlinkedString(array $item, array $targetTypes, array $targets, string $today, int &$counter): void
	{
 ...
 

				$this->update->set($item['id'], $targets, $targets, 2, $today, 	$counter);

Hmmm ... it seems to be passing the $targets as both the 2nd AND 3rd parameter.

I don't quite understand, from the code, why that would be like that.

Any ideas?

FYI ... here's the existing code snippets ... From Purge.php: ``` /** * Handle strings that are unlinked from the current component. * * This method checks if a string is linked to other extensions and either updates, * archives, or deletes it based on the conditions. * * @param array $item The language string item. * @param array $targetTypes The target extension types. * @param array $targets The targets to update. * @param string $today The current date. * @param int $counter The update counter. * * @return void * @since 5.0.2 */ protected function handleUnlinkedString(array $item, array $targetTypes, array $targets, string $today, int &$counter): void { ... $this->update->set($item['id'], $targets, $targets, 2, $today, $counter); ``` Hmmm ... it seems to be passing the $targets as both the 2nd AND 3rd parameter. I don't quite understand, from the code, why that would be like that. Any ideas?
Author

NOTE/WORK-AROUND: I found an easy work-around for this issue.

  1. Go into JCB > Language Translations
  2. Change the filter to display all of the entries
  3. Select them all
  4. Export Data (so you have a back-up copy if anything goes wrong)
  5. Select them all (again)
  6. Click TRASH to remove them all

Now the component will compile and re-generate all the entries in the Language Translations area.

NOTE: If you created any custom translations, they will likely be lost, but at least the component will compile. And you can manually re-translate. Or I guess you could re-export the new entries generated, then write a script to pull the translations from the original backup export and pull that translation text into the new export and then pull those back in. (Might be a good task for AI :-) )

However, the code problem is still there. Hopefully not there in JCB5 versions.

NOTE/WORK-AROUND: I found an easy work-around for this issue. 1. Go into JCB > Language Translations 2. Change the filter to display all of the entries 3. Select them all 4. Export Data (so you have a back-up copy if anything goes wrong) 5. Select them all (again) 6. Click TRASH to remove them all Now the component will compile and re-generate all the entries in the Language Translations area. NOTE: If you created any custom translations, they will likely be lost, but at least the component will compile. And you can manually re-translate. Or I guess you could re-export the new entries generated, then write a script to pull the translations from the original backup export and pull that translation text into the new export and then pull those back in. (Might be a good task for AI :-) ) However, the code problem is still there. Hopefully not there in JCB5 versions.
Author

FYI ... I found, in comparing the original language translations export to the newly generated one, that the problem was that I removed some un-needed functionality in the component, which then resulted in those language strings being 'unlinked' (I'm guessing), which then initiated that function to remove them.
So, I guess we need to just not remove any functionality (that has language strings), unless this function is fixed.

(Again, if this is resolved in later JCB versions, then this should be closed as JCB3 no longer supported for fixes like this, although it would be nice to have this fixed).

FYI ... I found, in comparing the original language translations export to the newly generated one, that the problem was that I removed some un-needed functionality in the component, which then resulted in those language strings being 'unlinked' (I'm guessing), which then initiated that function to remove them. So, I guess we need to just not remove any functionality (that has language strings), unless this function is fixed. (Again, if this is resolved in later JCB versions, then this should be closed as JCB3 no longer supported for fixes like this, although it would be nice to have this fixed).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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