Apen / additional_reports

Useful information in the reports module : xclass, ajax, cliKeys, eID, general status of the system (encoding, DB, php vars...), hooks, compare local and TER extension (diff), used content type, used plugins, ExtDirect... It can really help you during migration or new existing project (to have a global reports of the system).
Other
12 stars 11 forks source link

Using icon identifier breaks plugin and content type report #48

Open tbsschmdt opened 7 months ago

tbsschmdt commented 7 months ago

In TYPO3 11 current version 3.4.7 breaks Plugins & Content Types report under certain circumstances. If a plugin uses an icon identifier instead of a path the method getPublicResourceWebPath in sysext/core/Classes/Utility/PathUtility.php throws the following error:

TYPO3\CMS\Core\Resource\Exception\InvalidFileException Resource paths must start with "EXT:"

This method is called in method getContentInfosFromTca in additional_reports/Classes/Utility.php, line 266. This error has been introduced with commit d283b8b.

You can register an icon in ext_localconf.php (or since TYPO3 11.4 in Icons.php):

$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon(
    'ext-myext-icon',
    \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
    ['source' => 'EXT:myext/Resources/Public/Icons/Extension.svg']
);

Then you can use the icon identifier in method addPlugin():

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
    [
        'PLUGIN_NAME',
        'myext_pi1',
        'ext-myext-icon'
    ],
    'list_type',
    'myext'
);
tbsschmdt commented 7 months ago

I lack an overall view but it seems that the TYPO3 core uses FormEngineUtility::getIconHtml() to render icon markup from either icon paths or icon identifiers.

Apen commented 5 months ago

Hi, sorry for the long delay... have a few time for OSS. Could you provide me a small test extension to reproduce the bug? That could be faster for me.

dbitsch-no commented 3 months ago

Same issue happens here on the latest v12.

It seems that also Mask elements seem to break the Addional Reports page.

Error when having an icon identifier (which Mask seems to create on the fly / by itself):

TYPO3\CMS\Core\Utility\PathUtility::getAbsoluteWebPath(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/html/vendor/apen/additional_reports/Classes/Utility.php on line 290

Error when using no icon or icon from the root directory of the extension /example_ext/ext_icon.png:

EXT:example_ext/ext_icon.png is expected to be in public directory, but it is not

So you should be able to reproduce the error simply by installing mask/mask and create one simple element without an icon. But even setting an icon breaks your code.

I could fix the error by editing your core extension files and adding two !empty() conditions:

addional_reports/Classes/Utility.php - Line 259: -- if (PathUtility::isExtensionPath($itemValue['icon'])) { ++ if (!empty($itemValue['icon']) && PathUtility::isExtensionPath($itemValue['icon'])) {

addional_reports/Classes/Utility.php - Line 287: -- if (str_contains($icon['options']['source'], 'EXT:')) { ++ if (!empty($icon['options']['source']) && str_contains($icon['options']['source'], 'EXT:')) {

addional_reports/Classes/Utility.php - Line 289: -- } else { ++ } elseif(!empty($icon['options']['source']) && str_contains($icon['options']['source'], 'http')) {

Best Regards Dennis