Returns issue of Jira

@param mixed $query

@return array An array of issue
@throws \Exception

@see https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-get
557976
public function one($query)
    {
        $authSession = $this->repositoryDispatcher->getCookieAuthSession();

        $url = null;
        $options = [
            RequestOptions::HEADERS => [
                'Cookie' => $authSession->getName() . '=' . $authSession->getValue(),
            ],
        ];

        // Prepares request options
        if (is_scalar($query)) {
            $url = $this->endpoint . '/rest/api/2/issue/' . $query;
        } elseif (is_array($query)
            && (array_key_exists('id', $query) || array_key_exists('key', $query))
        ) {
            // Prepares key by query
            if (isset($query['id'])) {
                $url = $this->endpoint . '/rest/api/2/issue/' . $query['id'];
                unset($query['id']);
            } elseif (isset($query['key'])) {
                $url = $this->endpoint . '/rest/api/2/issue/' . $query['key'];
                unset($query['key']);
            }

            // Prepares query params
            foreach ($query as $param => $value) {
                if ('fields' === $param) {
                    if (is_array($value)) {
                        $query[$param] = implode(',', $value);
                    }
                } elseif ('expand' === $param) {
                    if (is_array($value)) {
                        $query[$param] = implode(',', $value);
                    }
                } else {
                    unset($query[$param]);
                }
            }

            $options[RequestOptions::QUERY] = $query;
        } else {
            throw new \Exception('Bad params');
        }

        $response = $this->client->request('GET', $url, $options);

        $body = $response->getBody();
        $body->seek(0);
        $contents = $body->getContents();

        $issue = $this->createInstance(json_decode($contents, true));

        return $issue;
    }
66606
public function search($query) {
        global $CFG;
        if ($result = parent::search($query)) {
            return $result;
        }

        $found = false;
        require_once($CFG->dirroot . '/question/engine/lib.php');
        foreach (core_component::get_plugin_list('qbehaviour') as $behaviour => $notused) {
            if (strpos(core_text::strtolower(question_engine::get_behaviour_name($behaviour)),
                    $query) !== false) {
                $found = true;
                break;
            }
        }
        if ($found) {
            $result = new stdClass();
            $result->page     = $this;
            $result->settings = array();
            return array($this->name => $result);
        } else {
            return array();
        }
    }
149770
public function get($resource, array $query = [])
    {
        $exec = $this->execute(Method::$HTTP_GET, $resource, ['query' => $query]);

        return $exec;
    }
914996
public function getRows($query) {
        try {
            $stmt = $this->db->query($query);
            return $stmt->fetchAll(PDO::FETCH_ASSOC);
        } catch (Exception $e) {
            return [];
        }
    }
413071
final public function queryArray(string $query)
    {
        $result = $this->queryResult($query);
        if (false === $result) {
            return false;
        }

        $return = [];
        while (false !== $row = $result->fetchRow()) {
            $return[] = $row;
        }
        return $return;
    }
1015401
public function getEditMetadata($issue)
    {
        $path = "/issue/{$issue}/editmeta";

        try {
            $data = $this->client->callGet($path)->getData();

            if (!isset($data['fields'])) {
                throw new JiraException("Bad metadata");
            }

            return $data;
        } catch (Exception $e) {
            throw new JiraException("Failed to retrieve issue metadata", $e);
        }
    }
62533
public function unprepared($query)
    {
        $start = $this->getLogTime();

        try {

            $result = $this->wpdb->query($query);

            if ($result === false || $this->wpdb->last_error) {
                throw new QueryException($query, [], new \Exception($this->wpdb->last_error));
            }

            return $result;

        } catch (QueryException $e) {
            throw $e;
        } finally {
            $this->logQuery($query, [], $this->getElapsedTime($start));
        }

    }
499093
public function runCount($query)
	{
		if (isset($this->stored_query_totals[md5(serialize($query))])) {
			return $this->stored_query_totals[md5(serialize($query))];
		}
		
		$query['terms'] = trim($query['terms']);
		if (isset($query['numericFilters'])) {
			$query['numericFilters'] = implode(',', $query['numericFilters']);
		}
		if (isset($query['facets'])) {
			$query['facets'] = implode(',', $query['facets']);
		}
		
		try {
			return array_get($this->getIndex()->search(array_get($query, 'terms'), array_get($query, 'query')), 'nbHits');
		} catch (\Exception $e) {
			return 0;
		}
	}
410207
public function fetch($query)
    {
        $result = $this->query($query);

        return $result->fetch(\PDO::FETCH_ASSOC);
    }
988593
public static function getAll($query)
    {
        $ret = array();

        $res = self::query($query);
        if ($res) {
            while ($row = self::connection()->sql_fetch_assoc($res)) {
                $ret[] = $row;
            }
            self::free($res);
        }

        return $ret;
    }
997311
private function parseQueryError(string $query): array
    {
        $return = ['sql_state' => null, 'code' => null, 'message' => 'Unknown error.'];
        if ($error = error_get_last()) {
            $error = explode("\n", $error['message']);
            // search for sql state
            preg_match('~ERROR:\s+(?<sql_state>[0-9A-Z]+?):\s+(?<message>.+)~', $error[0], $match);
            if (isset($match['sql_state'], $match['message'])) {
                $return['sql_state'] = $match['sql_state'];
                // line & query details etc.
                if (count($error) == 3 && preg_match('~(LINE\s+(?<line>\d+):\s+).+~', $error[1], $match2)) {
                    $return['message'] = sprintf('%s, line %d. Query: "%s".', ucfirst($match['message']),
                        $match2['line'], $query);
                } else {
                    $return['message'] = $match['message'] .'.';
                }
            }
        }

        return $return;
    }
1120213
public function fetchResults($query, $page = 1, $maxPerPage = 10, $filter = false, $paginate = false)
    {
        if ($paginate) {
            if (!$this->pager) {
                throw new \Exception('Please inject a pager on ResultBuilder');
            }

            $results = $this->pager->paginate($query, $page, $maxPerPage);
        } else {
            $results = $this->queryExecutor->fetch($query, $page, $maxPerPage);
        }

        if ($filter) {
            return $this->filterManager->filter($results);
        }

        return $results;
    }
1125747
protected function executeQuery($query)
    {
        $dataBase = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
        $success = true;
        try {
            $dataBase->execute($query);
        } catch (\OxidEsales\Eshop\Core\Exception\StandardException $exception) {
            \OxidEsales\Eshop\Core\Registry::getLogger()->error($exception->getMessage(), [$exception]);
            $success = false;
        }

        return $success;
    }
1227802
public function search($query) {
        $found = array();

        foreach ($this->settings as $setting) {
            if ($setting->is_related($query)) {
                $found[] = $setting;
            }
        }

        if ($found) {
            $result = new stdClass();
            $result->page     = $this;
            $result->settings = $found;
            return array($this->name => $result);
        }

        $found = false;
        if (strpos(strtolower($this->name), $query) !== false) {
            $found = true;
        } else if (strpos(core_text::strtolower($this->visiblename), $query) !== false) {
                $found = true;
            }
        if ($found) {
            $result = new stdClass();
            $result->page     = $this;
            $result->settings = array();
            return array($this->name => $result);
        } else {
            return array();
        }
    }
244000
private function validateQuery(SearchQuery $query)
    {
        $indexNames = $this->getIndexNames();
        $queryIndexNames = $query->getIndexes();

        foreach ($queryIndexNames as $queryIndexName) {
            if (!in_array($queryIndexName, $indexNames)) {
                $unknownIndexes[] = $queryIndexName;
            }
        }

        if (false === empty($unknownIndexes)) {
            throw new Exception\SearchException(
                sprintf(
                    'Search indexes "%s" not known. Known indexes: "%s"',
                    implode('", "', $queryIndexNames),
                    implode('", "', $indexNames)
                )
            );
        }
    }
877423
public function query($query)
    {

        if (empty($query) || !$this->db) {
            return false;
        }


        // if the resource type is not a mysql link it should try to reconnect
        if (!$this->db->isConnected()) {
            $this->db->ping();
        }

        // the last sql query
        $this->lastSql = (string)$query;


        // if the master is down a select may query the slave but it should not
        // insert anything
        if ($this->slaveConnection === $this->db && stripos(trim($query), 'SELECT') !== 0) {
            throw new DatabaseException(__METHOD__ . ' no Select on slave, abort !!', self::ERR_CONN, self::SEVERITY_LOG, __FILE__, __LINE__);
        }

        // tries execute the query and fetches the result
        $res             = $this->db->getDbAdapter()->query($query);


        try {
            // in cases of errors
            if (!$res) {
                $this->error   = $this->db->getDbAdapter()->getErrorInfo();
                $this->errorno = $this->db->getDbAdapter()->getErrorCode();
                throw new DatabaseException(__METHOD__ . "\nsql: $this->lastSql\nsql_error:$this->error\nsql_errorno:$this->errorno", self::ERR_EXEC, self::SEVERITY_LOG, __FILE__, __LINE__);
            } else {
                $this->insert_id = $this->db->getDbAdapter()->getLastInsertId();
            }
        } catch (DatabaseException $e) {
            if (Config::get('use_exception') !== true) {
                return false;
            }
            throw $e;
        }

        // reset old errors
        $this->error         = '';
        $this->errorno       = 0;
        if ($res && $res instanceof \PDOStatement){
            $this->affected_rows = $this->db->getDbAdapter()->getAffectedRows($res);
        }

        return $res;
    }
1000025
public function request(&$query)
    {
        global $_web_access_compress_reply;
        global $_web_access_post_xmlrpc;
        global $_web_access_retry_timeout;
        global $_web_access_retry_timeout_max;

        $query['State'] = 'BAD';
        $query['HDatas'] = '';
        $query['Datas'] = '';
        $query['DatasSize'] = 0;
        $query['DatasSent'] = 0;
        $query['Response'] = '';
        $query['ResponseSize'] = 0;
        $query['Headers'] = array();
        $query['Close'] = false;
        $query['Times'] = array(
            'open' => array(-1.0, -1.0),
            'send' => array(-1.0, -1.0),
            'receive' => array(-1.0, -1.0, 0),
        );


        // if async, in error, and maximal timeout, then forget the request and return false.
        if (($query['Callback'] != null) && ($this->_state == 'BAD')) {
            if ($this->_bad_timeout > $_web_access_retry_timeout_max) {
                $this->console->writeln($this->_webaccess_str.'$f00Request refused for consecutive errors $555('.$this->_bad_timeout
                    ." / ".$_web_access_retry_timeout_max.")");

                return false;
            } else {
                // if not max then accept the request
                // and try a request (minimum $_web_access_retry_timeout/2 after previous try)
                $time = time();
                $timeout = ($this->_bad_timeout / 2) - ($time - $this->_bad_time);
                if ($timeout < 0) {
                    $timeout = 0;
                }
                $this->_bad_time = $time - $this->_bad_timeout + $timeout;
            }
        }

        // build datas to send
        if (($query['Callback'] == null) || (is_array($query['Callback']) &&
                isset($query['Callback'][0]) &&
                is_callable($query['Callback'][0]))
        ) {

            if (is_string($query['QueryDatas']) && strlen($query['QueryDatas']) > 0) {
                $msg = "POST ".$query['Path']." HTTP/1.1\r\n";
                $msg .= "Host: ".$this->_host."\r\n";
                $msg .= "User-Agent: ".$this->_agent."\r\n";
                $msg .= "Cache-Control: no-cache\r\n";

                if ($_web_access_compress_reply) {
                    // ask compression of response if gzdecode() and/or gzinflate() is available
                    if (function_exists('gzdecode') && function_exists('gzinflate')) {
                        $msg .= "Accept-Encoding: deflate, gzip\r\n";
                    } elseif (function_exists('gzdecode')) {
                        $msg .= "Accept-Encoding: gzip\r\n";
                    } elseif (function_exists('gzinflate')) {
                        $msg .= "Accept-Encoding: deflate\r\n";
                    }
                }

                // echo "\nData:\n\n".$query['QueryDatas']."\n";  // for debug purposes, don't remove!

                if ($query['IsXmlrpc'] === true) {
                    if ($_web_access_post_xmlrpc) {
                        $msg .= "Content-type: application/x-www-form-urlencoded; charset=UTF-8\r\n";

                        echo "\n=========================== Data =================================\n\n".$query['Datas']."\n";

                        $query['QueryDatas'] = "xmlrpc=".urlsafe_base64_encode($query['QueryDatas']);
                    } else {
                        $msg .= "Content-type: text/xml; charset=UTF-8\r\n";
                    }

                    if ($this->_compress_request == 'gzip' && function_exists('gzencode')) {
                        $msg .= "Content-Encoding: gzip\r\n";
                        $query['QueryDatas'] = gzencode($query['QueryDatas']);
                    } elseif ($this->_compress_request == 'deflate' && function_exists('gzdeflate')) {
                        $msg .= "Content-Encoding: deflate\r\n";
                        $query['QueryDatas'] = gzdeflate($query['QueryDatas']);
                    }
                } elseif (is_string($query['IsXmlrpc'])) {
                    $msg .= "Content-type: ".$query['IsXmlrpc']."\r\n";
                    $msg .= "Accept: */*\r\n";
                } else {
                    $msg .= "Content-type: ".$query['MimeType']."\r\n";
                    $msg .= "Accept: */*\r\n";
                }

                $msg .= "Content-length: ".strlen($query['QueryDatas'])."\r\n";

                $query['HDatas'] = $msg;

                $query['State'] = 'OPEN';
                $query['Retries'] = 0;

                // print_r($msg); for debugging purposes - don't remove

                // add the query in spool
                $this->_spool[] = &$query;

                if ($query['Callback'] == null) {
                    $this->_wait = true;
                    $this->_open($query['OpenTimeout'], $query['WaitTimeout']); // wait more in not callback mode
                    $this->_spool = array();
                    $this->_wait = false;

                    return $query['Response'];
                } else {
                    $this->_open();
                }
            } else {
                $msg = "GET ".$query['Path']." HTTP/1.1\r\n";
                $msg .= "Host: ".$this->_host."\r\n";
                $msg .= "User-Agent: ".$this->_agent."\r\n";
                $msg .= "Cache-Control: no-cache\r\n";
                if ($_web_access_compress_reply) {
                    // ask compression of response if gzdecode() and/or gzinflate() is available
                    if (function_exists('gzdecode') && function_exists('gzinflate')) {
                        $msg .= "Accept-Encoding: deflate, gzip\r\n";
                    } elseif (function_exists('gzdecode')) {
                        $msg .= "Accept-Encoding: gzip\r\n";
                    } elseif (function_exists('gzinflate')) {
                        $msg .= "Accept-Encoding: deflate\r\n";
                    }
                }
                $msg .= "Content-type: ".$query['MimeType']."; charset=UTF-8\r\n";
                $msg .= "Content-length: ".strlen($query['QueryDatas'])."\r\n";
                $query['HDatas'] = $msg;

                $query['State'] = 'OPEN';
                $query['Retries'] = 0;

                // add the query in spool
                $this->_spool[] = &$query;

                if ($query['Callback'] == null) {
                    $this->_wait = true;
                    $this->_open($query['OpenTimeout'], $query['WaitTimeout']); // wait more in not callback mode
                    $this->_spool = array();
                    $this->_wait = false;

                    return $query['Response'];
                } else {
                    $this->_open();
                }
            }

        } else {

            $this->console->writeln($this->_webaccess_str.'Bad callback function:$fff '.$query['Callback']);

            return false;
        }

        return true;
    }