public function setSourceInfoGithub($owner, $repo, $repoDir = null) { $section = new kfLogSection(__METHOD__); $this->sourceInfo = array('issueTrackerUrl' => "https://github.com/{$owner}/{$repo}/issues", 'repoViewUrl' => "https://github.com/{$owner}/{$repo}"); if (is_dir($repoDir)) { $gitInfo = new GitInfo($repoDir); $repoCommitID = $gitInfo->getHeadSHA1(); if ($repoCommitID) { $this->sourceInfo['repoDir'] = $repoDir; $this->sourceInfo['repoCommitID'] = substr($repoCommitID, 0, 8); $this->sourceInfo['repoCommitUrl'] = "https://github.com/{$owner}/{$repo}/commit/{$repoCommitID}"; } else { kfLog("GitInfo for '{$repoDir}' failed."); } } }
/** * @param string $key * @param mixed $data * @param int $ttl * @return bool */ public function set($key, $data, $ttl = 0) { foreach ($this->stores as $store) { if (!$store->set($key, $data, $ttl)) { kfLog("Failed to store value for '{$key}' in " . get_class($store)); } } return true; }
public function query($statement) { kfLog(self::generalizeSQL("query: {$statement}")); return parent::query($statement); }
public function endLogSection($name) { $item = array_pop($this->logSectionStack); if ($item !== $name) { kfLog("Log section mismatch (in: {$item}, out: {$name})"); } }
/** * Get data from MediaWiki API. * * * @param string $url Base url for wiki (from LabsDb::getDbInfo). * @param array $params Query parameters for MediaWiki API * @return object|bool Data from the API response, or boolean false */ function kfApiRequest($url, $params) { $section = new kfLogSection(__METHOD__); $params['format'] = 'json'; if (!isset($params['action'])) { $params['action'] = 'query'; } $apiUrl = "{$url}/w/api.php?" . http_build_query($params); kfLog("request: GET {$apiUrl}"); $response = HttpRequest::get($apiUrl); if (!$response) { return false; } $data = json_decode($response); if (!is_object($data) || isset($data->error)) { return false; } return $data; }