diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-04-27 23:01:20 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-04-27 23:30:33 +0200 |
commit | b384f32fec78d221fe1dff949f17e98b8cb4272d (patch) | |
tree | fdf7210647e08c70302022d4157bee16c0ec772b /web/lib | |
parent | dda19c8e01321726912b417c41d7d25eee5e081f (diff) | |
download | aur-b384f32fec78d221fe1dff949f17e98b8cb4272d.tar.gz aur-b384f32fec78d221fe1dff949f17e98b8cb4272d.tar.xz |
Fix the RPC interface
* Fix the SQL query to conform to the new database layout.
* Remove the license field from replies. The license field is now stored
in a separate table and no longer returned on search queries.
* Add a "PackageBase" field that contains the name of the package base
of every package in the result.
* Fix the source tarball URL. The URL is now built based on the package
base name instead of the package name.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/aurjson.class.php | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index 4364e5dd..38cdd656 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -18,8 +18,9 @@ class AurJSON { 'search', 'info', 'multiinfo', 'msearch', 'suggest' ); private static $fields = array( - 'Packages.ID', 'Name', 'Version', 'CategoryID', 'Description', 'URL', - 'License', 'NumVotes', 'OutOfDateTS AS OutOfDate', + 'Packages.ID', 'Packages.Name', 'PackageBases.Name AS PackageBase', + 'Version', 'CategoryID', 'Description', 'URL', 'NumVotes', + 'OutOfDateTS AS OutOfDate', 'Users.UserName AS Maintainer', 'SubmittedTS AS FirstSubmitted', 'ModifiedTS AS LastModified' ); private static $numeric_fields = array( @@ -120,9 +121,10 @@ class AurJSON { private function process_query($type, $where_condition) { global $MAX_RPC_RESULTS; $fields = implode(',', self::$fields); - $query = "SELECT Users.Username as Maintainer, {$fields} " . - "FROM Packages LEFT JOIN Users " . - "ON Packages.MaintainerUID = Users.ID " . + $query = "SELECT {$fields} " . + "FROM Packages LEFT JOIN PackageBases " . + "ON PackageBases.ID = Packages.PackageBaseID " . + "LEFT JOIN Users ON PackageBases.MaintainerUID = Users.ID " . "WHERE ${where_condition}"; $result = $this->dbh->query($query); @@ -131,8 +133,8 @@ class AurJSON { $search_data = array(); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $resultcount++; - $name = $row['Name']; - $row['URLPath'] = URL_DIR . substr($name, 0, 2) . "/" . $name . "/" . $name . ".tar.gz"; + $pkgbase_name = $row['PackageBase']; + $row['URLPath'] = URL_DIR . substr($pkgbase_name, 0, 2) . "/" . $pkgbase_name . "/" . $pkgbase_name . ".tar.gz"; /* Unfortunately, mysql_fetch_assoc() returns all fields as * strings. We need to coerce numeric values into integers to @@ -204,7 +206,7 @@ class AurJSON { $keyword_string = $this->dbh->quote("%" . addcslashes($keyword_string, '%_') . "%"); - $where_condition = "(Name LIKE {$keyword_string} OR "; + $where_condition = "(Packages.Name LIKE {$keyword_string} OR "; $where_condition.= "Description LIKE {$keyword_string}) "; $where_condition.= "LIMIT {$MAX_RPC_RESULTS}"; @@ -224,7 +226,7 @@ class AurJSON { $where_condition = "Packages.ID={$pqdata}"; } else { - $where_condition = sprintf("Name=%s", $this->dbh->quote($pqdata)); + $where_condition = sprintf("Packages.Name=%s", $this->dbh->quote($pqdata)); } return $this->process_query('info', $where_condition); } @@ -255,7 +257,7 @@ class AurJSON { if ($names) { // individual names were quoted in parse_multiinfo_args() $names_value = implode(',', $args['names']); - $where_condition .= "Name IN ({$names_value}) "; + $where_condition .= "Packages.Name IN ({$names_value}) "; } $where_condition .= "LIMIT {$MAX_RPC_RESULTS}"; |