Bug #81813
closedShorcutButton doesn't handle exceptions in __toString
0%
Description
In TYPO3\CMS\Backend\Template\Components\Buttons\Actions\ShortcutButton
the __toString()
-Method might throw an exception, since the render
-Method uses the ModuleTemplate->makeShortcutIcon
-Method which itself may throw an exception, since this calls BackendUtility::shortcutExists
-Method which itself checks the database with a prepared statement. This might happen if the table lock cannot be acquired for some reason.
Now I don't think that every method making database calls should anootate @throws
if it doesn't handle database exception since this might be handled somewhere higher already but PHPs magic __toString
-method cannot throw an exception and I think that there the exception should be caught and either silenced or handled accordingly to the current environment.
My simple approach would be as follows:
/**
* Renders the button
*
* @return string
*/
public function __toString()
{
try {
return $this->render();
} catch(\Exception) {
// ensure that the exception is handled properly (regarding logging and info text if needed for the shortcut button)
return '';
}
}
I'll leave the category open on purpose since I'm not sure to which "Backend"-category this belongs.
Regards
Tizian