本文整理汇总了PHP中PEAR::pushErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR::pushErrorHandling方法的具体用法?PHP PEAR::pushErrorHandling怎么用?PHP PEAR::pushErrorHandling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR
的用法示例。
在下文中一共展示了PEAR::pushErrorHandling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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();
}
示例3: 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;
}
示例4: 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;
}
示例5: 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();
}
示例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:
/**
* 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;
}
示例8: 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;
}
示例9: 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));
}
示例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: __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;
}
}
}
}
示例12: 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;
}
示例13: add
/**
* Add a new user account
*
* During most of this method's operation, PEAR's error handling
* is set to PEAR_ERROR_RETURN.
*
* But, during the DB_storage::set() phase error handling is set to
* PEAR_ERROR_CALLBACK the report_warning() function. So, if an
* error happens a warning message is printed AND the incomplete
* user information is removed.
*
* @param array $data Information about the user
*
* @return mixed true if there are no problems, false if sending the
* email failed, 'set error' if DB_storage::set() failed
* or an array of error messages for other problems
*
* @access public
*/
function add(&$data)
{
global $dbh;
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$errors = array();
$required = array('handle' => 'Username', 'firstname' => 'First Name', 'lastname' => 'Last Name', 'email' => 'Email address', 'purpose' => 'Intended purpose');
$name = $data['firstname'] . " " . $data['lastname'];
foreach ($required as $field => $desc) {
if (empty($data[$field])) {
$data['jumpto'] = $field;
$errors[] = 'Please enter ' . $desc;
}
}
if (!preg_match(PEAR_COMMON_USER_NAME_REGEX, $data['handle'])) {
$errors[] = 'Username must start with a letter and contain' . ' only letters and digits';
}
// Basic name validation
// First- and lastname must be longer than 1 character
if (strlen($data['firstname']) == 1) {
$errors[] = 'Your firstname appears to be too short.';
}
if (strlen($data['lastname']) == 1) {
$errors[] = 'Your lastname appears to be too short.';
}
// Firstname and lastname must start with an uppercase letter
if (!preg_match("/^[A-Z]/", $data['firstname'])) {
$errors[] = 'Your firstname must begin with an uppercase letter';
}
if (!preg_match("/^[A-Z]/", $data['lastname'])) {
$errors[] = 'Your lastname must begin with an uppercase letter';
}
// No names with only uppercase letters
if ($data['firstname'] === strtoupper($data['firstname'])) {
$errors[] = 'Your firstname must not consist of only uppercase letters.';
}
if ($data['lastname'] === strtoupper($data['lastname'])) {
$errors[] = 'Your lastname must not consist of only uppercase letters.';
}
if ($data['password'] != $data['password2']) {
$data['password'] = $data['password2'] = "";
$data['jumpto'] = "password";
$errors[] = 'Passwords did not match';
}
if (!$data['password']) {
$data['jumpto'] = "password";
$errors[] = 'Empty passwords not allowed';
}
$handle = strtolower($data['handle']);
$obj =& new PEAR_User($dbh, $handle);
if (isset($obj->created)) {
$data['jumpto'] = "handle";
$errors[] = 'Sorry, that username is already taken';
}
if ($errors) {
$data['display_form'] = true;
return $errors;
}
$err = $obj->insert($handle);
if (DB::isError($err)) {
if ($err->getCode() == DB_ERROR_CONSTRAINT) {
$data['display_form'] = true;
$data['jumpto'] = 'handle';
$errors[] = 'Sorry, that username is already taken';
} else {
$data['display_form'] = false;
$errors[] = $err;
}
return $errors;
}
$data['display_form'] = false;
$md5pw = md5($data['password']);
$showemail = @(bool) $data['showemail'];
// hack to temporarily embed the "purpose" in
// the user's "userinfo" column
$userinfo = serialize(array($data['purpose'], $data['moreinfo']));
$set_vars = array('name' => $name, 'email' => $data['email'], 'homepage' => $data['homepage'], 'showemail' => $showemail, 'password' => $md5pw, 'registered' => 0, 'userinfo' => $userinfo);
PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, 'report_warning');
foreach ($set_vars as $var => $value) {
$err = $obj->set($var, $value);
if (PEAR::isError($err)) {
user::remove($data['handle']);
//.........这里部分代码省略.........
示例14: _fromString
/**
*
* @param string|array pass in an array of format
* array(
* 'package' => 'pname',
* ['channel' => 'channame',]
* ['version' => 'version',]
* ['state' => 'state',])
* or a string of format [channame/]pname[-version|-state]
*/
function _fromString($param)
{
$options = $this->_downloader->getOptions();
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$pname = $this->_registry->parsePackageName($param, $this->_config->get('default_channel'));
PEAR::popErrorHandling();
if (PEAR::isError($pname)) {
if ($pname->getCode() == 'invalid') {
$this->_valid = false;
return false;
}
if ($pname->getCode() == 'channel') {
$parsed = $pname->getUserInfo();
if ($this->_downloader->discover($parsed['channel'])) {
if ($this->_config->get('auto_discover')) {
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$pname = $this->_registry->parsePackageName($param, $this->_config->get('default_channel'));
PEAR::popErrorHandling();
} else {
if (!isset($options['soft'])) {
$this->_downloader->log(0, 'Channel "' . $parsed['channel'] . '" is not initialized, use ' . '"pear channel-discover ' . $parsed['channel'] . '" to initialize' . 'or pear config-set auto_discover 1');
}
}
}
if (PEAR::isError($pname)) {
if (!isset($options['soft'])) {
$this->_downloader->log(0, $pname->getMessage());
}
if (is_array($param)) {
$param = $this->_registry->parsedPackageNameToString($param);
}
$err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
$this->_valid = false;
return $err;
}
} else {
if (!isset($options['soft'])) {
$this->_downloader->log(0, $pname->getMessage());
}
$err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
$this->_valid = false;
return $err;
}
}
if (!isset($this->_type)) {
$this->_type = 'xmlrpc';
}
$this->_parsedname = $pname;
if (isset($pname['state'])) {
$this->_explicitState = $pname['state'];
} else {
$this->_explicitState = false;
}
if (isset($pname['group'])) {
$this->_explicitGroup = true;
} else {
$this->_explicitGroup = false;
}
$info = $this->_downloader->_getPackageDownloadUrl($pname);
if (PEAR::isError($info)) {
if ($pname['channel'] == 'pear.php.net') {
// try pecl
$pname['channel'] = 'pecl.php.net';
if ($test = $this->_downloader->_getPackageDownloadUrl($pname)) {
if (!PEAR::isError($test)) {
$info = PEAR::raiseError($info->getMessage() . ' - package ' . $this->_registry->parsedPackageNameToString($pname, true) . ' can be installed with "pecl install ' . $pname['package'] . '"');
}
}
}
return $info;
}
$this->_rawpackagefile = $info['raw'];
$ret = $this->_analyzeDownloadURL($info, $param, $pname);
if (PEAR::isError($ret)) {
return $ret;
}
if ($ret) {
$this->_downloadURL = $ret;
return $this->_valid = (bool) $ret;
}
}
示例15: test_factory
/**
* Tests that the MDB2::factory() method correctly connects to a
* database.
*/
function test_factory()
{
$db =& MDB2::factory($this->dsn);
$this->assertTrue(MDB2::isConnection($db), 'factory');
// Suppress handling of PEAR errors while preparing the
// next test case database connection
PEAR::pushErrorHandling(null);
$db =& MDB2::factory(null);
PEAR::popErrorHandling();
$this->assertFalse(MDB2::isConnection($db), 'factory');
}