PHP8兼容性问题求助:Unsupported operand types: array & int错误
The error occurs because fetch_permissions() now returns an associative array of permissions instead of an integer bitmask. PHP8 strictly prohibits bitwise operations (&) between an array and integer—an operation that silently failed or coerced in older PHP versions.
Corrected Code
Replace the two problematic lines in your process_attachments() function with direct array key checks:
$attach->process_attachments( $this->post, $this->post['allattachments'], (THIS_SCRIPT == 'external'), can_moderate($this->forum['forumid'], 'canmoderateattachments'), $forumperms['cangetattachment'], // Replaced bitwise operation with array lookup $forumperms['canseethumbnails'] // Replaced bitwise operation with array lookup );
Explanation
Modern forum software (like vBulletin) shifted from integer bitmasks to explicit permission arrays. Instead of using bitwise logic to extract permissions from a single integer, you now access the permission directly via its key in the $forumperms array.
For added safety (in case a permission key is missing), use the null coalescing operator to fall back to false:
$forumperms['cangetattachment'] ?? false, $forumperms['canseethumbnails'] ?? false
内容的提问来源于stack exchange,提问作者ZADeltaEcho

