[aur-dev] [PATCH 2/2] Add search for keywords only

Lukas Fleischer lfleischer at archlinux.org
Sat Sep 19 13:26:09 UTC 2015


On Fri, 18 Sep 2015 at 23:12:14, Marcel Korpel wrote:
> Implements FS#45619.
> 
> Signed-off-by: Marcel Korpel <marcel.korpel at gmail.com>
> ---
>  web/lib/pkgfuncs.inc.php         | 7 +++++++
>  web/template/pkg_search_form.php | 1 +
>  2 files changed, 8 insertions(+)
> 

Thanks for implementing this! One comment below.

> diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
> index d760429..da2c3da 100644
> --- a/web/lib/pkgfuncs.inc.php
> +++ b/web/lib/pkgfuncs.inc.php
> @@ -608,6 +608,13 @@ function pkg_search_page($SID="") {
>                         $K = "%" . addcslashes($_GET['K'], '%_') . "%";
>                         $q_where .= "AND (PackageBases.Name LIKE " . $dbh->quote($K) . ") ";
>                 }
> +               elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "k") {
> +                       /* Search by keywords. */
> +                       $K = "%" . addcslashes($_GET['K'], '%_') . "%";
> +                       $q_where .= "AND EXISTS (SELECT * FROM PackageKeywords WHERE ";
> +                       $q_where .= "PackageKeywords.PackageBaseID = Packages.PackageBaseID ";
> +                       $q_where .= "AND PackageKeywords.Keyword LIKE " . $dbh->quote($K) . ") ";
> +               }
>                 elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "N") {
>                         /* Search by name (exact match). */
>                         $q_where .= "AND (Packages.Name = " . $dbh->quote($_GET['K']) . ") ";
> [...]

I wonder whether, instead of doing this, we should enable the keyword
search mode when searching by keywords only, i.e. use the default search
and drop the Packages.Name and Description conditions...

Regards,
Lukas


More information about the aur-dev mailing list