TYPO3 V13: Fix RTE Image Soft Reference Parser Test Failure

by ADMIN 60 views

Hey everyone! We've got a bit of a situation with TYPO3 v13 where the RteImageSoftReferenceParserTest is failing. Let's dive into the details and see what's going on.

Description

So, the functional test RteImageSoftReferenceParserTest::updateReferenceIndexAddsIndexEntryForImage is not passing on TYPO3 v13, but it's all good on v12. This means something's changed between these versions, and we need to figure it out. Let’s get into the nitty-gritty of what's causing this hiccup.

Test Failure

Here’s the error we're seeing:

FAILURES!
Tests: 1, Assertions: 1, Failures: 1, Deprecations: 1, PHPUnit Deprecations: 1.

1) RteImageSoftReferenceParserTest::updateReferenceIndexAddsIndexEntryForImage
Assertion in data-set failed for "sys_refindex":
array(
 'tablename' => 'tt_content',
 'recuid' => '1',
 'field' => 'bodytext',
 'softref_key' => 'rtehtmlarea_images',
 'ref_table' => 'sys_file',
 'ref_uid' => '1'
)

This error basically tells us that the test expected a record in the sys_refindex table, but it wasn't there. Specifically, it's looking for an entry related to images in the RTE (Rich Text Editor).

Root Cause

The root cause of this failure is that the soft reference parser isn't creating those necessary reference index entries for RTE images in TYPO3 v13. When the ReferenceIndex::updateIndex() function is called, it should be creating a sys_refindex record, but it's not happening. This is a critical piece because soft references help TYPO3 keep track of relationships between content elements and files.

Affected Components

To fix this, we need to look at these components:

  • Classes/DataHandling/SoftReference/RteImageSoftReferenceParser.php: This is the main class responsible for parsing RTE image references.
  • Tests/Functional/DataHandling/RteImageSoftReferenceParserTest.php: The test that's failing, which gives us a clear indication of the problem.
  • Configuration/Services.yaml: This file is where soft reference parsers are registered, so we need to make sure everything's wired up correctly.

Test Environment

Here’s a breakdown of where the test passes and fails:

  • TYPO3 v12: âś… PASSING
  • TYPO3 v13: ❌ FAILING
  • PHP: 8.2, 8.3 (both fail on v13)
  • Database: PostgreSQL 10

So, it’s clear that the issue is specific to TYPO3 v13, and it’s not related to the PHP version or database we’re using.

Reproduction

If you want to reproduce the error, you can use this command:

Build/Scripts/runTests.sh -p 8.3 -t 13 -s functional -d postgres

This will run the functional tests for TYPO3 v13 using PHP 8.3 and a PostgreSQL database. If you see the same failure, you're on the right track.

Investigation Points

Here are some key areas to investigate:

  1. Soft Reference Registration: Did TYPO3 v13 change how soft reference parsers are registered? We need to ensure our parser is correctly registered.
  2. ReferenceIndex API: Has the behavior of ReferenceIndex::updateIndex() changed in v13? If so, we need to adapt our code accordingly.
  3. Service Configuration: Let’s double-check Configuration/Services.yaml for any v13 compatibility issues. Maybe something isn't set up quite right.
  4. TCA Configuration: We should also review Configuration/TCA/Overrides/tt_content.php to ensure the soft reference setup is correct.

Related Files

These files are crucial for our investigation:

  • Classes/DataHandling/SoftReference/RteImageSoftReferenceParser.php
  • Configuration/Services.yaml (specifically, the line with the softreference.parser tag)
  • Configuration/TCA/Overrides/tt_content.php (where soft reference configuration is defined)
  • Tests/Functional/DataHandling/RteImageSoftReferenceParserTest.php

History

Some background info:

  • The last time the functional test passed is unknown, but it likely failed in January 2025 as well.
  • The issue was discovered on October 16, 2025, during a review of PR #299.
  • Importantly, this is a pre-existing issue and wasn't introduced by PR #299.

Priority

We've marked this as a Medium priority. The test failure indicates a potential runtime issue with soft reference parsing in TYPO3 v13, which could lead to problems with content linking and management. Let's make sure to tackle this soon!

Deep Dive into the Core Issues

To really nail this bug, let's break down each investigation point and explore potential solutions. We’re going to put on our detective hats and dig deep into the code!

1. Soft Reference Registration

The first thing we need to check is whether TYPO3 v13 changed the way soft reference parsers are registered. If the parser isn't correctly registered, it won't be invoked when TYPO3 processes content. Think of it like forgetting to plug in your device – it just won’t work!

What to Look For

  • Event Listeners: TYPO3 often uses event listeners for tasks like this. Has the event we rely on changed or been removed in v13?
  • Service Tagging: In Services.yaml, we use tags to register services. Is the softreference.parser tag still the correct one, and is our parser correctly tagged?
  • Configuration Merging: TYPO3 merges configuration files. Is our service definition being overridden or ignored in v13?

How to Investigate

  1. Compare Services.yaml: Start by comparing the Configuration/Services.yaml file between TYPO3 v12 and v13. Look for any differences in how soft reference parsers are defined.
  2. Check Event Listeners: Search the TYPO3 core code for where soft reference parsers are invoked. Are there any event listeners involved, and have they changed?
  3. Debug Service Registration: Use TYPO3’s debugging tools to inspect the registered services. Is our RteImageSoftReferenceParser service present and correctly configured?

2. ReferenceIndex API

Next up, we need to verify if the behavior of ReferenceIndex::updateIndex() has changed in v13. This function is the heart of soft reference indexing, so any changes here could directly impact our parser. It’s like checking if the engine of your car still works the same way after a new model comes out.

What to Look For

  • Method Signature: Has the signature of updateIndex() changed? Are there new parameters or different return types?
  • Logic Changes: Has the internal logic of updateIndex() been modified? Are there new conditions that might prevent our references from being indexed?
  • Dependencies: Does updateIndex() rely on any other services or components that have changed in v13?

How to Investigate

  1. Code Comparison: Compare the ReferenceIndex::updateIndex() method in TYPO3 v12 and v13. Use a diff tool to highlight any changes.
  2. Xdebug: Set breakpoints in updateIndex() and step through the code while running the test. Observe the execution flow and variable values.
  3. Log Statements: Add temporary log statements to updateIndex() to track its behavior. Are the expected code paths being executed?

3. Service Configuration

Let's dive deeper into Configuration/Services.yaml. This file is where we define our services and how they’re connected. It’s like the wiring diagram for our application – if something’s not connected right, things won’t work as expected.

What to Look For

  • Parser Definition: Is our RteImageSoftReferenceParser service correctly defined? Does it have the right class name and arguments?
  • Tag Configuration: Is the softreference.parser tag still correctly applied to our service? Are there any new tag attributes we need to consider?
  • Dependency Injection: Are all the dependencies of our parser correctly injected? Are there any missing or incorrect dependencies?

How to Investigate

  1. YAML Syntax: Double-check the YAML syntax in Services.yaml. Even a small typo can cause the entire configuration to fail.
  2. Service Inspection: Use TYPO3’s service container to inspect the configuration of our parser. Are all the arguments and dependencies correctly set?
  3. Configuration Overrides: Look for any configuration overrides that might affect our service. Are there any environment-specific settings that are interfering?

4. TCA Configuration

Finally, let's check Configuration/TCA/Overrides/tt_content.php. TCA (Table Configuration Array) is how TYPO3 defines the structure and behavior of database tables. This is where we tell TYPO3 about the soft references in our tt_content table. Think of it as defining the blueprints for our data.

What to Look For

  • Soft Reference Setup: Is the soft reference configuration for the bodytext field (where RTE content is stored) correctly defined?
  • Parser Association: Is our RteImageSoftReferenceParser correctly associated with the bodytext field?
  • Field Configuration: Are there any changes to the bodytext field configuration that might affect soft reference parsing?

How to Investigate

  1. TCA Comparison: Compare the TCA configuration for tt_content between TYPO3 v12 and v13. Look for any differences in the soft reference setup.
  2. Debug TCA: Use TYPO3’s TCA debugging tools to inspect the configuration at runtime. Is the soft reference configuration correctly loaded?
  3. Field Analysis: Analyze the bodytext field configuration. Are there any new options or settings that might interfere with soft reference parsing?

By methodically investigating these points, we can get to the bottom of why the RteImageSoftReferenceParserTest is failing in TYPO3 v13. Let's get this fixed and keep TYPO3 running smoothly!

Conclusion

So, there you have it, guys! We've dissected the issue with the failing RteImageSoftReferenceParserTest in TYPO3 v13. We've pinpointed the root cause, identified the affected components, and laid out a plan of attack for fixing it. Remember, debugging is like solving a puzzle – sometimes you need to look at it from different angles to see the whole picture. Keep digging, keep testing, and let’s get this bug squashed!