Project

General

Profile

Actions

Bug #93889

closed

Cannot modify language pack remote base URL

Added by Xavier Perseguers over 3 years ago. Updated about 3 years 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 2 (0 open2 closed)

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
Actions #1

Updated by Xavier Perseguers over 3 years ago

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

Updated by Xavier Perseguers over 3 years ago

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

Updated by Xavier Perseguers over 3 years 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).

Actions #4

Updated by Xavier Perseguers over 3 years ago

  • Description updated (diff)
Actions #5

Updated by Xavier Perseguers over 3 years 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);
+        }
+        // --------------------------------------------------
     }

     /**
Actions #6

Updated by Benjamin Franzke over 3 years 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).

Actions #7

Updated by Benjamin Franzke over 3 years ago

  • Assignee set to Christian Kuhn
Actions #8

Updated by Xavier Perseguers over 3 years 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.

Actions #9

Updated by Gerrit Code Review over 3 years 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

Actions #10

Updated by Christian Kuhn over 3 years 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?

Actions #11

Updated by Xavier Perseguers over 3 years ago

friendly ping :)

Actions #12

Updated by Gerrit Code Review about 3 years 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

Actions #13

Updated by Benjamin Franzke about 3 years ago

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

Updated by Gerrit Code Review about 3 years 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

Actions #15

Updated by Benjamin Franzke about 3 years ago

  • Status changed from Under Review to Resolved
Actions #16

Updated by Benni Mack about 3 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF