powermail
powermail copied to clipboard
Multiple Edit Content Elements Error: In2code\Powermail\Utility\DatabaseUtility::getPidForRecord(): Argument #1 ($uid) must be of type int, string given, called in /var/www/vendor/in2code/powermail/Classes/EventListener/FlexFormParsingModifyEventListener.php on line 89
When using the list view to edit multiple content elements simultaneously, for example, by modifying the header on a page where a Powermail plugin exists, Powermail fails. This is because getPidForCurrentRecord assumes that it always receives only one UID in the request.
A possible solution could be to add a simple string check or implement a more elegant approach:
private function getPidForCurrentRecord(): int
{
$request = $this->getRequest();
$queryParams = $request->getQueryParams();
$uid = array_keys($queryParams['edit']['tt_content'] ?? [])[0] ?? 0;
if (is_string($uid)) {
$uid = intval(explode(",",$uid)[0]);
}
return DatabaseUtility::getPidForRecord($uid, 'tt_content');
}