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

  1. Remove the setPriority() call for transports without priority support, or pass null.
  2. For Beanstalk, set the job priority at put() time instead (the put priority parameter), not on the producer.
  3. 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

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


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/e7a6c74f4b0895bc. Report an issue: GitHub.