Bug #93889

Cannot modify language pack remote base URL

Added by Xavier Perseguers 7 months ago. Updated 21 days ago.

Status:
Closed
Priority:
Should have
Category:
Localization
Target version:
Start date:
2021-04-09
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

Since the move to PSR-14 one cannot modify the language pack remote base URL.

This is following event:

TYPO3\CMS\Install\Service\Event\ModifyLanguagePackRemoteBaseUrlEvent

The reason is that the listener provider TYPO3\CMS\Core\EventDispatcher\ListenerProvider has an empty list of initialized listeners (member listeners), most probably in relation with the context (Install Tool).

Configuration

In EXT:yourExt/Configuration/Settings.yaml:

  VENDOR\YourExt\EventListener\InstallServiceEventListener:
    tags:
      - name: event.listener
        identifier: 'VENDOR/yourExt'
        method: 'modifyLanguagePackRemoteBaseUrl'
        event: TYPO3\CMS\Install\Service\Event\ModifyLanguagePackRemoteBaseUrlEvent

Sample class VENDOR\YourExt\EventListener\InstallServiceEventListener:

namespace VENDOR\YourExt\EventListener;

use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Install\Service\Event\ModifyLanguagePackRemoteBaseUrlEvent;

class InstallServiceEventListener
{

    /**
     * @param ModifyLanguagePackRemoteBaseUrlEvent $event
     */
    public function modifyLanguagePackRemoteBaseUrl(ModifyLanguagePackRemoteBaseUrlEvent $event): void
    {
        if ($event->getPackageKey() === 'yourExt') {
            $event->setBaseUrl(new Uri('https://www.example.com/packages/'));
        }
    }

}

Expected

The method is invoked.

What happens

The method is not invoked as no listeners seems to be registered in that context.


Related issues

Related to TYPO3 Core - Bug #66928: Cannot use custom mirror URL anymore for XLIFFClosed2015-05-13

Actions
Related to TYPO3 Core - Feature #50467: Support custom translation servers for extensionsClosedXavier Perseguers2013-07-26

Actions
#1

Updated by Xavier Perseguers 7 months ago

  • Related to Bug #66928: Cannot use custom mirror URL anymore for XLIFF added
#2

Updated by Xavier Perseguers 7 months ago

  • Related to Feature #50467: Support custom translation servers for extensions added
#3

Updated by Xavier Perseguers 7 months ago

  • Category set to Localization
  • Target version set to next-patchlevel

This is the second time this feature, introduced with #50467 for TYPO3 6.2, gets broken after a refactoring. Last time it was during the development of TYPO3 v7 (#66928).

#4

Updated by Xavier Perseguers 7 months ago

  • Description updated (diff)
#5

Updated by Xavier Perseguers 7 months ago

My hack right now (and that's absolutely nasty!!!):

diff --git a/Classes/EventDispatcher/ListenerProvider.php b/Classes/EventDispatcher/ListenerProvider.php
index 99a48475f..143256f28 100644
--- a/Classes/EventDispatcher/ListenerProvider.php
+++ b/Classes/EventDispatcher/ListenerProvider.php
@@ -41,6 +41,28 @@ class ListenerProvider implements ListenerProviderInterface
     public function __construct(ContainerInterface $container)
     {
         $this->container = $container;
+
+        // --------------------------------------------------
+        // HACK
+        // See: https://forge.typo3.org/issues/50467
+        if ($container instanceof \TYPO3\CMS\Core\DependencyInjection\FailsafeContainer) {
+            $languagePackRemoateBaseUrlModifier = \VENDOR\YourExt\EventListener\InstallServiceEventListener::class;
+            $this->addListener(
+                \TYPO3\CMS\Install\Service\Event\ModifyLanguagePackRemoteBaseUrlEvent::class,
+                $languagePackRemoateBaseUrlModifier,
+                'modifyLanguagePackRemoteBaseUrl'
+            );
+
+            // and, that's absolutely nasty, but to make it work:
+            $reflectionOfContainer = new \ReflectionObject($container);
+            $privateEntries = $reflectionOfContainer->getProperty('entries');
+            $privateEntries->setAccessible(true);
+            $entries = $privateEntries->getValue($container);
+            $entries[$languagePackRemoateBaseUrlModifier] =
+                new $languagePackRemoateBaseUrlModifier();
+            $privateEntries->setValue($container, $entries);
+        }
+        // --------------------------------------------------
     }

     /**
#6

Updated by Benjamin Franzke 7 months ago

That's not primarly a container thing, but rather a consequence of the context change in https://review.typo3.org/c/Packages/TYPO3.CMS/+/55998/

Are you sure that worked in 9.5?
I guess it was broken in there as well, also v9 style extbase signal handlers wouldn't fire as ext_localconf isn't loaded, right?

Regarding a possible solution:
With the help of (Late)BootService we could load all extensions in install context and therefore get a ListenerProvider from the symfony container.
But that of course means that all extensions will be loaded and the full container bootstraped. So there is little use in working in install tool context at all.
I don't know about the reasons for moving this tool into the installtool in the first place, therefore I'd like to know what Christian Kuhn thinks (as author of the patch linked above).

#7

Updated by Benjamin Franzke 7 months ago

  • Assignee set to Christian Kuhn
#8

Updated by Xavier Perseguers 7 months ago

That worked in v9 since in v9 we had a signal/slot mechanism. I use it actively in v9 without any problem. Just facing this problem in v11 with a new project. The other one in v9 is not yet ready for v10 so did not spot earlier.

We really need to find a solution, at least for this very use case of changing the download URL of the language packs, this is extremely useful in an enterprise context. For other use cases, I know that Christian Kuhn is really unlikely to be fine loading extensions in the Install Tool context but we must address the XLIFF stuff anyway.

#9

Updated by Gerrit Code Review 7 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68754

#10

Updated by Christian Kuhn 5 months ago

@bnf: I remember we killed the slot in v9 when the dusty language pack handling has been moved to install tool where it belongs. IIRC, we re-integrated the same slot or a similar one. So, this broke again with the psr-14 or DI changes.

Benjamin, there are some more places in install tool that bootstrap "full system", right? For instance the upgrade wizards need to do this, and some others, too. We could use the same mechanism to re-enable the listener?

#11

Updated by Xavier Perseguers 3 months ago

friendly ping :)

#12

Updated by Gerrit Code Review about 2 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68754

#13

Updated by Benjamin Franzke about 1 month ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#14

Updated by Gerrit Code Review about 1 month ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/71110

#15

Updated by Benjamin Franzke about 1 month ago

  • Status changed from Under Review to Resolved
#16

Updated by Benni Mack 21 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF