vend / php-resque

PHP port of resque (Workers and Queueing)
MIT License
32 stars 9 forks source link

Be compatible with Resque Ruby GUI #11

Closed dominics closed 4 years ago

dominics commented 9 years ago

Perhaps relevant, from one of my private job classes:

    /**
     * Normalizes the job payload
     *
     * The failure backend keeps the arguments and job type in an associative
     * array/JSON object:
     *
     * args: {
     *   job: someJobName,
     *   data: {
     *     some_data: foo,
     *     some_other_data: etc...
     *   }
     * }
     *
     * However, when resque-web recreates failed jobs, it uses an array instead:
     *
     * args: [
     *   ['job', 'someJobName'],
     *   ['data', {'some_data': foo, 'some_other_data': etc...}]
     * ]
     * @throws RuntimeException
     * @throws InvalidArgumentException
     */
    protected function normalizePayload()
    {
        if (!isset($this->payload['args'])) {
            throw new RuntimeException('Payload has no arguments');
        }

        if (!isset($this->payload['args']['job'])
            && isset($this->payload['args'][0][0])
            && isset($this->payload['args'][1][0])
        ) {
            $normalized = array();

            foreach ($this->payload['args'] as $argument) {
                if (count($argument) == 2 && isset($argument[0]) && isset($argument[1])) {
                    $normalized[$argument[0]] = $argument[1];
                } else {
                    throw new InvalidArgumentException('Invalid job arguments: could not normalize');
                }
            }

            $this->payload['args'] = $normalized;
        }
    }
its-schmii commented 8 years ago

Wondering, ist there a reason why this pull request hasn't been merged yet. FYI - same error occurs on the newer resque web interface as well.