diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2015-09-18 08:02:33 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2015-09-18 08:03:56 +0200 |
commit | 9cae17ff7c4eeb7af66e06ba38de3b64d08dec2f (patch) | |
tree | 20bcb5a4aecc915bca4d9ace0c69671a9daddcd3 /web/html/packages.php | |
parent | 0dd27a86b1bceaa01d406e4b85139acbd8c885ab (diff) | |
download | aurweb-9cae17ff7c4eeb7af66e06ba38de3b64d08dec2f.tar.xz |
Extract package name from details
When requesting package details, instead of performing another SQL query
to obtain the package name, extract the name from the result of the
package details query.
Also, drop pkg_name_from_id() which is no longer needed after this
optimization.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/html/packages.php')
-rw-r--r-- | web/html/packages.php | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/web/html/packages.php b/web/html/packages.php index bf3daf8..38a2e29 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -11,19 +11,25 @@ check_sid(); # see if they're still logged in if (!isset($pkgid) || !isset($pkgname)) { if (isset($_GET['ID'])) { $pkgid = intval($_GET['ID']); - $pkgname = pkg_name_from_id($_GET['ID']); } else if (isset($_GET['N'])) { $pkgid = pkg_from_name($_GET['N']); - $pkgname = $_GET['N']; } else { - unset($pkgid, $pkgname); + unset($pkgid); } +} - if (isset($pkgid) && ($pkgid == 0 || $pkgid == NULL || $pkgname == NULL)) { - header("HTTP/1.0 404 Not Found"); - include "./404.php"; - return; - } +$details = array(); +if (isset($pkgid)) { + $details = pkg_get_details($pkgid); + $pkgname = $details['Name']; +} else { + unset($pkgname); +} + +if (isset($pkgid) && ($pkgid == 0 || $pkgid == NULL || $pkgname == NULL)) { + header("HTTP/1.0 404 Not Found"); + include "./404.php"; + return; } # Set the title to the current query or package name @@ -35,11 +41,6 @@ if (isset($pkgname)) { $title = __("Packages"); } -$details = array(); -if (isset($pkgname)) { - $details = pkg_get_details($pkgid); -} - html_header($title, $details); ?> |