Deprecation: #109575 - Various ContentObjectRenderer properties/methods 

See forge#109575

Description 

Several properties and a methods of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer have been deprecated.

Properties 

ContentObjectRenderer->$lastTypoLinkResult 

The property held the \TYPO3\CMS\Frontend\Typolink\LinkResultInterface produced by the most recent createLink() call. Relying on a side-effect property that is overwritten on every subsequent link call is fragile. Use the return value of createLink() directly instead.

ContentObjectRenderer->$currentRecordNumber and ContentObjectRenderer->$parentRecordNumber 

These counters are incremented by ContentContentObject and RecordsContentObject while iterating over their record sets, and exposed to TypoScript via getData cobj:parentRecordNumber. They carry no known use case for third-party extensions and are deprecated.

ContentObjectRenderer->$checkPid_badDoktypeList 

The property was intended to cache a comma-separated list of page doctypes that should be excluded from link target checks, but it was never written to or read from any code path in TYPO3 itself.

Methods 

ContentObjectRenderer->readFlexformIntoConf() 

The method parses a FlexForm XML string or array into a flat TypoScript configuration array. It only covered the sDEF sheet and had no equivalent in TYPO3 core itself. Use \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::convertFlexFormContentToArray() to decode FlexForm data, and map the result into your own configuration structure as needed.

TypoScript getData type 

The cobj:parentRecordNumber type for the getData function is deprecated. It returned the value of $parentRecordNumber, which is now deprecated.

ContentObjectRenderer->getRequest() fallback to $GLOBALS['TYPO3_REQUEST'] 

The getRequest() method falls back to $GLOBALS['TYPO3_REQUEST'] when no request had been set via setRequest() before. This fallback has been deprecated. Third-party code that instantiates ContentObjectRenderer must call setRequest(ServerRequestInterface $request) before calling start() or any other method that requires the request.

Impact 

Accessing $lastTypoLinkResult or $checkPid_badDoktypeList, calling readFlexformIntoConf(), evaluating the cobj:parentRecordNumber getData type, or triggering the $GLOBALS['TYPO3_REQUEST'] fallback in getRequest() all raise E_USER_DEPRECATED errors at runtime. The fallback will additionally throw an exception in TYPO3 v15 when no request has been set.

$currentRecordNumber and $parentRecordNumber carry only a docblock @deprecated annotation for now — they remain functional and do not raise runtime errors.

Affected installations 

Installations with extensions that:

  • Read $cObj->lastTypoLinkResult after calling createLink()
  • Read $currentRecordNumber, $parentRecordNumber, or $checkPid_badDoktypeList
  • Call $cObj->readFlexformIntoConf()
  • Use the cobj:parentRecordNumber getData type in TypoScript;
  • Instantiate ContentObjectRenderer without calling setRequest() before start().

The extension scanner detects usages of the deprecated properties as weak matches.

Migration 

$lastTypoLinkResult 

Capture the return value of createLink() directly:

// Before
$cObj->createLink($linkText, $conf);
$result = $cObj->lastTypoLinkResult;

// After
$result = $cObj->createLink($linkText, $conf);
Copied!

setRequest() before start() 

Call setRequest() immediately after instantiation, before any other method:

// Before
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$cObj->start($data, $table);

// After
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$cObj->setRequest($request);
$cObj->start($data, $table);
Copied!

readFlexformIntoConf() 

Replace with FlexFormTools::convertFlexFormContentToArray() and map the decoded array into the configuration structure as needed:

// Before
$conf = [];
$cObj->readFlexformIntoConf($flexFormXml, $conf);

// After
$conf = $this->flexFormTools->convertFlexFormContentToArray($flexFormXml);
Copied!

All other deprecated items 

Remove all usages. None of the remaining deprecated properties, nor cobj:parentRecordNumber getData type have a replacement.