Re: [PATCH 1/1] This patch implements FS#54906. Ability to query by pkgver via RPC or web request (url)

2018-06-10 Thread Nodiv Byzero
Hey Lukas.

This patch implements additional check for package version. Of course,
all clients can search by the name and then compare the version
itself. But... this small improvement can help clients a lot. Here[1]
is the good example.

[1] https://github.com/falconindy/auracle/issues/3

On Sat, Jun 9, 2018 at 10:42 AM, Lukas Fleischer
 wrote:
> On Fri, 08 Jun 2018 at 00:09:22, nodivbyzero wrote:
>> ---
>>  web/lib/aurjson.class.php | 5 +
>>  web/lib/pkgfuncs.inc.php  | 4 
>>  2 files changed, 9 insertions(+)
>>
>
> I don't quite understand what this is trying to fix. Can't the client
> simply obtain the package without the package version and then compare
> the versions itself? Please elaborate.
>
>> diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
>> index c51e9c2..30ce63f 100644
>> --- a/web/lib/aurjson.class.php
>> +++ b/web/lib/aurjson.class.php
>> @@ -486,6 +486,11 @@ class AurJSON {
>>
>> if ($search_by === 'name') {
>> $where_condition = "(Packages.Name LIKE 
>> $keyword_string)";
>> +   if (isset($http_data['pkgver'])) {
>> +   $pkgver = $http_data['pkgver'];
>> +   $pkgver_string = 
>> $this->dbh->quote($pkgver . "%");
>
> Not sure how useful that would be. If we agree that this is something to
> be implemented, I would expect to have proper support for version
> comparisons as supported by pacman. When would be need to search by
> matching prefixes?
>
> Best regards.
> Lukas


Re: [PATCH 1/1] Highlighting row on hover in the search results. FS#53612

2018-06-10 Thread Nodiv Byzero
Thank you for this info.
I'll submit my patch to archweb first.

On Sat, Jun 9, 2018 at 10:30 AM, Lukas Fleischer
 wrote:
> On Fri, 08 Jun 2018 at 23:04:20, nodivbyzero wrote:
>> ---
>>  web/html/css/archweb.css | 12 ++--
>>  1 file changed, 10 insertions(+), 2 deletions(-)
>> [...]
>
> We keep this in sync with the actual archweb CSS. So instead of doing
> this, we should copy and commit the most recent version from archweb.


Re: Populate DB from aur-schema.sql

2018-05-01 Thread Nodiv Byzero
Thank you Lukas.

Should this information be added into INSTALL file?

On Mon, Apr 30, 2018 at 11:26 PM, Lukas Fleischer
<lfleisc...@archlinux.org> wrote:
> On Wed, 25 Apr 2018 at 06:07:46, Nodiv Byzero wrote:
>> When I try to populate DB from aur-schema.sql using mysql command line
>> I see following error:
>> ERROR 1071 (42000) at line 20: Specified key was too long; max key
>> length is 767 bytes
>>
>>
>> Have you seen this one when installed aur-web?
>
> I think we saw it before. One way to fix it is to set
> innodb_large_prefix=1 and use the DYNAMIC row format.
>
> Regards,
> Lukas


Populate DB from aur-schema.sql

2018-04-24 Thread Nodiv Byzero
Hello,

When I try to populate DB from aur-schema.sql using mysql command line
I see following error:
ERROR 1071 (42000) at line 20: Specified key was too long; max key
length is 767 bytes


Have you seen this one when installed aur-web?
Is it because I use Maria DB version 10.1.30?

Thanks,
Nodiv


Re: [aur-dev][PATCH] config: allow reading both the proto file and the modified config

2018-04-16 Thread Nodiv Byzero
I think you're right.
I looked one more time and found guard there:
   if (!isset($AUR_CONFIG))

Thanks for clarification.

Nodiv.

On Mon, Apr 16, 2018 at 1:41 AM, Eli Schwartz <eschwa...@archlinux.org> wrote:
> On 04/12/2018 02:22 PM, Nodiv Byzero wrote:
>> The point is that there are few places where config_load() gets called
>> in the sequential order (the same request) and every time it loads and
>> parses data.
>
> Are these also places where if (!isset($AUR_CONFIG)) fails to actually
> fulfill its sole reason to exist?
>
> Not that it matters... if for some reason we are loading the config very
> fast and scribbling over each other, because $AUR_CONFIG is not yet set
> when we begin the second config_load() execution, checking if $config is
> already loaded won't help -- it's a local variable.
>
> So, question: can you show me code where $config would *not* be `false`?
>
> Because I think this proposition would be either a no-op or a reason to
> file a severely major upstream php bug complaining that the variables
> are leaking all over the floor.
>
> ...
>
> That being said, yes, there is a race condition where you call
> config_load() twice, and they both set $AUR_CONFIG.
>
> Elevating $config and $default_config to globals, *then* using them as
> additional file access caches to micro-optimize one or two disk ops,
> seems wasteful to me. It's not like this is being run in a tight loop.
>
> If any effort should be spent to fix this, rather than introducing
> painful, non-obvious code, we should introduce some sort of proper cache.
>
> --
> Eli Schwartz
> Bug Wrangler and Trusted User
>


Re: [aur-dev][PATCH] config: allow reading both the proto file and the modified config

2018-04-12 Thread Nodiv Byzero
The point is that there are few places where config_load() gets called
in the sequential order (the same request) and every time it loads and
parses data.

On Thu, Apr 12, 2018 at 11:05 AM, Eli Schwartz <eschwa...@archlinux.org> wrote:
> On 04/12/2018 01:51 PM, Nodiv Byzero wrote:
>> What do you think about adding one more line to check if $config is already 
>> set?
>> Something like:
>>  if (!isset($config)) {
>>   ... do the parse_ini_file
>>  }
>>
>> Just to reduce disk operations.
>
> What is the point? We only check if $AUR_CONFIG isset() because it is
> explicitly global, and the function is here to set it if needed or else
> do nothing.
>
> $config is locally scoped, and its only purpose is exactly where it is
> being used. It should be utterly impossible for it to be set beforehand.
>
> ...
>
> On an unrelated note, Bluewind suggested renaming the config.proto to
> config.defaults, so if Lukas agrees with this patch I will send in an
> amended version.
>
> --
> Eli Schwartz
> Bug Wrangler and Trusted User
>


Re: [aur-dev][PATCH] config: allow reading both the proto file and the modified config

2018-04-12 Thread Nodiv Byzero
What do you think about adding one more line to check if $config is already set?
Something like:
 if (!isset($config)) {
  ... do the parse_ini_file
 }

Just to reduce disk operations.






On Thu, Apr 12, 2018 at 10:44 AM, Eli Schwartz  wrote:
> This change allows aurweb configuration to be done via either:
> - copying config.proto to config and modifying values
> - creating a new config only containing modified values, next to a
>   config.proto containing unmodified values
>
> The motivation for this change is to enable ansible configuration by
> storing only changed values, and deferring to config.proto otherwise.
>
> If a config.proto file does not exist next to /etc/aurweb/config or
> $AUR_CONFIG, it is ignored and *all* values are expected to live in the
> modified config file.
>
> Signed-off-by: Eli Schwartz 
> ---
>  aurweb/config.py   | 4 
>  web/lib/confparser.inc.php | 8 +++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/aurweb/config.py b/aurweb/config.py
> index a52d942..c333c43 100644
> --- a/aurweb/config.py
> +++ b/aurweb/config.py
> @@ -13,6 +13,10 @@ def _get_parser():
>  path = os.environ.get('AUR_CONFIG')
>  else:
>  path = "/etc/aurweb/config"
> +
> +if os.path.isfile(path + '.proto'):
> +with open(path + '.proto') as f:
> +_parser.read_file(f)
>  _parser.read(path)
>
>  return _parser
> diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php
> index 499481d..2ed0108 100644
> --- a/web/lib/confparser.inc.php
> +++ b/web/lib/confparser.inc.php
> @@ -8,11 +8,17 @@ function config_load() {
> if (!$path) {
> $path = "/etc/aurweb/config";
> }
> +   if (file_exists($path . ".proto")) {
> +   $defaults = parse_ini_file($path . ".proto", true, 
> INI_SCANNER_RAW);
> +   } else {
> +   $defaults = [];
> +   }
> if (file_exists($path)) {
> -   $AUR_CONFIG = parse_ini_file($path, true, 
> INI_SCANNER_RAW);
> +   $config = parse_ini_file($path, true, 
> INI_SCANNER_RAW);
> } else {
> die("aurweb config file not found");
> }
> +   $AUR_CONFIG = array_replace_recursive($defaults, $config)
> }
>  }
>
> --
> 2.17.0


Re: [PATCH] Handle empty resultset getting recent 10 packages

2018-03-20 Thread Nodiv Byzero
Replaced spaces w/ tabs in this version

On Tue, Mar 20, 2018 at 8:47 PM, nodivbyzero  wrote:
> ---
>  web/lib/stats.inc.php | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php
> index 80619fe..f5692f9 100644
> --- a/web/lib/stats.inc.php
> +++ b/web/lib/stats.inc.php
> @@ -19,10 +19,12 @@ function updates_table() {
> $result = $dbh->query($q);
>
> $newest_packages = new ArrayObject();
> -   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> -   $newest_packages->append($row);
> +   if ($result) {
> +   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> +   $newest_packages->append($row);
> +   }
> +   set_cache_value($key, $newest_packages);
> }
> -   set_cache_value($key, $newest_packages);
> }
> include('stats/updates_table.php');
>  }
> --
> 2.16.1
>


Re: [PATCH] Handle empty resultset getting recent 10 packages

2018-03-20 Thread Nodiv Byzero
It renders incorrectly main page(Statistics) with empty database.

On Tue, Mar 20, 2018 at 8:33 PM, nodivbyzero  wrote:
> ---
>  web/lib/stats.inc.php | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/web/lib/stats.inc.php b/web/lib/stats.inc.php
> index 80619fe..0fa3ec6 100644
> --- a/web/lib/stats.inc.php
> +++ b/web/lib/stats.inc.php
> @@ -19,10 +19,13 @@ function updates_table() {
> $result = $dbh->query($q);
>
> $newest_packages = new ArrayObject();
> -   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> -   $newest_packages->append($row);
> -   }
> -   set_cache_value($key, $newest_packages);
> +if ($result) {
> +
> +   while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
> +   $newest_packages->append($row);
> +   }
> +   set_cache_value($key, $newest_packages);
> +}
> }
> include('stats/updates_table.php');
>  }
> --
> 2.16.1
>


Re: [PATCH] Terminates execution of the script if aurweb config file not found

2018-03-16 Thread Nodiv Byzero
I spent 5 minutes to figure out why fresh aurweb install did not work
for me. Because I missed aurweb/config file.
I've added termination just in case there is not file.

On Fri, Mar 16, 2018 at 8:17 PM, nodivbyzero  wrote:
> ---
>  web/lib/confparser.inc.php | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/web/lib/confparser.inc.php b/web/lib/confparser.inc.php
> index e7128be..499481d 100644
> --- a/web/lib/confparser.inc.php
> +++ b/web/lib/confparser.inc.php
> @@ -8,7 +8,11 @@ function config_load() {
> if (!$path) {
> $path = "/etc/aurweb/config";
> }
> -   $AUR_CONFIG = parse_ini_file($path, true, INI_SCANNER_RAW);
> +   if (file_exists($path)) {
> +   $AUR_CONFIG = parse_ini_file($path, true, 
> INI_SCANNER_RAW);
> +   } else {
> +   die("aurweb config file not found");
> +   }
> }
>  }
>
> --
> 2.16.1
>


Re: [PATCH 1/1] TESTING: Adding 2 required packages in the documentation file. Replacing MySQL with SQLite in the comment

2018-03-10 Thread Nodiv Byzero
Thank you Lukas for review.
I'll fix spaces issue and re-submit in two new commits.

Cheers,
Nodiv

On Sat, Mar 10, 2018 at 7:55 AM, Lukas Fleischer
<lfleisc...@archlinux.org> wrote:
> Dear Nodiv,
>
> On Tue, 06 Mar 2018 at 03:38:08, Nodiv Byzero wrote:
>> ---
>>  TESTING | 2 +-
>>  schema/Makefile | 1 +
>>  2 files changed, 2 insertions(+), 1 deletion(-)
>> [...]
>
> Thank you for working on this! Something must have gone wrong when you
> submitted the patch, though. It looks like tabs were replaced by spaces
> and thus, the patch cannot be applied as-is. I recommend using
> git-send-email(1).
>
> I would also prefer to have two separate commits (with separate commit
> messages) for the two issues that are fixed.
>
> Thanks!
>
> Regards,
> Lukas


[PATCH 1/1] TESTING: Adding 2 required packages in the documentation file. Replacing MySQL with SQLite in the comment

2018-03-05 Thread Nodiv Byzero
---
 TESTING | 2 +-
 schema/Makefile | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/TESTING b/TESTING
index d2c97d9..9613314 100644
--- a/TESTING
+++ b/TESTING
@@ -11,7 +11,7 @@ INSTALL.

 2) Install php and necessary modules:

-# pacman -S php php-sqlite sqlite
+# pacman -S php php-sqlite sqlite words fortune-mod

 3) Prepare the testing database:

diff --git a/schema/Makefile b/schema/Makefile
index e0448ad..62d0856 100644
--- a/schema/Makefile
+++ b/schema/Makefile
@@ -3,6 +3,7 @@ aur-schema-sqlite.sql: aur-schema.sql
  -e 's/ ENGINE = InnoDB//' \
  -e 's/ [A-Z]* UNSIGNED NOT NULL AUTO_INCREMENT/ INTEGER NOT NULL/' \
  -e 's/([0-9, ]*) UNSIGNED / UNSIGNED /' \
+ -e 's/ MySQL / SQLite /' \
  $< >$@

 clean:
-- 
2.16.1


Re: [aur-dev] [PATCH 1/1] Fix for issue FS#49134 - AUR site search includes packages' keywords when searching by name and description

2017-01-09 Thread Nodiv Byzero via aur-dev
I was wrong, You're right !


Re: [aur-dev] [PATCH 1/1] Fix for issue FS#49134 - AUR site search includes packages' keywords when searching by name and description

2017-01-08 Thread Nodiv Byzero via aur-dev
There is a search by 'package name & description' according to the
function comment.
File: pkgfuncs.inc.php
/* ...
SeB- property that search string (K) represents
  values: n  - package name
  nd - package name & description
  b  - package base name
  N  - package name (exact match)
  B  - package base name (exact match)
  k  - package keyword(s)
  m  - package maintainer's username
  s  - package submitter's username
...
*/
Correct me if I'm wrong, but this patch does not break search
functionality using web-form. The patch would work only if user
manually specifies 'nd' in url. Default search uses name and keywords.

So, it looks good to me :)


[aur-dev] What cgit version does AUR use?

2017-01-03 Thread Nodiv Byzero via aur-dev
Hello,

I'm looking into FS#51968 - 'Atom feed of package repo have
non-escaped href' issue.
https://bugs.archlinux.org/task/51968?project=2

It looks like it's cgit issue.

So, can somebody confirm current running cgit version?

Thanks.


[aur-dev] [PATCH 1/1] Fix for issue FS#49134 - AUR site search includes packages' keywords when searching by name and description

2016-12-23 Thread Nodiv Byzero via aur-dev
---
 web/lib/pkgfuncs.inc.php |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 4b0fdba..f61e52c 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -755,6 +755,11 @@ function pkg_search_page($SID="") {
$K = "%" . addcslashes($_GET['K'], '%_') . "%";
$q_where .= "AND (Packages.Name LIKE " . 
$dbh->quote($K) . ") ";
}
+   elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "nd") {
+   /* Search by name. */
+   $K = "%" . addcslashes($_GET['K'], '%_') . "%";
+   $q_where .= "AND (Packages.Name LIKE " . 
$dbh->quote($K) . " OR Packages.Description LIKE " . $dbh->quote($K) . ") ";
+   }
elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "b") {
/* Search by package base name. */
$K = "%" . addcslashes($_GET['K'], '%_') . "%";
-- 
1.7.3.4