/** * * cmd posible values: * 'getCasesInfo' - in response there will be returned set of cases and subcases info formated in WikiText * 'getComment' - in response there will be returned comments for particular case */ public static function getFogbugzServiceResponse() { global $wgRequest, $wgHTTPProxy, $wgFogbugzAPIConfig; $command = $wgRequest->getText('cmd'); $myFBService = new FogbugzService($wgFogbugzAPIConfig['apiUrl'], $wgFogbugzAPIConfig['username'], $wgFogbugzAPIConfig['password'], $wgHTTPProxy); // there should be made some kind of protection from setting different value as cmd if ($command == 'getCasesInfo') { $outerIDs = $wgRequest->getArray('IDs'); $results = array(); try { $results = $myFBService->logon()->getCasesBasicInfo($outerIDs); } catch (Exception $e) { $results = array(); } $preparedResults = FogbugzTag::sortAndMakeTickets($results); $response = new AjaxResponse(); $response->addText(json_encode($preparedResults)); } else { // this part is not in use now; it will be after adding displaying comments $outerIDs = $wgRequest->getText('ID'); /* ... */ } if (!$response) { $response = new AjaxResponse(); $response->addText(json_encode(array('status' => wfMsg('fbtag-unknown-error')))); } return $response; }
private function sendToMemCache(array $case) { global $wgMemc; $wgMemc->set(FogbugzService::getMemcKey($case["ixBug"]), $case); }
require_once __DIR__ . '/../../../../maintenance/commandLine.inc'; global $wgRequest, $wgHTTPProxy, $wgFogbugzAPIConfig, $wgMemc; $key = wfSharedMemcKey('FogbugzService', 'LastUpdate'); if (in_array('-h', $argv)) { // if number of parameters wasn't correct or parameters were wrong die("Usage:\tphp FogbugzCache.php [ -c [ clear ] ]\n" . "no options: \n\tupdates data about Fogbugz cases:\n\tin cache (old version)/database(current version)\n" . "options:\n" . "\t-c clear database\n" . "\t-h shows this screen\n"); // I see name should be probably changed } else { if (in_array('-c', $argv)) { echo "Yupie! We are clearing the database!\n"; wfGetDB(DB_MASTER)->delete('fogbugz_cases', '*'); $wgMemc->set($key, null); echo "Database clear!\n"; } else { //$command = $wgRequest->getText('cmd'); $myFBService = new FogbugzService($wgFogbugzAPIConfig['apiUrl'], $wgFogbugzAPIConfig['username'], $wgFogbugzAPIConfig['password'], $wgHTTPProxy); $LastUpdated = $wgMemc->get($key); // we've got dtLastUpdated value echo "Date of last updated case:\n"; print_r($LastUpdated); echo "\n"; $DBconnMSTR = wfGetDB(DB_MASTER); $dateToday = new DateTime(); if ($LastUpdated != null) { echo "Getting cases updated in last 15 mins...\n"; $results = $myFBService->logon()->findAndSaveCasesToMemc('category:"Bug" lastupdated:"-15m.."', false); $totalLastUpdate = ''; // value that should be written in memc after adding/updating data foreach ($results as $res) { if (strtotime($res['dtLastUpdated']) > strtotime($LastUpdated)) { echo "Updating/inserting case " . $res['ixBug'] . " in database...\n";