cvs: pearweb /include pear-database.php /public_html release-upload.php

From: Date: Tue, 01 Mar 2005 18:14:02 +0000
Subject: cvs: pearweb /include pear-database.php /public_html release-upload.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-29963@lists.php.net to get a copy of this message
cellog Tue Mar 1 13:14:02 2005 EDT Modified files: /pearweb/public_html release-upload.php /pearweb/include pear-database.php Log: force integer comparison, which may fix things although I can't reproduce the problem. Also, make pecl releases work through pear.php.net. This pecl patch will be reverted when 1.4.0 stable comes out.

http://cvs.php.net/diff.php/pearweb/public_html/release-upload.php?r1=1.59&r2=1.60&ty=u Index: pearweb/public_html/release-upload.php diff -u pearweb/public_html/release-upload.php:1.59 pearweb/public_html/release-upload.php:1.60 --- pearweb/public_html/release-upload.php:1.59 Mon Feb 28 18:47:08 2005 +++ pearweb/public_html/release-upload.php Tue Mar 1 13:14:01 2005 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: | +----------------------------------------------------------------------+ - $Id: release-upload.php,v 1.59 2005/02/28 23:47:08 pajoye Exp $ + $Id: release-upload.php,v 1.60 2005/03/01 18:14:01 cellog Exp $ */ auth_require('pear.dev'); @@ -90,7 +90,7 @@ } break; } else { - $pacid = package::info($info->getPackage(), 'id'); + $pacid = package::info($info->getPackage(), 'id', true); if (PEAR::isError($pacid)) { $errors[] = $pacid->getMessage(); break; @@ -118,7 +118,7 @@ foreach ($info->getMaintainers() as $user) { $users[strtolower($user['handle'])] = array( 'role' => $user['role'], - 'active' => $user['active'] == 'yes', + 'active' => !isset($user['active']) || $user['active'] == 'yes', ); } $e = maintainer::updateAll($pacid, $users); @@ -132,7 +132,7 @@ } } else { - $pacid = package::info($info['package'], 'id'); + $pacid = package::info($info['package'], 'id', true); if (PEAR::isError($pacid)) { $errors[] = $pacid->getMessage(); break; @@ -288,15 +288,28 @@ } $errors[] = $info->getMessage(); } else { - if ($info->getState() == 'stable') { - $releases = package::info($info->getPackage(), 'releases'); - if (!count($releases)) { - $errors[] = "The first release of a package must be 'alpha' or 'beta', not 'stable'." . - " Try releasing version 1.0.0RC1, state 'beta'"; - } + $id = package::info($info->getPackage(), 'id', true); + if ($id) { + $type = $dbh->getOne('SELECT package_type FROM packages WHERE id = ?', array($id)); + } + if ($type == 'pear') { $version = $info->getVersion(); - if ($version{0} < '1') { - $errors[] = "Versions < 1.0.0 may not be 'stable'"; + $verinfo = explode('.', $version); + if (count($verinfo) != 3) { + $errors[] = "Versions must have 3 decimals as in x.y.z"; + } + if ($info->getState() == 'stable') { + $releases = package::info($info->getPackage(), 'releases', true); + if (!count($releases)) { + $errors[] = "The first release of a package must be 'alpha' or 'beta', not 'stable'." . + " Try releasing version 1.0.0RC1, state 'beta'"; + } + if ($version{0} < 1) { + $errors[] = "Versions < 1.0.0 may not be 'stable'"; + } + if (!preg_match('/^\d+$/', $verinfo[2])) { + $errors[] = "Stable versions must not have a postfix (use 'beta' for RC postfix)"; + } } } } @@ -346,7 +359,7 @@ if ($info['release_state'] == 'stable') { // see if this is the first release - $releases = package::info($info['package'], 'releases'); + $releases = package::info($info['package'], 'releases', true); if (!count($releases)) { $errors[] = "The first release of a package must be 'alpha' or 'beta', not 'stable'." . " Try releasing version 1.0.0RC1, state 'beta'"; http://cvs.php.net/diff.php/pearweb/include/pear-database.php?r1=1.270&r2=1.271&ty=u Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.270 pearweb/include/pear-database.php:1.271 --- pearweb/include/pear-database.php:1.270 Tue Mar 1 12:21:15 2005 +++ pearweb/include/pear-database.php Tue Mar 1 13:14:02 2005 @@ -17,7 +17,7 @@ | Tomas V.V.Cox <cox@php.net> | | Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: pear-database.php,v 1.270 2005/03/01 17:21:15 cellog Exp $ + $Id: pear-database.php,v 1.271 2005/03/01 18:14:02 cellog Exp $ */ require_once 'DB/storage.php'; @@ -1037,7 +1037,7 @@ function updateInfo($pkgid, $data) { global $dbh, $auth_user; - $package_id = package::info($pkgid, 'id'); + $package_id = package::info($pkgid, 'id', true); if (PEAR::isError($package_id) || empty($package_id)) { return PEAR::raiseError("Package not registered or not approved. Please register it first with \"New Package\" or wait until it gets approved."); } @@ -1192,7 +1192,7 @@ return PEAR::raiseError("User $user does not exist"); } if (is_string($package)) { - $package = package::info($package, 'id'); + $package = package::info($package, 'id', true); } $err = $dbh->query("INSERT INTO maintains VALUES(?,?,?,?)", array($user, $package, $role, $active)); @@ -1217,7 +1217,7 @@ { global $dbh; if (is_string($package)) { - $package = package::info($package, 'id'); + $package = package::info($package, 'id', true); } $query = "SELECT handle, role, active FROM maintains WHERE package = ?"; if ($lead) { @@ -1282,7 +1282,7 @@ return PEAR::raiseError('maintainer::remove: insufficient privileges'); } if (is_string($package)) { - $package = package::info($package, 'id'); + $package = package::info($package, 'id', true); } $sql = "DELETE FROM maintains WHERE package = ? AND handle = ?"; return $dbh->query($sql, array($package, $user)); @@ -1556,7 +1556,7 @@ return PEAR::raiseError('release::validateUpload: insufficient privileges'); } // (2) verify that package exists - $package_id = package::info($package, 'id'); + $package_id = package::info($package, 'id', true); if (PEAR::isError($package_id) || empty($package_id)) { return PEAR::raiseError("package `$package' must be registered first"); } @@ -1689,93 +1689,98 @@ } } } - foreach ($storedeps as $dep) { - $prob = array(); - - if (empty($dep['type']) || - !in_array($dep['type'], $_PEAR_Common_dependency_types)) - { - $prob[] = 'type'; - } - - if (empty($dep['name'])) { - /* - * NOTE from pajoye in ver 1.166: - * This works for now. - * This would require a 'cleaner' InfoFromXXX - * which may return a defined set of data using - * default values if required. - */ - if (strtolower($dep['type']) == 'php') { - $dep['name'] = 'PHP'; - } else { - $prob[] = 'name'; + if (is_array($storedeps)) { + foreach ($storedeps as $dep) { + $prob = array(); + + if (empty($dep['type']) || + !in_array($dep['type'], $_PEAR_Common_dependency_types)) + { + $prob[] = 'type'; } - } elseif (strtolower($dep['name']) == 'pear') { - if (!$pearused && $compatible) { - // there is no need for a PEAR dependency here - continue; + + if (empty($dep['name'])) { + /* + * NOTE from pajoye in ver 1.166: + * This works for now. + * This would require a 'cleaner' InfoFromXXX + * which may return a defined set of data using + * default values if required. + */ + if (strtolower($dep['type']) == 'php') { + $dep['name'] = 'PHP'; + } else { + $prob[] = 'name'; + } + } elseif (strtolower($dep['name']) == 'pear') { + if (!$pearused && $compatible) { + // there is no need for a PEAR dependency here + continue; + } + if (!$pearused && !$compatible) { + $dep['name'] = 'PEAR Installer'; + } } - if (!$pearused && !$compatible) { - $dep['name'] = 'PEAR Installer'; + + if (empty($dep['rel']) || + !in_array($dep['rel'], $_PEAR_Common_dependency_relations)) + { + $prob[] = 'rel'; } - } - - if (empty($dep['rel']) || - !in_array($dep['rel'], $_PEAR_Common_dependency_relations)) - { - $prob[] = 'rel'; - } - - if (empty($dep['optional'])) { - $optional = 0; - } else { - if ($dep['optional'] != strtolower($dep['optional'])) { - $prob[] = 'optional'; + + if (empty($dep['optional'])) { + $optional = 0; + } else { + if ($dep['optional'] != strtolower($dep['optional'])) { + $prob[] = 'optional'; + } + if ($dep['optional'] == 'yes') { + $optional = 1; + } else { + $optional = 0; + } } - if ($dep['optional'] == 'yes') { - $optional = 1; + + if (count($prob)) { + $res = PEAR::raiseError('The following attribute(s) ' . + 'were missing or need proper values: ' . + implode(', ', $prob)); } else { - $optional = 0; + $res = $dbh->execute($sth, + array( + $package_id, + $release_id, + $dep['type'], + $dep['rel'], + @$dep['version'], + $dep['name'], + $optional)); + } + + if (PEAR::isError($res)) { + $dbh->query('DELETE FROM deps WHERE ' . + "release = $release_id"); + $dbh->query('DELETE FROM releases WHERE ' . + "id = $release_id"); + @unlink($file); + return $res; } } - - if (count($prob)) { - $res = PEAR::raiseError('The following attribute(s) ' . - 'were missing or need proper values: ' . - implode(', ', $prob)); - } else { - $res = $dbh->execute($sth, - array( - $package_id, - $release_id, - $dep['type'], - $dep['rel'], - @$dep['version'], - $dep['name'], - $optional)); - } - - if (PEAR::isError($res)) { - $dbh->query('DELETE FROM deps WHERE ' . - "release = $release_id"); - $dbh->query('DELETE FROM releases WHERE ' . - "id = $release_id"); - @unlink($file); - return $res; - } } - // Add release archive file to API documentation queue - $query = "INSERT INTO apidoc_queue (filename, queued) " - . "VALUES ('" . $file. "', NOW())"; - - /* - * Don't abort the release if something goes wrong. - */ - $dbh->pushErrorHandling(PEAR_ERROR_RETURN); - $sth = $dbh->query($query); - $dbh->popErrorHandling(); + $type = $dbh->getOne('SELECT package_type FROM packages WHERE id = ?', array($id)); + if ($type == 'pear') { + // Add release archive file to API documentation queue + $query = "INSERT INTO apidoc_queue (filename, queued) " + . "VALUES ('" . $file. "', NOW())"; + + /* + * Don't abort the release if something goes wrong. + */ + $dbh->pushErrorHandling(PEAR_ERROR_RETURN); + $sth = $dbh->query($query); + $dbh->popErrorHandling(); + } // Update Cache include_once 'xmlrpc-cache.php'; @@ -2037,6 +2042,58 @@ } // }}} + + /** + * Promote new release + * + * @param array Coming from PEAR_common::infoFromDescFile('package.xml') + * @param string Filename of the new uploaded release + * @return void + */ + function _peclPromote($pkginfo, $upload) + { + if ($_SERVER['SERVER_NAME'] != PEAR_CHANNELNAME) { + return; + } + $pacid = package::info($pkginfo['package'], 'packageid', true); + $authors = package::info($pkginfo['package'], 'authors', true); + $txt_authors = ''; + foreach ($authors as $a) { + $txt_authors .= $a['name']; + if ($a['showemail']) { + $txt_authors .= " <{$a['email']}>"; + } + $txt_authors .= " ({$a['role']})\n"; + } + $upload = basename($upload); + $release = "{$pkginfo['package']}-{$pkginfo['version']} ({$pkginfo['release_state']})"; + $txtanounce =<<<END +The new PECL package $release has been released at http://pecl.php.net/. + +Release notes +------------- +{$pkginfo['release_notes']} + +Package Info +------------- +{$pkginfo['description']} + +Related Links +------------- +Package home: http://pecl.php.net/package/$pkginfo[package] + Changelog: http://pecl.php.net/package-changelog.php?package=$pkginfo[package] + Download: http://pecl.php.net/get/$upload + +Authors +------------- +$txt_authors +END; + $to = '"PECL developers list" <pecl-dev@lists.php.net>'; + $from = '"PECL Announce" <pecl-dev@lists.php.net>'; + $subject = "[ANNOUNCEMENT] $release Released."; + mail($to, $subject, $txtanounce, "From: $from", "-f pear-sys@php.net"); + } + // {{{ +proto string release::promote(array, string) API 1.0 /** @@ -2051,6 +2108,10 @@ if ($_SERVER['SERVER_NAME'] != PEAR_CHANNELNAME) { return; } + $type = $dbh->getOne('SELECT package_type FROM packages WHERE id = ?', array($id)); + if ($type == 'pecl') { + return $this->_peclPromote($pkginfo, $upload); + } $pacid = package::info($pkginfo['package'], 'packageid'); $authors = package::info($pkginfo['package'], 'authors'); $txt_authors = ''; @@ -2402,7 +2463,7 @@ function maintains($user, $pkgid, $role = 'any') { global $dbh; - $package_id = package::info($pkgid, 'id'); + $package_id = package::info($pkgid, 'id', true); if ($role == 'any') { return $dbh->getOne('SELECT role FROM maintains WHERE handle = ? '. 'AND package = ?', array($user, $package_id));
« previous php.pear.cvs (#29963) next »