本文整理汇总了PHP中PEAR::popErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR::popErrorHandling方法的具体用法?PHP PEAR::popErrorHandling怎么用?PHP PEAR::popErrorHandling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR
的用法示例。
在下文中一共展示了PEAR::popErrorHandling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run($answers, $phase)
{
switch ($phase) {
case 'askdb':
if ($answers['yesno'] != 'y') {
$this->_ui->skipParamgroup('init');
}
return true;
break;
case 'init':
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
if (PEAR::isError($err = MDB2::loadFile('Driver' . DIRECTORY_SEPARATOR . $answers['driver']))) {
PEAR::popErrorHandling();
$this->_ui->outputData('ERROR: Unknown MDB2 driver "' . $answers['driver'] . '": ' . $err->getUserInfo() . '. Be sure you have installed ' . 'MDB2_Driver_' . $answers['driver']);
return false;
}
PEAR::popErrorHandling();
if ($answers['driver'] !== 'mysqli') {
$this->_ui->outputData('pearweb only supports mysqli, ' . 'not ' . $answers['driver']);
return false;
}
return $this->initializeDatabase($answers);
break;
case 'askhttpd':
if ($answers['yesno'] != 'y') {
$this->_ui->skipParamgroup('httpdconf');
}
return true;
break;
case 'httpdconf':
return $this->setupHttpdconf($answers);
break;
}
return true;
}
示例2: sendEmail
function sendEmail()
{
if (!$this->handle) {
throw new Exception('Internal fault: user was not set when sending email,
please report to ' . PEAR_DEV_EMAIL);
}
$sql = 'SELECT salt FROM bug_account_request WHERE handle = ?';
$salt = $this->dbh->getOne($sql, array($this->handle));
if (!$salt) {
throw new Exception('No such handle ' . $this->handle . ' found, cannot send confirmation email');
}
$sql = 'SELECT email FROM bug_account_request WHERE salt = ?';
$email = $this->dbh->getOne($sql, array($salt));
if (!$email) {
throw new Exception('No such salt found, cannot send confirmation email');
}
$mailData = array('salt' => $salt);
require_once 'Damblan/Mailer.php';
$mailer = Damblan_Mailer::create('pearweb_account_request_bug', $mailData);
$additionalHeaders['To'] = $email;
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
if (!DEVBOX) {
$e = $mailer->send($additionalHeaders);
}
PEAR::popErrorHandling();
if (!DEVBOX && PEAR::isError($e)) {
throw new Exception('Cannot send confirmation email: ' . $e->getMessage());
}
return true;
}
示例3: testDeliveryBlocked
/**
* A method to test the deliveryBlocked() method.
*
* Tests that the method in the class returns a PEAR::Error, as method is abstract.
*/
function testDeliveryBlocked()
{
$oDate = new Date();
PEAR::pushErrorHandling(null);
$this->assertTrue(is_a(OA_Maintenance_Priority_DeliveryLimitation_Common::deliveryBlocked($oDate), 'pear_error'));
PEAR::popErrorHandling();
}
示例4: test_instantiateController
function test_instantiateController()
{
$file = MAX_PATH . '/lib/OA/Admin/Statistics/Delivery/Common.php';
$aParams = array();
$class = 'OA_Admin_Statistics_Delivery_Common';
$oObject =& OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
$this->assertIsA($oObject, $class);
$this->assertEqual(count($oObject->aPlugins), 2);
$this->assertTrue(isset($oObject->aPlugins['default']));
$this->assertTrue(isset($oObject->aPlugins['affiliates']));
$file = MAX_PATH . '/lib/OA/Admin/Statistics/tests/data/TestStatisticsController.php';
$aParams = array();
$class = 'OA_Admin_Statistics_Test';
$oObject =& OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
$this->assertIsA($oObject, $class);
// Disable default error handling
PEAR::pushErrorHandling(null);
// Test _instantiateController for not existing controller
$file = MAX_PATH . '/lib/OA/Admin/Statistics/tests/data/TestNotExists.php';
$aParams = array();
$class = 'OA_Admin_Statistics_Test';
$oObject =& OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
$this->assertTrue(PEAR::isError($oObject));
$this->assertEqual($oObject->getMessage(), 'OA_Admin_Statistics_Factory::_instantiateController() Unable to locate ' . basename($file));
// Test _instantiateController for not existing class
$file = MAX_PATH . '/lib/OA/Admin/Statistics/tests/data/TestStatisticsController.php';
$aParams = array();
$class = 'OA_Admin_not_exists';
$oObject =& OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
$this->assertTrue(PEAR::isError($oObject));
$this->assertEqual($oObject->getMessage(), 'OA_Admin_Statistics_Factory::_instantiateController() Class ' . $class . ' doesn\'t exist');
// Restore default error handling
PEAR::popErrorHandling();
}
示例5: processInstallation
function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null)
{
$test = parent::processInstallation($pkg, $atts, $file, $tmp_path, $layer);
if (@file_exists($test[2])) {
// configuration has already been installed, check for mods
if (md5_file($test[2]) !== md5_file($test[3])) {
// configuration has been modified, so save our version as
// configfile-version
$old = $test[2];
$test[2] .= '.new-' . $pkg->getVersion();
// backup original and re-install it
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$tmpcfg = $this->config->get('temp_dir');
$newloc = System::mkdir(array('-p', $tmpcfg));
if (!$newloc) {
// try temp_dir
$newloc = System::mktemp(array('-d'));
if (!$newloc || PEAR::isError($newloc)) {
PEAR::popErrorHandling();
return PEAR::raiseError('Could not save existing configuration file ' . $old . ', unable to install. Please set temp_dir ' . 'configuration variable to a writeable location and try again');
}
} else {
$newloc = $tmpcfg;
}
if (!@copy($old, $newloc . DIRECTORY_SEPARATOR . 'savefile')) {
PEAR::popErrorHandling();
return PEAR::raiseError('Could not save existing configuration file ' . $old . ', unable to install. Please set temp_dir ' . 'configuration variable to a writeable location and try again');
}
PEAR::popErrorHandling();
$this->installer->addFileOperation('rename', array($newloc . DIRECTORY_SEPARATOR . 'savefile', $old, false));
$this->installer->addFileOperation('delete', array($newloc . DIRECTORY_SEPARATOR . 'savefile'));
}
}
return $test;
}
示例6: testDeliveryBlocked
/**
* A method to test the deliveryBlocked() method.
*
* Tests that the method in the class returns a PEAR::Error, as method is abstract.
*/
function testDeliveryBlocked()
{
$oCommon = new OA_Maintenance_Priority_DeliveryLimitation_Common(array());
PEAR::pushErrorHandling(null);
$this->assertTrue($oCommon->deliveryBlocked(new Date()) instanceof PEAR_Error);
PEAR::popErrorHandling();
}
示例7: enableErrorHandling
/**
* A method to re-enable PEAR error handling by popping
* a null error handler off the top of the stack.
*
* @static
*/
static function enableErrorHandling()
{
// Ensure this method only acts when a null error handler exists
$stack =& $GLOBALS['_PEAR_error_handler_stack'];
list($mode, $options) = $stack[sizeof($stack) - 1];
if (is_null($mode) && is_null($options)) {
PEAR::popErrorHandling();
}
}
示例8:
/**
* Create a new object of the appropriate OA_Admin_Statistics_Common subclass.
*
* @static
* @param string $controllerType The controller type (e.g. "global-advertiser").
* @param array $aParams An array of parameters to be passed as the parameter
* to the constructor of the class instantiated.
* @return OA_Admin_Statistics_Common The instantiated class that inherits from
* OA_Admin_Statistics_Common.
*/
function &getController($controllerType = '', $aParams = null)
{
// Instantiate & return the required statistics class
$result = OA_Admin_Statistics_Factory::_getControllerClass($controllerType, $aParams, $class, $file);
if (PEAR::isError($result)) {
return $result;
}
// To allow catch errors and pass it out without calling error handler
PEAR::pushErrorHandling(null);
$oStatsController = OA_Admin_Statistics_Factory::_instantiateController($file, $class, $aParams);
PEAR::popErrorHandling();
return $oStatsController;
}
示例9: attach
/**
* Attach a pull request to this bug
*/
function attach($bugid, $repo, $pull_id, $developer)
{
$data = $this->getDataFromGithub($repo, $pull_id);
if (!$data) {
return PEAR::raiseError('Failed to retrieve pull request from GitHub');
}
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$e = $this->_dbh->prepare('INSERT INTO bugdb_pulls
(bugdb_id, github_repo, github_pull_id, github_title, github_html_url, developer) VALUES (?, ?, ?, ?, ?, ?)')->execute(array($bugid, $repo, $pull_id, $data->title, $data->html_url, $developer));
PEAR::popErrorHandling();
if (PEAR::isError($e)) {
return $e;
}
return $data;
}
示例10: newPatchFileName
/**
* Retrieve a unique, ordered patch filename
*
* @param int $bugid
* @param string $patch
* @return array array(revision, patch file name)
*/
function newPatchFileName($bugid, $patch, $handle)
{
$id = time();
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$e = $this->_dbh->query('INSERT INTO bugdb_patchtracker
(bugdb_id, patch, revision, developer) VALUES(?, ?, ?, ?)', array($bugid, $patch, $id, $handle));
if (PEAR::isError($e)) {
// try with another timestamp
$id++;
$e = $this->_dbh->query('INSERT INTO bugdb_patchtracker
(bugdb_id, patch, revision, developer) VALUES(?, ?, ?, ?)', array($bugid, $patch, $id, $handle));
}
PEAR::popErrorHandling();
if (PEAR::isError($e)) {
return PEAR::raiseError('Could not get unique patch file name for bug #' . $bugid . ', patch "' . $patch . '"');
}
return array($id, $this->getPatchFileName($id));
}
示例11: newPatchFileName
/**
* Retrieve a unique, ordered patch filename
*
* @param int $bugid
* @param string $patch
* @return array array(revision, patch file name)
*/
function newPatchFileName($bugid, $patch, $handle)
{
$id = time();
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$e = $this->_dbh->prepare('INSERT INTO bugdb_patchtracker
(bugdb_id, patch, revision, developer) VALUES(?, ?, ?, ?)')->execute(array($bugid, $patch, $id, $handle));
if (PEAR::isError($e)) {
// try with another timestamp
$id++;
$e = $this->_dbh->prepare('INSERT INTO bugdb_patchtracker
(bugdb_id, patch, revision, developer) VALUES(?, ?, ?, ?)')->execute(array($bugid, $patch, $id, $handle));
}
PEAR::popErrorHandling();
if (PEAR::isError($e)) {
return PEAR::raiseError("Could not get unique patch file name for bug #{$bugid}, patch \"{$patch}\"");
}
return array($id, $this->getPatchFileName($id));
}
示例12: __construct
public function __construct($oUpgrader)
{
if ($oUpgrader->isRecoveryRequired()) {
$this->isRecovery = true;
} else {
if ($oUpgrader->isFreshInstall()) {
$this->isInstall = true;
} else {
PEAR::pushErrorHandling(null);
$oUpgrader->canUpgradeOrInstall();
PEAR::popErrorHandling();
if ($oUpgrader->existing_installation_status == OA_STATUS_CURRENT_VERSION) {
$this->isUpToDate = true;
} else {
$this->isUpgrade = true;
}
}
}
}
示例13: startSession
/**
* Unlike other tasks, the installed file name is passed in instead of the file contents,
* because this task is handled post-installation
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
* @param string file name
* @return bool|PEAR_Error false to skip this file, PEAR_Error to fail
* (use $this->throwError)
*/
function startSession($pkg, $contents)
{
if ($this->installphase != PEAR_TASK_INSTALL) {
return false;
}
// remove the tasks: namespace if present
$this->_pkg = $pkg;
$this->_stripNamespace();
$this->logger->log(0, 'Including external post-installation script "' . $contents . '" - any errors are in this script');
include_once $contents;
if (class_exists($this->_class)) {
$this->logger->log(0, 'Inclusion succeeded');
} else {
return $this->throwError('init of post-install script class "' . $this->_class . '" failed');
}
$this->_obj = new $this->_class();
$this->logger->log(1, 'running post-install script "' . $this->_class . '->init()"');
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$res = $this->_obj->init($this->config, $pkg, $this->_lastversion);
PEAR::popErrorHandling();
if ($res) {
$this->logger->log(0, 'init succeeded');
} else {
return $this->throwError('init of post-install script "' . $this->_class . '->init()" failed');
}
$this->_contents = $contents;
return true;
}
示例14: packageInfo
function packageInfo($base, $package)
{
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$pinfo = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml');
if (PEAR::isError($pinfo)) {
PEAR::popErrorHandling();
return PEAR::raiseError('Unknown package: "' . $package . '" (Debug: ' . $pinfo->getMessage() . ')');
}
$releases = array();
$allreleases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml');
if (!PEAR::isError($allreleases)) {
if (!class_exists('PEAR_PackageFile_v2')) {
require_once 'PEAR/PackageFile/v2.php';
}
if (!is_array($allreleases['r']) || !isset($allreleases['r'][0])) {
$allreleases['r'] = array($allreleases['r']);
}
$pf = new PEAR_PackageFile_v2();
foreach ($allreleases['r'] as $release) {
$ds = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/deps.' . $release['v'] . '.txt');
if (PEAR::isError($ds)) {
continue;
}
if (!isset($latest)) {
$latest = $release['v'];
}
$pf->setDeps(unserialize($ds));
$ds = $pf->getDeps();
$info = $this->_rest->retrieveCacheFirst($base . 'r/' . strtolower($package) . '/' . $release['v'] . '.xml');
if (PEAR::isError($info)) {
continue;
}
$releases[$release['v']] = array('doneby' => $info['m'], 'license' => $info['l'], 'summary' => $info['s'], 'description' => $info['d'], 'releasedate' => $info['da'], 'releasenotes' => $info['n'], 'state' => $release['s'], 'deps' => $ds ? $ds : array());
}
} else {
$latest = '';
}
PEAR::popErrorHandling();
if (isset($pinfo['dc']) && isset($pinfo['dp'])) {
if (is_array($pinfo['dp'])) {
$deprecated = array('channel' => (string) $pinfo['dc'], 'package' => trim($pinfo['dp']['_content']));
} else {
$deprecated = array('channel' => (string) $pinfo['dc'], 'package' => trim($pinfo['dp']));
}
} else {
$deprecated = false;
}
return array('name' => $pinfo['n'], 'channel' => $pinfo['c'], 'category' => $pinfo['ca']['_content'], 'stable' => $latest, 'license' => $pinfo['l'], 'summary' => $pinfo['s'], 'description' => $pinfo['d'], 'releases' => $releases, 'deprecated' => $deprecated);
}
示例15: array
//.........这里部分代码省略.........
}
$curchannel =& $this->_registry->getChannel($params[$i]->getChannel());
if (PEAR::isError($curchannel)) {
PEAR::staticPopErrorHandling();
return $this->raiseError($curchannel);
}
$a = $this->downloadHttp('http://' . $params[$i]->getChannel() . '/channel.xml', $this->ui, System::mktemp(array('-d')), null, $curchannel->lastModified());
PEAR::staticPopErrorHandling();
if (PEAR::isError($a) || !$a) {
continue;
}
$this->log(0, 'WARNING: channel "' . $params[$i]->getChannel() . '" has ' . 'updated its protocols, use "channel-update ' . $params[$i]->getChannel() . '" to update');
}
if ($params[$i] && !isset($this->_options['downloadonly'])) {
if (isset($this->_options['packagingroot'])) {
$checkdir = $this->_prependPath($this->config->get('php_dir', null, $params[$i]->getChannel()), $this->_options['packagingroot']);
} else {
$checkdir = $this->config->get('php_dir', null, $params[$i]->getChannel());
}
while ($checkdir && $checkdir != '/' && !file_exists($checkdir)) {
$checkdir = dirname($checkdir);
}
if ($checkdir == '.') {
$checkdir = '/';
}
if (!@is_writeable($checkdir)) {
return PEAR::raiseError('Cannot install, php_dir for channel "' . $params[$i]->getChannel() . '" is not writeable by the current user');
}
}
}
}
unset($channelschecked);
PEAR_Downloader_Package::removeDuplicates($params);
if (!count($params)) {
$a = array();
return $a;
}
if (!isset($this->_options['nodeps']) && !isset($this->_options['offline'])) {
$reverify = true;
while ($reverify) {
$reverify = false;
foreach ($params as $i => $param) {
$ret = $params[$i]->detectDependencies($params);
if (PEAR::isError($ret)) {
$reverify = true;
$params[$i] = false;
PEAR_Downloader_Package::removeDuplicates($params);
if (!isset($this->_options['soft'])) {
$this->log(0, $ret->getMessage());
}
continue 2;
}
}
}
}
if (isset($this->_options['offline'])) {
$this->log(3, 'Skipping dependency download check, --offline specified');
}
if (!count($params)) {
$a = array();
return $a;
}
while (PEAR_Downloader_Package::mergeDependencies($params)) {
}
PEAR_Downloader_Package::removeInstalled($params);
if (!count($params)) {
$this->pushError('No valid packages found', PEAR_INSTALLER_FAILED);
$a = array();
return $a;
}
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$err = $this->analyzeDependencies($params);
PEAR::popErrorHandling();
if (!count($params)) {
$this->pushError('No valid packages found', PEAR_INSTALLER_FAILED);
$a = array();
return $a;
}
$ret = array();
$newparams = array();
if (isset($this->_options['pretend'])) {
return $params;
}
foreach ($params as $i => $package) {
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$pf =& $params[$i]->download();
PEAR::staticPopErrorHandling();
if (PEAR::isError($pf)) {
if (!isset($this->_options['soft'])) {
$this->log(1, $pf->getMessage());
$this->log(0, 'Error: cannot download "' . $this->_registry->parsedPackageNameToString($package->getParsedPackage(), true) . '"');
}
continue;
}
$newparams[] =& $params[$i];
$ret[] = array('file' => $pf->getArchiveFile(), 'info' => &$pf, 'pkg' => $pf->getPackage());
}
$this->_downloadedPackages = $ret;
return $newparams;
}