Bug #81813

Updated by Tizian Schmidlin about 2 years ago

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 <code>@throws</code> @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:

<pre><code class="PHP">
/**
* 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 '';
}
}
</code></pre>

I'll leave the category open on purpose since I'm not sure to which "Backend"-category this belongs.

Regards
Tizian

Back