コード例 #1
0
    static function getTasks($phid)
    {
        global $wgManiphestListArcanistPath;
        global $wgManiphestListConduitURI;
        global $wgManiphestListConduitToken;
        $arcopts = '--conduit-uri \'' . $wgManiphestListConduitURI . '\'';
        $arcopts .= ' --conduit-token \'' . $wgManiphestListConduitToken . '\'';
        $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
        $query_command = "{$wgManiphestListArcanistPath} {$arcopts} call-conduit maniphest.search";
        $h = proc_open($query_command, $descriptorspec, $pipes, null, null);
        if (!is_resource($h)) {
            die("Error while calling arcanist.");
        }
        $conduit_command = sprintf('{
        "constraints":{
          "statuses":[ "open" ],
          "projects":[ "%s" ]
        }
			}', $phid);
        fwrite($pipes[0], $conduit_command);
        fflush($pipes[0]);
        fclose($pipes[0]);
        $response = "";
        while ($s = fread($pipes[1], 1024)) {
            $response .= $s;
        }
        #while($s = fread($pipes[2], 1024)) {
        #	$response .= $s;
        #}
        #error_log($response);
        proc_close($h);
        $l = strpos($response, "{");
        $r = strrpos($response, "}");
        if ($l === FALSE || $r === FALSE) {
            $response = "";
        }
        $response = substr($response, $l, $l + $r + 1);
        return ManiphestListCommand::parseTasks(json_decode($response, true), $wgManiphestListConduitURI);
    }