Project

General

Profile

Actions

Bug #103009

open

Import of Initialisation Files not working in typical dev setup

Added by Philipp Wrann 5 months ago. Updated 11 days ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
composer
Start date:
2024-02-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When developing your extension, the import of your Initialisation/Files is not working because the path handling wont support the directory structure.

The "typical" setup will be the following:


{
    "config": {
        "vendor-dir": ".Build/vendor",
        "bin-dir": ".Build/bin" 
    },
    "scripts": {
        "post-autoload-dump": [
            "cd .Build/vendor && mkdir -p my_vendor && rm -f my_vendor/my_package && ln -s ../../.. my_vendor/my_package && cd -; fi",
            "mkdir -p .Build/config/system && cd .Build/config/system && ln -sf ../../../Resources/Private/Build/additional.php && cd -; fi" 
        ]
    },
    "extra": {
        "typo3/cms": {
            "web-dir": ".Build/Web",
            "cms-package-dir": "${vendor-dir}/typo3/cms",
            "extension-key": "your_key" 
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require": {
        "php": "^8.2",
        "ext-SimpleXML": "*",
        "ext-json": "*",
        "typo3/minimal": "^12.4" 
    },
    "require-dev": {
        "typo3/testing-framework": "^7",
        "typo3/cms-setup": "^12.4" 
    }
}

It can be seen in many many extensions and is documented here:
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Testing/ExtensionTesting.html

The "ProjectPath" will not contain your Extension folder and this will lead to non-existing paths:

https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Classes/Utility/GeneralUtility.php#L2498

Like mentioned [here](https://forge.typo3.org/issues/102993), there is a setting, that we could use to solve the issue but it is not consistently used in the core:

assuming your setup utilizes a docker container and your extension code is mounted to /app:

$GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'] = '/app/';

The inconsistent path handling existed in earlier versions as well but this problem only affects TYPO3 12+ with composer mode. I guess before the package path has been typo3conf/ext/your_key and now its the absolute path (/app). So this seems to be related to the composer api of typo3.

Actions #1

Updated by Philipp Wrann 5 months ago

The issue (and many other issues related to this problem) may be solved very easily:

The package path for the local dev Package should be the symlinked one (.Build/vendor/your_vendor/your_package) insteadof the realpath. By doing that, the package will be "within" your project folder.

This bug is pretty severe and nasty, at this point i can't tell what it might affect as well!

What i noticed along the way: When generating keys for sys_registry, the core will sometimes strip the public path from the absolute path and it does that by using substring, with extensions stored in /vendor (not inside the public path), this will lead to wrong keys and might cause things to be executed twice!

@see here https://github.com/TYPO3/typo3/blob/12.4/typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php#L490

Actions #2

Updated by Helmut Hummel 11 days ago

  • Related to Bug #96984: Duplicate data imports with typo3/cms-composer-installers v4 added
Actions #3

Updated by Helmut Hummel 11 days ago

  • Status changed from New to Needs Feedback

Philipp Wrann wrote:

When developing your extension, the import of your Initialisation/Files is not working because the path handling wont support the directory structure.

The "typical" setup will be the following:
It can be seen in many many extensions and is documented here:
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Testing/ExtensionTesting.html

What exactly do you consider "typical" and what do you think from that is documented?

        "post-autoload-dump": [
            "cd .Build/vendor && mkdir -p my_vendor && rm -f my_vendor/my_package && ln -s ../../.. my_vendor/my_package && cd -; fi",
            "mkdir -p .Build/config/system && cd .Build/config/system && ln -sf ../../../Resources/Private/Build/additional.php && cd -; fi" 
        ]

Linking the extension into the vendor folder is non functional. It does not do anything and therefore should rather be removed (it also has a syntax error).

Linking the configuration might be useful, but is non functional with TYPO3 12, as the config folder always is top level.

        "typo3/cms": {
            "cms-package-dir": "${vendor-dir}/typo3/cms" 
        }

This does not do any more since the subtree split (TYPO3 8.7) and can safely be removed.

    "config": {
        "vendor-dir": ".Build/vendor",
        "bin-dir": ".Build/bin" 
    },

       "typo3/cms": {
            "web-dir": ".Build/Web" 
    }

These should be fine, if one prefers it like that, but latest with TYPO3 12, I would rather recommend going with the defaults

    "minimum-stability": "dev",
    "prefer-stable": true,

Such configuration is not required and should rather be removed.

   "require": {
        "php": "^8.2",
        "ext-SimpleXML": "*",
        "ext-json": "*",
        "typo3/minimal": "^12.4" 
    },

All package names should/ must be lower case.
An extension requiring typo3/minimal is highly discouraged and likely counter productive.
Please add the TYPO3 packages as requirement, that your extension really depends on.

Once you change these, what code exactly does fail for you? Please provide reproducible examples of what you are trying to achieve, what your expectations are and what the actual result is.

Actions #4

Updated by Helmut Hummel 11 days ago

  • Related to deleted (Bug #96984: Duplicate data imports with typo3/cms-composer-installers v4)
Actions #5

Updated by Helmut Hummel 11 days ago

Ah, it is pretty clear what you claim is not working. Only I can not reproduce it. So please provide an example to reproduce.

The introduction package https://github.com/FriendsOfTYPO3/introduction/blob/main/composer.json is an example, where exactly what is claimed here not working, is in fact working.

Actions

Also available in: Atom PDF