本文整理汇总了PHP中PEAR_Downloader::log方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Downloader::log方法的具体用法?PHP PEAR_Downloader::log怎么用?PHP PEAR_Downloader::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Downloader
的用法示例。
在下文中一共展示了PEAR_Downloader::log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
/**
* @param array output of package.getDownloadURL
* @param string|array|object information for detecting packages to be downloaded, and
* for errors
* @param array name information of the package
* @param array|null packages to be downloaded
* @access private
*/
function _analyzeDownloadURL($info, $param, $pname, $params = null)
{
if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
return false;
}
if (!$info) {
if (!is_string($param)) {
$saveparam = ", cannot download \"{$param}\"";
} else {
$saveparam = '';
}
// no releases exist
return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
}
if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
$err = false;
if ($pname['channel'] == 'pear.php.net') {
if ($info['info']->getChannel() != 'pecl.php.net') {
$err = true;
}
} else {
$err = true;
}
if ($err) {
return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
}
}
if (!isset($info['url'])) {
// releases exist, but we failed to get any
if (isset($this->_downloader->_options['force'])) {
if (isset($pname['version'])) {
$vs = ', version "' . $pname['version'] . '"';
} elseif (isset($pname['state'])) {
$vs = ', stability "' . $pname['state'] . '"';
} else {
$vs = ' within preferred state ' . $this->_config->get('preferred_state') . '"';
}
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"');
}
// download the latest release
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
} else {
// construct helpful error message
if (isset($pname['version'])) {
$vs = ', version "' . $pname['version'] . '"';
} elseif (isset($pname['state'])) {
$vs = ', stability "' . $pname['state'] . '"';
} else {
$vs = ' within preferred state ' . $this->_downloader->config->get('preferred_state') . '"';
}
$err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . $vs . ', latest release is version ' . $info['version'] . ', stability "' . $info['info']->getState() . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['version'])) . '" to install');
return $err;
}
}
return $info;
}
示例2: validatePackage
/**
* validate a downloaded package against installed packages
*
* As of PEAR 1.4.3, this will only validate
*
* @param array|PEAR_Downloader_Package|PEAR_PackageFile_v1|PEAR_PackageFile_v2
* $pkg package identifier (either
* array('package' => blah, 'channel' => blah) or an array with
* index 'info' referencing an object)
* @param PEAR_Downloader $dl
* @param array $params full list of packages to install
* @return true|PEAR_Error
*/
function validatePackage($pkg, &$dl, $params = array())
{
if (is_array($pkg) && isset($pkg['info'])) {
$deps = $this->_dependencydb->getDependentPackageDependencies($pkg['info']);
} else {
$deps = $this->_dependencydb->getDependentPackageDependencies($pkg);
}
$fail = false;
if ($deps) {
if (!class_exists('PEAR_Downloader_Package')) {
require_once 'PEAR/Downloader/Package.php';
}
$dp =& new PEAR_Downloader_Package($dl);
if (is_object($pkg)) {
$dp->setPackageFile($pkg);
} else {
$dp->setDownloadURL($pkg);
}
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
foreach ($deps as $channel => $info) {
foreach ($info as $package => $ds) {
foreach ($params as $packd) {
if (strtolower($packd->getPackage()) == strtolower($package) && $packd->getChannel() == $channel) {
$dl->log(3, 'skipping installed package check of "' . $this->_registry->parsedPackageNameToString(array('channel' => $channel, 'package' => $package), true) . '", version "' . $packd->getVersion() . '" will be ' . 'downloaded and installed');
continue 2;
// jump to next package
}
}
foreach ($ds as $d) {
$checker =& new PEAR_Dependency2($this->_config, $this->_options, array('channel' => $channel, 'package' => $package), $this->_state);
$dep = $d['dep'];
$required = $d['type'] == 'required';
$ret = $checker->_validatePackageDownload($dep, $required, array(&$dp));
if (is_array($ret)) {
$dl->log(0, $ret[0]);
} elseif (PEAR::isError($ret)) {
$dl->log(0, $ret->getMessage());
$fail = true;
}
}
}
}
PEAR::popErrorHandling();
}
if ($fail) {
return $this->raiseError('%s cannot be installed, conflicts with installed packages');
}
return true;
}
示例3: elseif
/**
* @param array output of package.getDownloadURL
* @param string|array|object information for detecting packages to be downloaded, and
* for errors
* @param array name information of the package
* @param array|null packages to be downloaded
* @param bool is this an optional dependency?
* @param bool is this any kind of dependency?
* @access private
*/
function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false, $isdependency = false)
{
if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
return false;
}
if ($info === false) {
$saveparam = !is_string($param) ? ", cannot download \"{$param}\"" : '';
// no releases exist
return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
}
if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
$err = false;
if ($pname['channel'] == 'pecl.php.net') {
if ($info['info']->getChannel() != 'pear.php.net') {
$err = true;
}
} elseif ($info['info']->getChannel() == 'pecl.php.net') {
if ($pname['channel'] != 'pear.php.net') {
$err = true;
}
} else {
$err = true;
}
if ($err) {
return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
}
}
$preferred_state = $this->_config->get('preferred_state');
if (!isset($info['url'])) {
$package_version = $this->_registry->packageInfo($info['info']->getPackage(), 'version', $info['info']->getChannel());
if ($this->isInstalled($info)) {
if ($isdependency && version_compare($info['version'], $package_version, '<=')) {
// ignore bogus errors of "failed to download dependency"
// if it is already installed and the one that would be
// downloaded is older or the same version (Bug #7219)
return false;
}
}
if ($info['version'] === $package_version) {
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' . ' (' . $package_version . ') is the same as the locally installed one.');
}
return false;
}
if (version_compare($info['version'], $package_version, '<=')) {
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . '-' . $package_version . ', additionally the suggested version' . ' (' . $info['version'] . ') is a lower version than the locally installed one (' . $package_version . ').');
}
return false;
}
$instead = ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"';
// releases exist, but we failed to get any
if (isset($this->_downloader->_options['force'])) {
if (isset($pname['version'])) {
$vs = ', version "' . $pname['version'] . '"';
} elseif (isset($pname['state'])) {
$vs = ', stability "' . $pname['state'] . '"';
} elseif ($param == 'dependency') {
if (!class_exists('PEAR_Common')) {
require_once 'PEAR/Common.php';
}
if (!in_array($info['info']->getState(), PEAR_Common::betterStates($preferred_state, true))) {
if ($optional) {
// don't spit out confusing error message
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
}
$vs = ' within preferred state "' . $preferred_state . '"';
} else {
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
if ($optional) {
// don't spit out confusing error message
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
}
$vs = PEAR_Dependency2::_getExtraString($pname);
$instead = '';
}
} else {
$vs = ' within preferred state "' . $preferred_state . '"';
}
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . $instead);
}
// download the latest release
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
} else {
if (isset($info['php']) && $info['php']) {
$err = PEAR::raiseError('Failed to download ' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package']), true) . ', latest release is version ' . $info['php']['v'] . ', but it requires PHP version "' . $info['php']['m'] . '", use "' . $this->_registry->parsedPackageNameToString(array('channel' => $pname['channel'], 'package' => $pname['package'], 'version' => $info['php']['v'])) . '" to install', PEAR_DOWNLOADER_PACKAGE_PHPVERSION);
return $err;
//.........这里部分代码省略.........
示例4: elseif
/**
* @param array output of package.getDownloadURL
* @param string|array|object information for detecting packages to be downloaded, and
* for errors
* @param array name information of the package
* @param array|null packages to be downloaded
* @param bool is this an optional dependency?
* @access private
*/
function _analyzeDownloadURL($info, $param, $pname, $params = null, $optional = false)
{
if (!is_string($param) && PEAR_Downloader_Package::willDownload($param, $params)) {
return false;
}
if (!$info) {
if (!is_string($param)) {
$saveparam = ", cannot download \"{$param}\"";
} else {
$saveparam = '';
}
// no releases exist
return PEAR::raiseError('No releases for package "' . $this->_registry->parsedPackageNameToString($pname, true) . '" exist' . $saveparam);
}
if (strtolower($info['info']->getChannel()) != strtolower($pname['channel'])) {
$err = false;
if ($pname['channel'] == 'pecl.php.net') {
if ($info['info']->getChannel() != 'pear.php.net') {
$err = true;
}
} elseif ($info['info']->getChannel() == 'pecl.php.net') {
if ($pname['channel'] != 'pear.php.net') {
$err = true;
}
} else {
$err = true;
}
if ($err) {
return PEAR::raiseError('SECURITY ERROR: package in channel "' . $pname['channel'] . '" retrieved another channel\'s name for download! ("' . $info['info']->getChannel() . '")');
}
}
if (!isset($info['url'])) {
$instead = ', will instead download version ' . $info['version'] . ', stability "' . $info['info']->getState() . '"';
// releases exist, but we failed to get any
if (isset($this->_downloader->_options['force'])) {
if (isset($pname['version'])) {
$vs = ', version "' . $pname['version'] . '"';
} elseif (isset($pname['state'])) {
$vs = ', stability "' . $pname['state'] . '"';
} elseif ($param == 'dependency') {
if (!class_exists('PEAR_Common')) {
require_once 'PEAR/Common.php';
}
if (!in_array($info['info']->getState(), PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
if ($optional) {
// don't spit out confusing error message
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
}
$vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
} else {
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
if ($optional) {
// don't spit out confusing error message
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
}
$vs = PEAR_Dependency2::_getExtraString($pname);
$instead = '';
}
} else {
$vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
}
if (!isset($options['soft'])) {
$this->_downloader->log(1, 'WARNING: failed to download ' . $pname['channel'] . '/' . $pname['package'] . $vs . $instead);
}
// download the latest release
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
} else {
// construct helpful error message
if (isset($pname['version'])) {
$vs = ', version "' . $pname['version'] . '"';
} elseif (isset($pname['state'])) {
$vs = ', stability "' . $pname['state'] . '"';
} elseif ($param == 'dependency') {
if (!class_exists('PEAR_Common')) {
require_once 'PEAR/Common.php';
}
if (!in_array($info['info']->getState(), PEAR_Common::betterStates($this->_config->get('preferred_state'), true))) {
if ($optional) {
// don't spit out confusing error message, and don't die on
// optional dep failure!
return $this->_downloader->_getPackageDownloadUrl(array('package' => $pname['package'], 'channel' => $pname['channel'], 'version' => $info['version']));
}
$vs = ' within preferred state "' . $this->_config->get('preferred_state') . '"';
} else {
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
if ($optional) {
// don't spit out confusing error message, and don't die on
//.........这里部分代码省略.........