HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux aritmodecarnaval.es 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/www/torresncgolf/wp-content/plugins/wp-migrate-db/class/Common/Queue/Connection.php
<?php

namespace DeliciousBrains\WPMDB\Common\Queue;


use WP_Error;
use wpdb;

class Connection extends Connections\DatabaseConnection {

    /**
     * DatabaseQueue constructor.
     *
     * @param wpdb   $wpdb                WP database object, default global object.
     * @param array  $allowed_job_classes Job classes that may be handled, default any Job subclass.
     * @param string $prefix              Table prefix, default temp_prefix.
     */
    public function __construct(wpdb $wpdb = null, $allowed_job_classes = [], $prefix = null)
    {
        if (null === $wpdb) {
            $wpdb = $GLOBALS['wpdb'];
        }
        if (null === $prefix) {
            $prefix = $GLOBALS['wpmdbpro']->get('temp_prefix');
        }

        // We should be able to call parent to set database
        // and allowed_job_classes, but unit test setup is broken
        // and throws a wobbly in Mockery. Yay, mocks. 😞
        // parent::__construct($wpdb, $allowed_job_classes);
        $this->database            = $wpdb;
        $this->allowed_job_classes = $allowed_job_classes;

        $this->jobs_table     = $prefix . 'queue_jobs';
        $this->failures_table = $prefix . 'queue_failures';
    }

	/**
	 * Get list of jobs in queue
	 *
	 * @param int  $limit
	 * @param int  $offset
	 * @param bool $raw if true, method will return serialized instead of instantiated objects
	 *
	 * @return array|WP_Error
	 */
	public function list_jobs( $limit, $offset, $raw = false ) {
		$offset  = null === $offset ? 0 : $offset;
		$limit   = null === $limit ? 9999999 : $limit;
		$raw_sql = "
			SELECT * FROM {$this->jobs_table}
			WHERE reserved_at IS NULL
			AND available_at <= %s
			LIMIT %d,%d
		";
		$sql     = $this->database->prepare( $raw_sql, $this->datetime(), $offset, $limit );
		$results = $this->database->get_results( $sql );

		if ( $raw ) {
			return $results;
		}

		$jobs = [];
		foreach ( $results as $raw_job ) {
            $job = $this->vitalize_job($raw_job);

            if ($job && is_a($job, Job::class)) {
                $jobs[$raw_job->id] = $job;
            } else {
                return new WP_Error(
                    'invalid-queue-job',
                    __('An invalid item was found in the queue of files to be transferred.', 'wp-migrate-db')
                );
            }
		}

		return $jobs;
	}
}