[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#949716: qa.debian.org: DDPO doesn't show packages with version 0



On Thu, Jan 23, 2020 at 11:58:14PM +0100, Adam Borowski wrote:
> Package: qa.debian.org
> Severity: normal
>
> Hi!
> If you have a package with version "0" (a valid version number) -- like
> "fonts-recommended" at the moment, DDPO won't show it.  On the other hand,
> a non-native package versioned "0-1" does show up.
>
> This suggests a type confusion bug, like something equalling string "0" to
> NULL.

Heh. From staring at the code for a little, my guess is that it is the
following snippet in wml/developer.wml's print_package_entry at fault:

> /* don't display this package if it doesn't have any version or wnpp info */
> if (empty(array_filter($version)) and empty($wnpp_info)) return "";

The documentation for array_filter[1] says:

> If no callback is supplied, all entries of array equal to FALSE (see converting to boolean) will be removed.

and if you follow the reference to the implicit boolean conversions
documentation[2], it indeed has the following:

> When converting to boolean, the following values are considered FALSE:
>   ...
>   * the empty string, and the string "0"

(because Javascript isn't the only language with "helpful" design
decisions)

So, I think you have to have *every* version in the archive as "0";
later checks in that function explicitly compare against "".

It's worth noting that there's also

> $pack_array = array_filter(explode(" ", $packages));

in the caller (print_package_entries), so if a src:0 were ever uploaded
to the archive it would feel left out of all the DDPO fun, although such
a source package name would surely be rejected...

As for the fix, you can (ab)use strlen as the callback (though of
*course* you have to pass the function name as a string...), so:

> if (empty(array_filter($version, 'strlen')) and empty($wnpp_info)) return "";

and

> $pack_array = array_filter(explode(" ", $packages), 'strlen');

I use the word "fix" loosely here though, I've only convinced myself
it's correct; it has not seen an interpreter, let alone been tested on
this input!

James

[1] https://www.php.net/manual/en/function.array-filter.php#refsect1-function.array-filter-parameters
[2] https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting


Reply to: