Repository: laravel/framework
File: src/Illuminate/Queue/Worker.php (PHP)

Code before:
     * Get the next job from the queue connection.
     *
     * @param  \Illuminate\Contracts\Queue\Queue  $connection
     * @param  string  $queue
     * @return \Illuminate\Contracts\Queue\Job|null
     */
    protected function getNextJob($connection, $queue)
    {
        $popJobCallback = function ($queue, $index = 0) use ($connection) {
            return $connection->pop($queue, $index);
        };

        $this->raiseBeforeJobPopEvent($connection->getConnectionName());

        try {
            if (isset(static::$popCallbacks[$this->name ?? ''])) {
                if (! is_null($job = (static::$popCallbacks[$this->name ?? ''])($popJobCallback, $queue))) {
                    $this->raiseAfterJobPopEvent($connection->getConnectionName(), $job);
                }

                return $job;
            }

            foreach (explode(',', $queue) as $index => $queue) {
                // Skip paused queues
                if ($this->isQueuePaused($queue)) {
                    continue;
                }

                if (! is_null($job = $popJobCallback($queue, $index))) {
                    $this->raiseAfterJobPopEvent($connection->getConnectionName(), $job);

                    return $job;
                }
            }
        } catch (Throwable $e) {
            $this->exceptions->report($e);

            $this->stopWorkerIfLostConnection($e);

            $this->sleep(1);
        }
    }

    /**
     * Determine if a queue is paused.
     *
     * @param  string  $queue
     * @return bool
     */
    protected function isQueuePaused($queue)

Review comment (suggestion):
Consider situations, where you have three `default` queue on three different connections. In current solution, trying to pause it, you will pause all three queues, leaving no way to pause just one.

You should take connection name into account too, to point exactly to specific queue.

Code after:
     * Get the next job from the queue connection.
     *
     * @param  \Illuminate\Contracts\Queue\Queue  $connection
     * @param  string  $queue
     * @return \Illuminate\Contracts\Queue\Job|null
     */
    protected function getNextJob($connection, $queue)
    {
        $popJobCallback = function ($queue, $index = 0) use ($connection) {
            return $connection->pop($queue, $index);
        };

        $this->raiseBeforeJobPopEvent($connection->getConnectionName());

        try {
            if (isset(static::$popCallbacks[$this->name ?? ''])) {
                if (! is_null($job = (static::$popCallbacks[$this->name ?? ''])($popJobCallback, $queue))) {
                    $this->raiseAfterJobPopEvent($connection->getConnectionName(), $job);
                }

                return $job;
            }

            foreach (explode(',', $queue) as $index => $queue) {
                if ($this->queuePaused($connection->getConnectionName(), $queue)) {
                    continue;
                }

                if (! is_null($job = $popJobCallback($queue, $index))) {
                    $this->raiseAfterJobPopEvent($connection->getConnectionName(), $job);

                    return $job;
                }
            }
        } catch (Throwable $e) {
            $this->exceptions->report($e);

            $this->stopWorkerIfLostConnection($e);

            $this->sleep(1);
        }
    }

    /**
     * Determine if a given connection and queue is paused.
     *
     * @param  string  $connectionName
     * @param  string  $queue
     * @return bool
     */
    protected function queuePaused($connectionName, $queue)