"Popular Packages"

[email protected] (Alexey Borzov) Sat, 29 Oct 2011 14:23:20 +0400
Newsgroups php.pear.dev,php.pear.webmaster
Message-ID <[email protected]>
Hi,

Can someone with access to a PEAR website database check what is wrong with 
"Popular Packages" list?

Specifically, I'm seeing Net_URL2 2.0.0 released 2011-10-20 here with 495 
downloads a day, but I'm not seeing HTTP_Request2 2.0.0 released 2011-10-20 with 
~336 downloads a day.

I've looked up a query in pearweb and it looks legit:
SELECT
packages.name, releases.version, downloads, releasedate,
downloads/(CEIL((unix_timestamp(NOW()) - 
unix_timestamp(releases.releasedate))/86400)) as releasenotes
FROM releases, packages, aggregated_package_stats a
WHERE
packages.name <> "pearweb" AND
packages.name <> "pearweb_phars" AND
packages.id = releases.package AND
packages.package_type = ? AND
a.release_id = releases.id AND
a.package_id = packages.id AND
packages.newpk_id IS NULL AND
packages.unmaintained = 0 AND
a.yearmonth = "' . date('Y-m-01 00:00:00', time()) . '"
ORDER BY releasenotes DESC';

However, knowing MySQL's creative approach to data integrity, the part about 
"packages.newpk_id IS NULL" may be a problem. This newpk_id is changed in 
package-edit.php and stored the following way into the DB:

         $qparams = array(
...
             isset($_POST['newpk_id']) ? $_POST['newpk_id'] : null,
...
         );

I suspect that $_POST['newpk_id'] is always isset(), so an empty string is sent 
to a database and creatively converted to something like zero by MySQL. I also 
suspect that quite a number of packages may be affected.

Also WTF is File_Mogile? Does it really have 100K downloads a month or is this 
creative approach to foreign key constraints?
http://pear.php.net/package-stats.php?pid=843&cid=9