Bug #90635

Error is thrown when using EXT:extension_name for which is installed in different folder name in typo3conf/ext

Added by Tymoteusz Motylewski 3 months ago. Updated 3 months ago.

Status:
New
Priority:
Should have
Category:
-
Target version:
-
Start date:
2020-03-04
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Problem

Given

- an extension e.g. yoast_seo copied to typo3conf/ext/yoast_typo3 (folder different than extension key)
- this extension has TYPOScript which references some file using EXT:yoast_seo syntax

Result:

- Backend is broken with "Call to a member function getPackagePath() on null" in ExtensionManagerUtility

Expected:

- either the file inclusion is ignored, or the path is correctly resolved (as TYPO3 can correctly translate yoast_seo to yoast_typo3 with

$this->getPackageKeyFromComposerName($packageKey);

- breaking whole system is not expected

Technical details:

in this setup
- PackageManager->isPackageActive('yoast_seo') return TRUE
- PackageManager->getPackageKeyFromComposerName('yoast_seo') returns 'yoast_typo3'
- PackageManager->isPackageRegistered('yoast_seo') returns TRUE
- PackageManager->isPackageAvailable('yoast_seo')returns TRUE
- ExtensionManagementUtility::isLoaded('yoast_seo') returns TRUE
- ExtensionManagementUtility::extPath('yoast_seo') throws "Call to a member function getPackagePath() on null"
- because PackageManager->getPackage('yoast_seo') returns null

Seems like the API is inconsistent here.

Possible solution:

change

    public function getPackage($packageKey)
    {
        if (!$this->isPackageRegistered($packageKey) && !$this->isPackageAvailable($packageKey)) {
            throw new Exception\UnknownPackageException('Package "' . $packageKey . '" is not available. Please check if the package exists and that the package key is correct (package keys are case sensitive).', 1166546734);
        }
        return $this->packages[$packageKey];
    }

to:
    public function getPackage($packageKey)
    {
        if (!$this->isPackageRegistered($packageKey) && !$this->isPackageAvailable($packageKey)) {
            throw new Exception\UnknownPackageException('Package "' . $packageKey . '" is not available. Please check if the package exists and that the package key is correct (package keys are case sensitive).', 1166546734);
        }
        return $this->packages[$this->getPackageKeyFromComposerName($packageKey)];
    }

History

#1 Updated by Tymoteusz Motylewski 3 months ago

  • Description updated (diff)

#2 Updated by Tymoteusz Motylewski 3 months ago

  • Description updated (diff)

#3 Updated by Tymoteusz Motylewski 3 months ago

  • Description updated (diff)

#4 Updated by Tymoteusz Motylewski 3 months ago

  • Assignee set to Tymoteusz Motylewski

#5 Updated by Nicole Cordes 3 months ago

Hi Tymoteusz,

I wouldn't change the getPackage() code as the (correct) packageKey is expected as an argument. If you need another package key than provided currently, I think it would be a better solution to change the calling code and receive the correct extension key.

But I must commit, that having an extension in a different extension folder than the extension key provides, is not an expected behaviour at all. I would recommend to reject the ticket and refer to "this is (not) how TYPO3 (currently) works".

#6 Updated by Tymoteusz Motylewski 3 months ago

@Nicole,
Are you saying that the "Call to a member function getPackagePath() on null" error (which breaks the backend) is expected behavior in this case?
In other cases, If you use an EXT: syntax to not existing or not loaded extension, it will silently fail, no error will be thrown.
This is why this error is nothing I would expect (especially as this error is not helpful at all).

Second topic is inconsistency in the API.
I see no way to currently to check whether it's safe to call ExtensionManagementUtility::extPath('xxx').
As you see above all methods: isPackageActive('xxx'), isPackageRegistered('xxx'), isPackageAvailable('xxx'), isLoaded('xxx') return TRUE (as they all use getPackageKeyFromComposerName to "normalize" given key.
So as a developer I'm surprised that ExtensionManagementUtility::extPath('xxx') throws an error.

Because it means that the key you are suppouse to pass to extPath() and getPackage() is a different key that is expected in all other methods of the ExtensionManagementUtility and PackageManager (despite being described in the same way everywhere).

I can also add that its possible to install the extension with "wrong" folder name, so if it would be prevented the following erros would not happen.
Also install tool's checks for broken extensions are all green.

Also available in: Atom PDF