phalcon/cphalcon · warning · Phalcon\Acl\Exceptions\InvalidRoleType
Role must be either a string or implement RoleInterface
Error message
Role must be either a string or implement RoleInterface
What it means
AbstractProducer::setPriority() throws PriorityNotSupportedException for any non-null priority value; null (the default) is accepted. This is the capability-declaration pattern of this queue layer: transports without priority semantics (Beanstalk priority here is bound at put-time, not per producer) reject per-producer priority configuration.
Source
Thrown at phalcon/Acl/Adapter/Memory.zep:414
* $acl->addRole(
* new Phalcon\Acl\Role("administrator"),
* "consultant"
* );
*
* $acl->addRole("administrator", "consultant");
* $acl->addRole("administrator", ["consultant", "consultant2"]);
* ```
*/
public function addRole(role, accessInherits = null) -> bool
{
var roleName, roleObject;
if typeof role === "object" && role instanceof RoleInterface {
let roleObject = role;
} elseif is_string(role) {
let roleObject = new Role(role);
} else {
throw new InvalidRoleType();
}
let roleName = roleObject->getName();
if isset this->roles[roleName] {
return false;
}
let this->roles[roleName] = roleObject;
if null !== accessInherits {
return this->addInherit(roleName, accessInherits);
}
return true;
}
/**View on GitHub (pinned to b7419de9cd)
Solutions
- Remove the setPriority() call for transports without priority support, or pass null.
- For Beanstalk, set the job priority at put() time instead (the put priority parameter), not on the producer.
- If per-message priority is required, select a transport that overrides setPriority().
Example fix
// before $producer->setPriority(5); $producer->send($destination, $message); // after (Beanstalk-style transport: priority belongs to put()) $producer->send($destination, $message); // pass priority via the transport-specific put options rather than the producer
Defensive patterns
Strategy: try-catch
Try / catch
try {
$producer->setPriority($priority);
} catch (\Phalcon\Queue\Exceptions\PriorityNotSupportedException $e) {
// fall back to the transport's default priority; do not fail the dispatch
$logger->info('Priority ignored: unsupported by this transport');
} Prevention
- Treat priority as optional metadata; wrap the setter when brokers vary.
- For Beanstalk, set priority at put() time instead of on the producer.
When it happens
Trigger: $producer->setPriority(5) on a producer whose class does not override setPriority().
Common situations: Reusable job-dispatch code shared across brokers that configures priority uniformly; migrating from enqueue/queue-interop backends where setPriority(null) round-trips harmlessly; documenting per-message priorities that the transport cannot honor.
Related errors
- Role '{roleName}' (to inherit) produces an infinite loop
- Access '{accessName}' does not exist in component '{componen
- Access '{access}' does not exist in component '{componentNam
- {elementName} '{element}' does not exist in the {suffix}
- Your passed parameter does not have the same class as the pa
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/e7a6c74f4b0895bc.
Report an issue: GitHub.