Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Collection of backports #633

Merged
merged 6 commits into from
Nov 29, 2024
Merged

[TASK] Collection of backports #633

merged 6 commits into from
Nov 29, 2024

Conversation

@sbuerk sbuerk changed the title [BUGFIX] Ensure correct path calculation on system build [TASK] Collection of backports Nov 28, 2024
@sbuerk sbuerk marked this pull request as draft November 28, 2024 07:51
@sbuerk sbuerk force-pushed the 8-stefan-1 branch 2 times, most recently from 7e52025 to 1889534 Compare November 28, 2024 09:31
@sbuerk sbuerk marked this pull request as ready for review November 28, 2024 19:46
thomashohn and others added 5 commits November 28, 2024 20:51
TYPO3 core `SystemEnvironmentBuilder` has been implement
normal TYPO3 usages in mind respecting possible instance
setup scenarios, to build low level system environment
before taking configuration into account.

Path calculations are based on different indicators,
for example if TYPO3 is used in composer mode based
on the PHP define() TYPO3_COMPOSER_MODE set during
by the `typo3/cms-composer-installers` composer plugin
during `composer install` actions.

Per nature, PHP defines are immutable and cannot be
changed anymore during runtime.

As `typo3/testing-framework` is only installabe using
composer the TYPO3_COMPOSER_MODE define is always set
but is invalid for functional test instances build in
legacy mode and making invalid path calculations.
That was hidden quite some time now, and is related to
a chain of changes over a very long period of time and
finally popped up in early TYPO3 v13 development after
introducing the configurable backend url feature.

Functional tests building relative url for resources
or links could run into the issue not retrieving the
leading slash anymore due to path calculation errrors,
leading to follup issues in `NormalizedParams` create
method when using frontend requests.

Eventually more developers run into that issue, but
simply adjusted the test expectation instead analyzing
the root of the curse and thus not reported it, which
has been done recenently.

To fix this issue changes on two fronts have to be made,
in the TYPO3 core `SystemEnvironmentBuilder` [1] and
in the testing-framework implementation.

Note that only both changes together solves this issue,
as the testing-framework change alone would not be
executed due to using `self` for static method calls
in the TYPO3 implementation.

[1] https://review.typo3.org/c/Packages/TYPO3.CMS/+/86569

Resolves: #577
Releases: main, 8
The typo3/testing-framework provides two TYPO3 extensions,
which are required and bound to every created functional
test instance.

Adding missing `composer.json` for these two extensions.

Releases: main, 8
The `typo3/testing-framework` creates functional test instances
as "classic" mode instances, writing a `PackageStates.php` file
composed using composer information, provided and handled by the
internal `ComposerPackageManager` class. Extensions in the state
file are not sorted based on their dependencies and suggestions.

To mitigate this and having a correctly sorted extension state
file, the `PackageCollection` service has been introduced with
the goal to resort the extension state file after the initial
write to provide the correct sorted extension state.

The extension sorting within the state file is important, as the
TYPO3 Core uses this sorting to loop over extensions to collect
information from the extensions, for example TCA, TCAOverrides,
ext_localconf.php and other things. Package sorting is here very
important to allow extensions to reconfigure or change the stuff
from other extensions, which is guaranteed in normal "composer"
and "classic" mode instances.

For "classic" mode instances, only the `ext_emconf.php` file is
taken into account and "composer.json" as the source of thruth
for "composer" mode instances since TYPO3 v12, which made the
`ext_emconf.php` file obsolete for extensions only installed
with composer.

Many agencies removed the optional `ext_emconf.php` file for
project local path extensions like a sitepackage to remove
the maintenance burden, which is a valid case.

Sadly, the `PackageCollection` adopted from the TYPO3 Core
`PackageManager` did not reflected this case and failed for
extensions to properly sort only on extension dependencies
and keys due the mix of extension key and composer package
name handling. Extension depending on another extension
failed to be sorted correctly with following exception:

    UnexpectedValueException: The package "extension_key"
    depends on "composer/package-key" which is not present
    in the system.

This change modifies the `PackageCollection` implementation
to take only TYPO3 extension and system extension into account
for dependency resolving and sorting, using `ext_emconf.php`
depends/suggest information as first source and falling back
to `composer` require and suggestion information.

Resolves: #541
Releases: main, 8
…Manager`

The `ComposerPackageManager` has been introduced to streamline
the functional test instance creation process and provide all
selected extensions (system, custom and test fixture) within
the test instance, which original simply used relative path
names for classic mode instances or a simple extension key:

For `$coreExtensionsToLoad`:

* typo3/sysext/backend
* backend

For `$testExtensionsToLoad`:

* typo3conf/ext/my_ext_key
* my_ext_key

With `typo3/cms-composer-installers` version 4.0RC1 and
5 these paths could not be found anymore, because TYPO3
system extensions and extensions are no longer installed
into the classic paths in a composer mode instance and
left in the vendor folder, which is the case for usual
root project or extension instance.

Using the available composer information to determine the
source for extensions unrelated to the real installation
path, which can be configured with composer, was the way
to mitigate this issue and `ComposerPackageManger` has
been implemented to process these lookups while still
supporting test fixture extensions not loaded by the root
composer.json directly.

The implementation tried to provide backwards compatible
as much as possible along with fallback to use folder names
as extension keys by simply using `basename()` in some code
places and including not obvious side effects and lookup
issues. `basename()` was also used on valid composer package
names to resolve composer package name for that value as
extension key for loaded packages, which leads to fetch the
wrong composer package.

The standlone fluid `typo3fluid/fluid` composer package name
resolved and retrieved the TYPO3 system extension package
`typo3/cms-fluid` using `getPackageInfo()`, which lead to
issues in other places, for example the dependency ordering
and resolving class `PackageCollection`.

This change streamlines the `ComposerPackageManager` class
to mitigate building and using invalid values to lookup
extension composer package names and harden the registration
process of extension even further.

Guarding unit tests are added to cover this bugfix.

Resolves: #553
Releases: main, 8
Using the `typo3DatabasePort` environment variable to
define the database server port string-casts the value
to an string which is not compatible with the mysqli
method `mysqli::real_connect()` and fails with:

  TypeError: mysqli::real_connect(): Argument #5 ($port)
  must be of type ?int, string given

This change casts the database port to an integer in case
a port is provided to avoid PHP TypeError when passing to
`mysqli::real_connect()` to align with `ConnectionPool`,
which is not used to create the database for the functional
test instance.

Resolves: #631
Releases: main, 8
@sbuerk sbuerk merged commit c627c85 into 8 Nov 29, 2024
8 checks passed
@sbuerk sbuerk deleted the 8-stefan-1 branch November 29, 2024 09:46
sbuerk added a commit that referenced this pull request Nov 29, 2024
The bugfix backport to ensure correct system environment path
building to fix issue #577 missed to correctly set the flag
for non-composer mode for TYPO3 v12 and lead to wrong path
calculations and followup issues within functional tests.

This is fixed by handing over a correct override value within
the functional test bootstrap.

[1] #577
[2] #633

Resolves: #658
Related: #633
Related: 409c2b8
Releases: 8
sbuerk added a commit that referenced this pull request Nov 29, 2024
The bugfix backport to ensure correct system environment path
building to fix issue #577 missed to correctly set the flag
for non-composer mode for TYPO3 v12 and lead to wrong path
calculations and followup issues within functional tests.

This is fixed by handing over a correct override value within
the functional test bootstrap.

[1] #577
[2] #633

Resolves: #658
Related: #633
Related: 409c2b8
Releases: 8
sbuerk added a commit to sbuerk/typo3-testing-framework that referenced this pull request Dec 3, 2024
The bugfix backport to ensure correct system environment path
building to fix issue TYPO3#577 missed to correctly set the flag
for non-composer mode for TYPO3 v12 and lead to wrong path
calculations and followup issues within functional tests.

This is fixed by handing over a correct override value within
the functional test bootstrap.

[1] TYPO3#577
[2] TYPO3#633

Resolves: TYPO3#658
Related: TYPO3#633
Related: TYPO3@409c2b8
Releases: 8
sbuerk added a commit to sbuerk/typo3-testing-framework that referenced this pull request Dec 3, 2024
The bugfix backport to ensure correct system environment path
building to fix issue TYPO3#577 missed to correctly set the flag
for non-composer mode for TYPO3 v12 and lead to wrong path
calculations and followup issues within functional tests.

This is fixed by handing over a correct override value within
the functional test bootstrap.

[1] TYPO3#577
[2] TYPO3#633

Resolves: TYPO3#658
Related: TYPO3#633
Related: TYPO3@409c2b8
Releases: 8

Backported from dd7505b
sbuerk added a commit to sbuerk/typo3-testing-framework that referenced this pull request Dec 4, 2024
The bugfix backport to ensure correct system environment path
building to fix issue TYPO3#577 missed to correctly set the flag
for non-composer mode for TYPO3 v12 and lead to wrong path
calculations and followup issues within functional tests.

This is fixed by handing over a correct override value within
the functional test bootstrap.

[1] TYPO3#577
[2] TYPO3#633

Resolves: TYPO3#658
Related: TYPO3#633
Related: TYPO3@409c2b8
Releases: 8

Backported from dd7505b
sbuerk added a commit to sbuerk/typo3-testing-framework that referenced this pull request Dec 4, 2024
The bugfix backport to ensure correct system environment path
building to fix issue TYPO3#577 missed to correctly set the flag
for non-composer mode for TYPO3 v12 and lead to wrong path
calculations and followup issues within functional tests.

This is fixed by handing over a correct override value within
the functional test bootstrap.

[1] TYPO3#577
[2] TYPO3#633

Resolves: TYPO3#658
Related: TYPO3#633
Related: TYPO3@409c2b8
Releases: 8

Backported from dd7505b
sbuerk added a commit to sbuerk/typo3-testing-framework that referenced this pull request Dec 4, 2024
The bugfix backport to ensure correct system environment path
building to fix issue TYPO3#577 missed to correctly set the flag
for non-composer mode for TYPO3 v12 and lead to wrong path
calculations and followup issues within functional tests.

This is fixed by handing over a correct override value within
the functional test bootstrap.

[1] TYPO3#577
[2] TYPO3#633

Resolves: TYPO3#658
Related: TYPO3#633
Related: TYPO3@409c2b8
Releases: 8

Backported from dd7505b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants