Skip to content

Commit

Permalink
Merge pull request #17 from sschuberth/master
Browse files Browse the repository at this point in the history
Misc. fixes, partly to work with newer Gerrit versions
  • Loading branch information
andygrunwald committed Jan 19, 2016
2 parents e512a94 + 8430e70 commit 82c66fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/Gerrie/API/DataService/DataServiceFactory.php
Expand Up @@ -48,6 +48,10 @@ public static function getDataService(array $instanceConfig)
throw new \RuntimeException($exceptionMessage, 1415453791);
}

if (!array_key_exists('port', $instanceDetails)) {
$instanceDetails['port'] = null;
}

$instanceConfig['Instance'] = $instanceDetails;

$scheme = strtoupper($instanceConfig['Instance']['scheme']);
Expand Down Expand Up @@ -133,4 +137,4 @@ protected static function getHTTPClientInstance(array $instanceConfig)

return $restClient;
}
}
}
16 changes: 10 additions & 6 deletions src/Gerrie/Gerrie.php
Expand Up @@ -791,11 +791,14 @@ protected function proceedChangeset(array $changeSet, array $project)
'commit_message' => $changeSet['commitMessage'],
'created_on' => $changeSet['createdOn'],
'last_updated' => $changeSet['lastUpdated'],
'sort_key' => $changeSet['sortKey'],
'open' => intval($changeSet['open']),
'status' => $changeSet['status'],
);

if (isset($changeSet['sortKey']) === true) {
$changeSetData['sort_key'] = $changeSet['sortKey'];
}

// A changeset don`t have a unique identifier.
// The Gerrit documentation says that "<project>~<branch>~<Change-Id>" will be enough
// @see https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-id
Expand Down Expand Up @@ -1211,7 +1214,8 @@ protected function proceedPatchset(array $patchset, array $changeSet)
'sizeInsertions',
'sizeDeletions',
'isDraft',
'createdOn'
'createdOn',
'kind'
);
$patchset = $this->unsetKeys($patchset, $keysToDelete);

Expand Down Expand Up @@ -1558,7 +1562,7 @@ protected function getLastSortKey(array $data)
{
$lastChangeSet = $this->transferJsonToArray(array_pop($data));

return $lastChangeSet['sortKey'];
return (isset($lastChangeSet['sortKey']) === true) ? $lastChangeSet['sortKey'] : null;
}

/**
Expand Down Expand Up @@ -1644,7 +1648,7 @@ protected function getGerritProjectsByName($serverId, array $names)
$nameList = implode(',', $names);

$query = 'SELECT `id`, `name` FROM ' . Database::TABLE_PROJECT . '
WHERE `server_id` = :server_id AND FIND_IN_SET(`name`, :names) > 0';
WHERE `server_id` = :server_id AND FIND_IN_SET(BINARY `name`, :names) > 0';
$statement = $dbHandle->prepare($query);

$statement->bindParam(':server_id', $serverId, \PDO::PARAM_INT);
Expand Down Expand Up @@ -1964,7 +1968,7 @@ protected function checkIfServersFirstRun($level, $exceptionCode, $debugInformat
* We save name, description and parent project.
*
* @param array $project Project info like description or parent project
* @param array $parentMapping Array where parent / child releation will be saved
* @param array $parentMapping Array where parent / child relation will be saved
* @return int
*/
public function importProject(array $project, array &$parentMapping)
Expand Down Expand Up @@ -2157,4 +2161,4 @@ public function isDebugFunctionalityEnabled()
{
return $this->debug;
}
}
}

0 comments on commit 82c66fe

Please sign in to comment.