cvs: pearweb /include pear-database.php

From: Date: Sat, 21 Apr 2007 22:14:52 +0000
Subject: cvs: pearweb /include pear-database.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-46081@lists.php.net to get a copy of this message
dufuz Sat Apr 21 22:14:52 2007 UTC Modified files: /pearweb/include pear-database.php Log: Just general cosmetics http://cvs.php.net/viewvc.cgi/pearweb/include/pear-database.php?r1=1.341&r2=1.342&diff_format=u Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.341 pearweb/include/pear-database.php:1.342 --- pearweb/include/pear-database.php:1.341 Tue Apr 17 22:12:12 2007 +++ pearweb/include/pear-database.php Sat Apr 21 22:14:52 2007 @@ -18,7 +18,7 @@ | Martin Jansen <mj@php.net> | | Gregory Beaver <cellog@php.net> | +----------------------------------------------------------------------+ - $Id: pear-database.php,v 1.341 2007/04/17 22:12:12 cellog Exp $ + $Id: pear-database.php,v 1.342 2007/04/21 22:14:52 dufuz Exp $ */ require_once 'DB/storage.php'; @@ -500,11 +500,8 @@ function getPackageFile($package, $version) { global $dbh; - if (is_numeric($package)) { - $what = "id"; - } else { - $what = "name"; - } + $what = is_numeric($package) ? 'id' : 'name'; + $relids = $dbh->getRow('SELECT releases.id as rid, packages.id as pid' . ' FROM releases, packages WHERE ' . "packages.$what = ? AND releases.version = ? AND " . @@ -680,12 +677,7 @@ static function info($pkg, $field = null, $allow_pecl = false) { global $dbh; - - if (is_numeric($pkg)) { - $what = "id"; - } else { - $what = "name"; - } + $what = is_numeric($pkg) ? 'id' : 'name'; if ($allow_pecl) { $package_type = "((p.package_type = 'pear' AND p.approved = 1) OR p.package_type = 'pecl') AND "; @@ -922,9 +914,9 @@ } } $var = !$stable_only ? 'allreleases' : 'stablereleases'; - foreach(array_keys($packageinfo) as $pkg) { + foreach (array_keys($packageinfo) as $pkg) { $_deps = array(); - foreach($deps as $dep) { + foreach ($deps as $dep) { if ($dep['package'] == $packageinfo[$pkg]['packageid'] && isset($$var[$pkg]) && $dep['release'] == $$var[$pkg]['rid']) @@ -1787,21 +1779,17 @@ if (!$pkg_info) { require_once 'Archive/Tar.php'; $tar = &new Archive_Tar($file); + $oldpackagexml = $tar->extractInString('package.xml'); - if ($packagexml = $tar->extractInString('package2.xml')) { - // success - } else { - if ($oldpackagexml) { - $packagexml = $oldpackagexml; - } else { + if (null === $packagexml = $tar->extractInString('package2.xml')) { + if ($oldpackagexml === null) { return PEAR::raiseError('Archive uploaded does not appear to contain a package.xml!'); } + + $packagexml = $oldpackagexml; } - if ($oldpackagexml != $packagexml) { - $compatible = true; - } else { - $compatible = false; - } + + $compatible = $oldpackagexml != $packagexml ? true : false; } // Update releases table $query = "INSERT INTO releases (id,package,version,state,doneby,". @@ -1902,11 +1890,8 @@ if ($dep['optional'] != strtolower($dep['optional'])) { $prob[] = 'optional'; } - if ($dep['optional'] == 'yes') { - $optional = 1; - } else { - $optional = 0; - } + + $optional = $dep['optional'] == 'yes' ? 1 : 0; } if (count($prob)) { @@ -1950,13 +1935,14 @@ } // Update Cache - include_once 'xmlrpc-cache.php'; - $cache = new XMLRPC_Cache; $GLOBALS['pear_rest']->saveAllReleasesREST($package); $GLOBALS['pear_rest']->saveReleaseREST($file, $packagexml, $pkg_info, $auth_user->handle, $release_id); $GLOBALS['pear_rest']->savePackagesCategoryREST(package::info($package, 'category')); + // gotta clear all the permutations + include_once 'xmlrpc-cache.php'; + $cache = new XMLRPC_Cache; $cache->remove('package.listAll', array(false)); $cache->remove('package.listAll', array(true)); @@ -2176,30 +2162,30 @@ yearmonth="' . date('Y-m-01') . '"', array($package, $release_id)); if ($dbh->affectedRows() == 0) { - $dbh->query('INSERT INTO aggregated_package_stats - (package_id, release_id, yearmonth, downloads) - VALUES(?,?,?,1)', - array($package, $release_id, date('Y-m-01'))); + $dbh->query('INSERT INTO aggregated_package_stats + (package_id, release_id, yearmonth, downloads) + VALUES(?,?,?,1)', + array($package, $release_id, date('Y-m-01'))); } // This method can be used when we have MySQL 4.1, // 30% efficiency gain at least over previous method -// $dbh->query('INSERT INTO aggregated_package_stats -// (package_id, release_id, yearmonth, downloads) -// VALUES(?,?,?,1) -// ON DUPLICATE KEY UPDATE downloads=downloads+1', -// array($package, $release_id, date('Y-m-01'))); +// $dbh->query('INSERT INTO aggregated_package_stats +// (package_id, release_id, yearmonth, downloads) +// VALUES(?,?,?,1) +// ON DUPLICATE KEY UPDATE downloads=downloads+1', +// array($package, $release_id, date('Y-m-01'))); // {{{ Update package_stats table // This method can be used when we have MySQL 4.1, // 30% efficiency gain at least over previous method // $query = 'INSERT INTO package_stats -// (dl_number, package, release, pid, rid, cid, last_dl) -// VALUES (1, ?, ?, ?, ?, ?, ?) -// ON DUPLICATE KEY UPDATE -// dl_number=dl_number+1, -// last_dl = "' . date('Y-m-d H:i:s') . '"'; +// (dl_number, package, release, pid, rid, cid, last_dl) +// VALUES (1, ?, ?, ?, ?, ?, ?) +// ON DUPLICATE KEY UPDATE +// dl_number=dl_number+1, +// last_dl = "' . date('Y-m-d H:i:s') . '"'; // // $dbh->query($query, array($pkg_info['name'], // $version, @@ -2420,9 +2406,9 @@ if (PEAR::isError($sth)) { return false; - } else { - return true; } + + return true; } // }}} @@ -2897,14 +2883,14 @@ function update($data) { global $dbh; - $fields = array('name', - 'email', - 'homepage', - 'showemail', - 'userinfo', - 'pgpkeyid', - 'wishlist', - 'latitude', + $fields = array('name', + 'email', + 'homepage', + 'showemail', + 'userinfo', + 'pgpkeyid', + 'wishlist', + 'latitude', 'longitude', );

« previous php.pear.cvs (#46081) next »