Commit graph

156 commits

Author SHA1 Message Date
Jakub Klinkovský
bc972089a1 Fix WHERE clause for keyword search queries with empty keywords
When the keyword parameter is empty, the AND clause has to be omitted,
otherwise we get an SQL syntax error:

... WHERE PackageBases.PackagerUID IS NOT NULL AND () ...

This got broken in commit 9e30013aa4fc6ce3a3c9f6f83a6fe789c1fc2456
Author: Kevin Morris <kevr.gtalk@gmail.com>
Date:   Sun Jul 5 18:19:06 2020 -0700

Support conjunctive keyword search in RPC interface

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:25:21 -05:00
Kevin Morris
efe99dc16f Support conjunctive keyword search in RPC interface
Newly supported API Version 6 modifies `type=search` for _by_ type
`name-desc`: it now behaves the same as `name-desc` search through the
https://aur.archlinux.org/packages/ search page.

Search for packages containing the literal keyword `blah blah` AND `haha`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg="blah blah"%20haha

Search for packages containing the literal keyword `abc 123`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg="abc 123"

The following example searches for packages that contain `blah` AND `abc`:
https://aur.archlinux.org/rpc/?v=6&type=search&arg=blah%20abc

The legacy method still searches for packages that contain `blah abc`:
https://aur.archlinux.org/rpc/?v=5&type=search&arg=blah%20abc
https://aur.archlinux.org/rpc/?v=5&type=search&arg=blah%20abc

API Version 6 is currently only considered during a `search` of `name-desc`.

Note: This change was written as a solution to
https://bugs.archlinux.org/task/49133.

PS: + Some spacing issues fixed in comments.

Signed-off-by: Kevin Morris <kevr.gtalk@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2021-02-20 11:24:30 -05:00
Morten Linderud
613364b773 pkg_search_page: Limit number of results on package search
The current package search query is quite poorly optimized and becomes a
resource hog when the offsets gets large enough. This DoSes the service.

A quick fix is to just ensure we have some limit to the number of hits
we return. The current hardcoding of 2500 is based on the following:

    * 250 hits per page max
    * 10 pages

We can maybe consider having it lower, but it seems easier to just have
this a multiple of 250 in the first iteration.

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-09-05 10:21:16 -04:00
Eli Schwartz
5ca1e271f9 Fix PHP 7.4 warnings
If a db query returned NULL instead of an array, then accessing $row[0]
now throws a warning. The undocumented behavior of evaluating to NULL
is maintained, and we want to return NULL anyway, so add a check for the
value and fall back on the default function return type.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2020-02-13 09:11:28 +01:00
Lukas Fleischer
3ec0f6bfbf Cache package requirements and sources
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-09 15:13:15 -04:00
Lukas Fleischer
734527370d Make package details cache TTL configurable
The TTL for package details can be much longer than for generic values
since they never change. Note that when an update is pushed via Git, all
packages belonging to that package base are deleted and new packages are
created.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-07 12:21:03 -04:00
Lukas Fleischer
f804ea4abb Cache package licenses, groups and relations
Cache more package details if the global caching mechanism is enabled.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-07 09:31:18 -04:00
Lukas Fleischer
1283fe4918 Cache package provider and dependency information
The package provider and dependency queries are quite CPU-intensive and
usually yield rather small result sets. Cache these values if the global
caching mechanism is enabled.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2019-10-06 16:13:38 -04:00
Florian Pritz
042f3f2622
Quote MySql 8.0 reserved keywords
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
2019-01-14 14:45:37 -05:00
Johannes Löthberg
257115943e Allow paginating package comments
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-08-06 06:03:58 +02:00
Johannes Löthberg
3578e77ad4 Allow listing all comments from a user
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-08-06 06:03:58 +02:00
Florian Pritz
f51d4c32cd Remove disjunction in pkg_providers query
For some reason, running the SELECT .. WHERE .. OR .. query takes e.g.
58ms on a randomly generated db for some dependency name. Splitting the
OR into two dedicated queries and UNIONing the result takes only 0.42ms.

On the Arch Linux installation, searching for the providers of e.g.
mongodb takes >=110ms when not cached by the query cache. The new query
takes <1ms even when not cached.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2018-02-24 14:57:31 +01:00
Eli Schwartz
ac29097ce8 Fix regression that stopped maintainers from pinning comments
In commit 8c98db0b82 support was added for
package co-maintainers to pin comments in addition to maintainers.

Due to a typo, the SQL query was reset halfway through and only added
the co-maintainer IDs to the list of allowed users.

Fixes FS#56783.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-12-23 22:51:39 +01:00
Lukas Fleischer
8c98db0b82 Allow package co-maintainers to pin comments
Implements FS#56255.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-11-06 17:03:37 +01:00
Lukas Fleischer
44858e0618 Store dependency descriptions in a separate column
Split optional dependency descriptions from dependency names before
storing them in the database and use a separate column to store the
descriptions.

This allows us to simplify and optimize the SQL queries in
pkg_dependencies() as well as pkg_required().

Suggested-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-04-19 09:13:09 +02:00
Janne Heß
9df1bd5fe2 Add direct links to each source file
Currently, each source file which is an external link (http://,
https://, ...) is a clickable link.

This commit extends the behaviour by making files from the repository
clickable as well. The link brings the user to the corresponding cgit
page.

Also, the link to the PKGBUILD is altered to make the configuration more
consistent.

Signed-off-by: Janne Heß <jannehess@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-12 17:53:13 +01:00
Lukas Fleischer
880d25e98c Allow to search for both maintainer and co-maintainer
As a follow-up to commit 6cb8c04 (Implement co-maintainer search,
2017-01-26), add an option to search for both maintainers and
co-maintainers at the same time.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-08 19:18:27 +01:00
Lukas Fleischer
555cdac2db Return the number of results in pkg_search_page()
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-08 19:18:26 +01:00
Lukas Fleischer
3b4c6e72a9 Refactor pkg_search_page()
* Pass search parameters using an associative array instead of $_GET.
* Add a boolean parameter to enable and disable headers/footers.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-04 00:36:17 +01:00
Lukas Fleischer
ac745f656d Split out the search form from pkg_search_page()
This makes it easier to display search results without showing the
search form.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-02-03 23:54:31 +01:00
Lukas Fleischer
6cb8c041bc Implement co-maintainer search
Add an option to filter package search results by co-maintainer.

Partly fixes FS#45591.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2017-01-28 11:23:40 +01:00
Lukas Fleischer
fbf3e54057 Add hard limit for the length of dependency lists
Introduce a configuration option max_depends which can be used to
specify a maximum number of (reverse) dependencies to display on the
package details pages.

Fixes FS#49059.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-06-26 08:53:55 +02:00
Mark Weiman
c23914fc1d Unset $pinned unconditionally when displaying comments
In pkg_comments.php, the $pinned variable is used to determine whether
the template is supposed to print all comments or pinned comments only.
If the $pinned variable is unset, the top 10 comments are printed,
followed by an "All comments" link. If the $pinned variable is set, the
pinned comments are printed and the "All comments" link below the
comment listing is skipped. Thus, we need to make sure that this
variable is always unset at the time we include the template to display
all comments, even if it was empty before.

Fixes FS#48194.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-02-19 18:18:48 +01:00
Lukas Fleischer
3412de21d3 Rename the CommentNotify table to PackageNotifications
As a preparatory step to adding support for package notifications on
events other than comments, rename the database table accordingly.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2016-02-07 10:39:22 +01:00
Mark Weiman
7d4c0c9ffa Implement capability to pin comments above others
Adds capability to pin comments before others.

Implements FS#10863.

Signed-off-by: Mark Weiman <mark.weiman@markzz.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-12-12 15:09:47 +01:00
Lukas Fleischer
66d12f0c37 Highlight broken dependencies
If a dependency neither exists in the official repositories nor in the
AUR, make it appear bold red.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-10-24 18:59:04 +02:00
Lukas Fleischer
8dcf225f63 Hide optdepend description if not available
Remove the "(unknown)" suffix that used to be shown for optional
dependencies without a description.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-10-24 18:50:44 +02:00
Lukas Fleischer
b30135111a Include trivial AUR providers in pkg_providers()
When obtaining provisions using pkg_providers(), we already include
virtual providers from the official repositories, virtual providers from
the AUR and trivial providers (i.e. packages having the given name) from
the official repositories. Include trivial providers from the AUR as
well.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-10-24 18:33:00 +02:00
Lukas Fleischer
5d119c02ea Always retrieve dependency providers
Since commit 16765d5 (Track providers in the official repositories,
2015-10-21), we know all packages and virtual provisions from the
official repositories. Always obtain and display all providers from both
the official repositories and the AUR.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-10-24 18:22:25 +02:00
Lukas Fleischer
b74a87abfc Fix spacing of versioned dependencies
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-10-24 18:13:48 +02:00
Lukas Fleischer
16765d5532 Track providers in the official repositories
Maintain a list of virtual provisions of packages from the official
binary package repositories. The list can be updated using the aurblup
script, e.g. via a cronjob.

This allows for adding proper links to package dependencies: If an AUR
package depends on a package from the official repositories (or on a
name provided by a package from the official repositories), add a link
to the corresponding archweb package details page. If an AUR package
depends on another AUR package (or on a name provided by another AUR
package), add a link to the corresponding aurweb package details page.
Otherwise, just display the name and do not add a link at all.

Fixes FS#46549.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-10-21 22:05:42 +02:00
Lukas Fleischer
938b1058eb pkgfuncs.inc.php: Squelch PHP warning
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-09-25 08:35:44 +02:00
Marcel Korpel
4516f07d9c Add search for keywords only
Implements FS#45619.

Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-09-23 21:45:47 +02:00
Lukas Fleischer
f3ec4d1ef5 Rename "Age" search order to "Last modified"
Use a better description for sorting by modification time, as it is not
clear whether "Age" refers to the package creation date or to the
modification date.

The possibility to sort by "Age" is kept internally (but hidden from the
user interface) such that old links to search results still work.

Fixes FS#46319.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-09-20 11:09:47 +02:00
Lukas Fleischer
9cae17ff7c 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>
2015-09-18 08:03:56 +02:00
Lukas Fleischer
0dd27a86b1 Remove legacy code
In 74edb6f (Use Git repositories to store packages, 2014-06-06), package
creation was moved to the Python backend. Remove several PHP functions
that are no longer needed.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-09-18 07:55:50 +02:00
Lukas Fleischer
9d2d8f1c8c Honor virtual provisions in package requirements
Implements FS#14125.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-09-17 23:04:58 +02:00
Lukas Fleischer
dd808ac802 Use a separate function for "Required by" links
Do not use the same function for generating dependency and inverse
dependency links. Instead, factor out common code and create two
separate functions for those (rather different) functionalities.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-09-17 19:06:18 +02:00
Lukas Fleischer
f9476c1093 Show providers in dependencies
For all "virtual provisions" in package dependencies, show links to the
actual packages providing the dependency.

This partly implements FS#14125.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-09-16 22:00:04 +02:00
Lukas Fleischer
57db4814a4 Allow users to unflag packages they flagged themselves
Sometimes, a user accidentally flags a package out-of-date. Allow users
to unflag packages that they flagged themselves, thereby providing a way
to undo these actions.

Implements FS#46145.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-30 16:51:14 +02:00
Marcel Korpel
c7025054c6 Split pkg_comment_form.php so the outer box is not always included
For use in the new RPC interface to edit comments, the form shouldn't
always print a header. Create a new template pkg_comment_box.php that
prints form and box, change template pkg_comment_form.php to only
print the form.

Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:24 +02:00
Lukas Fleischer
e610360c95 Show popularity in package base details
Fixes FS#45600.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:24 +02:00
Marcel Korpel
e331ce273c Support comment editing in the backend
Create two new actions, do_AddComment and do_EditComment. When editing
or deleting a comment, a timestamp is added.

Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:24 +02:00
Marcel Korpel
92e19e95f3 Add comment edit icon and form
Show an icon next to the comment deletion icon, which leads to a
comment edit form.

Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-08-08 12:59:23 +02:00
Lukas Fleischer
d1c331613d Display (reverse) optional dependencies as "Required by"
Also, change pkg_required() such that the returned array has the same
structure as the result of pkg_dependencies().

Fixes FS#45452.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-27 13:04:03 +02:00
Lukas Fleischer
2d7b68ac4c Remove can_submit_blacklisted()
This function is unneeded since commit 74edb6f (Use Git repositories to
store packages, 2014-06-06).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-19 16:52:07 +02:00
Lukas Fleischer
5fb7a74e23 Replace categories with keywords
Remove package base categories. Instead, users can now specify up to
twenty custom keywords that are taken into consideration when searching.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-14 17:58:55 +02:00
Lukas Fleischer
15ee85b456 Show package popularity in search results
Display the popularity score (weighted votes) in the package search
results.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-11 19:15:44 +02:00
Lukas Fleischer
08cdc5ca64 Invert order when sorting packages by age
Fixes FS#44195.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-09 09:22:46 +02:00
Lukas Fleischer
5c64ae1a0e Drop suffixes from confirm parameters
Remove the _delete and _disown suffixes from HTTP POST confirmation
parameters.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-09 09:05:05 +02:00