Fix fatal error in database_attachments plugin under some conditions (#1489726)