Deprecation: #109575 - Various ContentObjectRenderer properties/methods
See forge#109575
Description
Several properties and a methods of
\TYPO3\ have been
deprecated.
Properties
ContentObjectRenderer->$lastTypoLinkResult
The property held the
\TYPO3\
produced by the most recent
create call. Relying on a
side-effect property that is overwritten on every subsequent link call is
fragile. Use the return value of
create directly instead.
ContentObjectRenderer->$currentRecordNumber and
ContentObjectRenderer->$parentRecordNumber
These counters are incremented by
Content and
Records while iterating over their record sets, and
exposed to TypoScript via
get.
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\
to decode FlexForm data, and map the result into your own configuration
structure as needed.
TypoScript getData type
The
cobj: type for the
getData function is deprecated.
It returned the value of
$parent, which is now
deprecated.
ContentObjectRenderer->getRequest() fallback to
$GLOBALS['TYPO3_REQUEST']
The
get method falls back to
$GLOBALS when no request
had been set via
set before. This fallback has been deprecated. Third-party code that
instantiates
Content must call
set
before calling
start or any other method that requires the request.
Impact
Accessing
$last or
$check, calling
read,
evaluating the
cobj: getData type, or
triggering the
$GLOBALS fallback in
get all raise
E_ errors at runtime.
The fallback will additionally throw an exception in TYPO3 v15 when no
request has been set.
$current and
$parent carry only a
docblock
@deprecated annotation for now — they remain functional
and do not raise runtime errors.
Affected installations
Installations with extensions that:
- Read
$cafter callingObj->last Typo Link Result createLink () - Read
$current,Record Number $parent, orRecord Number $checkPid_ bad Doktype List - Call
$cObj->read Flexform Into Conf () - Use the
cobj:getData type in TypoScript;parent Record Number - Instantiate
Contentwithout callingObject Renderer setbeforeRequest () start.()
The extension scanner detects usages of the deprecated properties as weak matches.
Migration
$lastTypoLinkResult
Capture the return value of
create directly:
// Before
$cObj->createLink($linkText, $conf);
$result = $cObj->lastTypoLinkResult;
// After
$result = $cObj->createLink($linkText, $conf);
setRequest() before
start()
Call
set 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);
readFlexformIntoConf()
Replace with
Flex and
map the decoded array into the configuration structure as needed:
// Before
$conf = [];
$cObj->readFlexformIntoConf($flexFormXml, $conf);
// After
$conf = $this->flexFormTools->convertFlexFormContentToArray($flexFormXml);
All other deprecated items
Remove all usages. None of the remaining deprecated properties, nor
cobj: getData type have a replacement.