本文整理汇总了PHP中PEAR::staticPushErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR::staticPushErrorHandling方法的具体用法?PHP PEAR::staticPushErrorHandling怎么用?PHP PEAR::staticPushErrorHandling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR
的用法示例。
在下文中一共展示了PEAR::staticPushErrorHandling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enableConversion
/**
*/
public static function enableConversion()
{
$oldErrorReportingLevel = error_reporting(error_reporting() & ~E_STRICT);
PEAR::staticPushErrorHandling(PEAR_ERROR_CALLBACK, array(__CLASS__, 'toException'));
error_reporting($oldErrorReportingLevel);
class_exists('Stagehand_LegacyError_PEARError_Exception');
}
示例2: _checkChannelForStatus
function _checkChannelForStatus($channel, $chan)
{
$rest = new PEAR_REST($this->config);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$a = $rest->downloadHttp('http://' . $channel . '/channel.xml', $chan->lastModified());
PEAR::staticPopErrorHandling();
if (!PEAR::isError($a) && $a) {
$this->ui->outputData('WARNING: channel "' . $channel . '" has ' . 'updated its protocols, use "channel-update ' . $channel . '" to update');
}
}
示例3: testFactoryDAL
/**
* Test that method returns correct object when DataObject exists and false otherwise.
*
* @TODO Add PEAR_Error expectations to simpletest in order to catch them
*/
function testFactoryDAL()
{
// Test when object exists
$dalBanners = OA_Dal::factoryDAL('banners');
$this->assertIsA($dalBanners, 'MAX_Dal_Admin_Banners');
// Test when object doesn't exist
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$dalBanners = OA_Dal::factoryDAL('foo' . rand());
PEAR::staticPopErrorHandling();
$this->assertFalse($dalBanners);
}
示例4: processBucket
/**
* Process an aggregate-type bucket. This is MySQL specific.
*
* @param Plugins_DeliveryLog $oBucket a reference to the using (context) object.
* @param Date $oEnd A PEAR_Date instance, interval_start to process up to (inclusive).
*/
public function processBucket($oBucket, $oEnd)
{
$sTableName = $oBucket->getBucketTableName();
$oMainDbh =& OA_DB_Distributed::singleton();
if (PEAR::isError($oMainDbh)) {
MAX::raiseError($oMainDbh, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
}
OA::debug(' - Processing the ' . $sTableName . ' table for data with operation interval start equal to or before ' . $oEnd->format('%Y-%m-%d %H:%M:%S') . ' ' . $oEnd->tz->getShortName(), PEAR_LOG_INFO);
// Select all rows with interval_start <= previous OI start.
$rsData =& $this->getBucketTableContent($sTableName, $oEnd);
$rowCount = $rsData->getRowCount();
OA::debug(' - ' . $rsData->getRowCount() . ' records found', PEAR_LOG_DEBUG);
if ($rowCount) {
// We can't do bulk inserts with ON DUPLICATE.
$aExecQueries = array();
if ($rsData->fetch()) {
// Get first row
$aRow = $rsData->toArray();
// Prepare INSERT
$sInsert = "INSERT INTO {$sTableName} (" . join(',', array_keys($aRow)) . ") VALUES ";
// Add first row data
$sRow = '(' . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ')';
$sOnDuplicate = ' ON DUPLICATE KEY UPDATE count = count + ' . $aRow['count'];
// Add first insert
$aExecQueries[] = $sInsert . $sRow . $sOnDuplicate;
// Deal with the other rows
while ($rsData->fetch()) {
$aRow = $rsData->toArray();
$sRow = '(' . join(',', array_map(array(&$oMainDbh, 'quote'), $aRow)) . ')';
$sOnDuplicate = ' ON DUPLICATE KEY UPDATE count = count + ' . $aRow['count'];
$aExecQueries[] = $sInsert . $sRow . $sOnDuplicate;
}
}
if (count($aExecQueries)) {
// Try to disable the binlog for the inserts so we don't
// replicate back out over our logged data.
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$result = $oMainDbh->exec('SET SQL_LOG_BIN = 0');
if (PEAR::isError($result)) {
OA::debug('Unable to disable the bin log, proceeding anyway.', PEAR_LOG_WARNING);
}
PEAR::staticPopErrorHandling();
foreach ($aExecQueries as $execQuery) {
$result = $oMainDbh->exec($execQuery);
if (PEAR::isError($result)) {
MAX::raiseError($result, MAX_ERROR_DBFAILURE, PEAR_ERROR_DIE);
}
}
}
}
}
示例5: resetPassword
/**
* Mark a user for password resetting
*
* @param string $user
* @param string $pass1
* @param string $pass2
* @return array
*/
function resetPassword($user, $pass1, $pass2)
{
require_once 'Damblan/Mailer.php';
$errors = array();
$salt = md5(mt_rand(4, 13) . $user . time() . $pass1);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$this->_dbh->query('DELETE FROM lostpassword WHERE handle=?', array($user));
$e = $this->_dbh->query('INSERT INTO lostpassword
(handle, newpassword, salt, requested)
VALUES(?,?,?,NOW())', array($user, md5($pass1), $salt));
PEAR::staticPopErrorHandling();
if (PEAR::isError($e)) {
$errors[] = 'Could not change password: ' . $e->getMessage();
} else {
include_once 'pear-database-user.php';
$info = user::info($user);
$this->_mailer = Damblan_mailer::create(array('To' => array($info['name'] . ' <' . $info['email'] . '>'), 'Reply-To' => array('PEAR QA <' . PEAR_QA_EMAIL . '>'), 'Subject' => '[PEAR-ACCOUNT-PASSWORD] Your password reset request : %username%', 'Body' => 'A request has been made to reset your password for %username%
at pear.php.net.
If you intended to reset the password, please navigate to this page:
https://' . PEAR_CHANNELNAME . '/account/password-confirm-change.php
and follow the instructions. Your password reset code is:
%salt%
If you have received this email by mistake or did not request a
password change, no further action is necessary. Your password
will NOT change until you confirm the change, and it cannot be changed
without the password reset code. Password change requests are automatically
purged after 24 hours.
PEAR Quality Assurance.'), array('username' => $user, 'salt' => $salt));
$this->_mailer->send();
}
return $errors;
}
示例6: _getDepPackageDownloadUrl
/**
* @param array dependency array
* @access private
*/
function _getDepPackageDownloadUrl($dep, $parr)
{
$xsdversion = isset($dep['rel']) ? '1.0' : '2.0';
$curchannel = $this->config->get('default_channel');
if (isset($dep['uri'])) {
$xsdversion = '2.0';
$chan =& $this->_registry->getChannel('__uri');
if (PEAR::isError($chan)) {
return $chan;
}
$version = $this->_registry->packageInfo($dep['name'], 'version', '__uri');
$this->configSet('default_channel', '__uri');
} else {
if (isset($dep['channel'])) {
$remotechannel = $dep['channel'];
} else {
$remotechannel = 'pear.php.net';
}
if (!$this->_registry->channelExists($remotechannel)) {
do {
if ($this->config->get('auto_discover')) {
if ($this->discover($remotechannel)) {
break;
}
}
return PEAR::raiseError('Unknown remote channel: ' . $remotechannel);
} while (false);
}
$chan =& $this->_registry->getChannel($remotechannel);
if (PEAR::isError($chan)) {
return $chan;
}
$version = $this->_registry->packageInfo($dep['name'], 'version', $remotechannel);
$this->configSet('default_channel', $remotechannel);
}
$state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state');
if (isset($parr['state']) && isset($parr['version'])) {
unset($parr['state']);
}
if (isset($dep['uri'])) {
$info =& $this->newDownloaderPackage($this);
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$err = $info->initialize($dep);
PEAR::staticPopErrorHandling();
if (!$err) {
// skip parameters that were missed by preferred_state
return PEAR::raiseError('Cannot initialize dependency');
}
if (PEAR::isError($err)) {
if (!isset($this->_options['soft'])) {
$this->log(0, $err->getMessage());
}
if (is_object($info)) {
$param = $info->getChannel() . '/' . $info->getPackage();
}
return PEAR::raiseError('Package "' . $param . '" is not valid');
}
return $info;
} elseif ($chan->supportsREST($this->config->get('preferred_mirror')) && (($base2 = $chan->getBaseURL('REST1.3', $this->config->get('preferred_mirror'))) || ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))))) {
if ($base2) {
$base = $base2;
$rest =& $this->config->getREST('1.3', $this->_options);
} else {
$rest =& $this->config->getREST('1.0', $this->_options);
}
$url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, $state, $version, $chan->getName());
if (PEAR::isError($url)) {
return $url;
}
if ($parr['channel'] != $curchannel) {
$this->configSet('default_channel', $curchannel);
}
if (!is_array($url)) {
return $url;
}
$url['raw'] = false;
// no checking is necessary for REST
if (!is_array($url['info'])) {
return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen');
}
if (isset($url['info']['required'])) {
if (!class_exists('PEAR_PackageFile_v2')) {
require_once 'PEAR/PackageFile/v2.php';
}
$pf = new PEAR_PackageFile_v2();
$pf->setRawChannel($remotechannel);
} else {
if (!class_exists('PEAR_PackageFile_v1')) {
require_once 'PEAR/PackageFile/v1.php';
}
$pf = new PEAR_PackageFile_v1();
}
$pf->setRawPackage($url['package']);
$pf->setDeps($url['info']);
if ($url['compatible']) {
$pf->setCompatible($url['compatible']);
//.........这里部分代码省略.........
示例7: doDownloadAll
/**
* retrieves a list of avaible Packages from master server
* and downloads them
*
* @access public
* @param string $command the command
* @param array $options the command options before the command
* @param array $params the stuff after the command name
* @return bool true if succesful
* @throw PEAR_Error
*/
function doDownloadAll($command, $options, $params)
{
$savechannel = $this->config->get('default_channel');
$reg =& $this->config->getRegistry();
$channel = isset($options['channel']) ? $options['channel'] : $this->config->get('default_channel');
if (!$reg->channelExists($channel)) {
$this->config->set('default_channel', $savechannel);
return $this->raiseError('Channel "' . $channel . '" does not exist');
}
$this->config->set('default_channel', $channel);
$this->ui->outputData('Using Channel ' . $this->config->get('default_channel'));
$chan = $reg->getChannel($channel);
if (PEAR::isError($chan)) {
return $this->raiseError($chan);
}
if ($chan->supportsREST($this->config->get('preferred_mirror')) && ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror')))) {
$rest =& $this->config->getREST('1.0', array());
$remoteInfo = array_flip($rest->listPackages($base, $channel));
}
if (PEAR::isError($remoteInfo)) {
return $remoteInfo;
}
$cmd =& $this->factory("download");
if (PEAR::isError($cmd)) {
return $cmd;
}
$this->ui->outputData('Using Preferred State of ' . $this->config->get('preferred_state'));
$this->ui->outputData('Gathering release information, please wait...');
/**
* Error handling not necessary, because already done by
* the download command
*/
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$err = $cmd->run('download', array('downloadonly' => true), array_keys($remoteInfo));
PEAR::staticPopErrorHandling();
$this->config->set('default_channel', $savechannel);
if (PEAR::isError($err)) {
$this->ui->outputData($err->getMessage());
}
return true;
}
示例8: Archive_Tar
/**
* Create a PEAR_PackageFile_v* from a compresed Tar or Tgz file.
* @access public
* @param string contents of package.xml file
* @param int package state (one of PEAR_VALIDATE_* constants)
* @return PEAR_PackageFile_v1|PEAR_PackageFile_v2
* @using Archive_Tar to extract the files
* @using fromPackageFile() to load the package after the package.xml
* file is extracted.
*/
function &fromTgzFile($file, $state)
{
if (!class_exists('Archive_Tar')) {
require_once 'Archive/Tar.php';
}
$tar = new Archive_Tar($file);
if ($this->_debug <= 1) {
$tar->pushErrorHandling(PEAR_ERROR_RETURN);
}
$content = $tar->listContent();
if ($this->_debug <= 1) {
$tar->popErrorHandling();
}
if (!is_array($content)) {
if (is_string($file) && strlen($file < 255) && (!file_exists($file) || !@is_file($file))) {
$ret = PEAR::raiseError("could not open file \"{$file}\"");
return $ret;
}
$file = realpath($file);
$ret = PEAR::raiseError("Could not get contents of package \"{$file}\"" . '. Invalid tgz file.');
return $ret;
} else {
if (!count($content) && !@is_file($file)) {
$ret = PEAR::raiseError("could not open file \"{$file}\"");
return $ret;
}
}
$xml = null;
$origfile = $file;
foreach ($content as $file) {
$name = $file['filename'];
if ($name == 'package2.xml') {
// allow a .tgz to distribute both versions
$xml = $name;
break;
}
if ($name == 'package.xml') {
$xml = $name;
break;
} elseif (ereg('package.xml$', $name, $match)) {
$xml = $name;
break;
}
}
if ($this->_tmpdir) {
$tmpdir = $this->_tmpdir;
} else {
$tmpdir = System::mkTemp(array('-d', 'pear'));
PEAR_PackageFile::addTempFile($tmpdir);
}
$this->_extractErrors();
PEAR::staticPushErrorHandling(PEAR_ERROR_CALLBACK, array($this, '_extractErrors'));
if (!$xml || !$tar->extractList(array($xml), $tmpdir)) {
$extra = implode("\n", $this->_extractErrors());
if ($extra) {
$extra = ' ' . $extra;
}
PEAR::staticPopErrorHandling();
$ret = PEAR::raiseError('could not extract the package.xml file from "' . $origfile . '"' . $extra);
return $ret;
}
PEAR::staticPopErrorHandling();
$ret =& PEAR_PackageFile::fromPackageFile("{$tmpdir}/{$xml}", $state, $origfile);
return $ret;
}
示例9: uninstall
/**
* Uninstall a package
*
* This method removes all files installed by the application, and then
* removes any empty directories.
* @param string package name
* @param array Command-line options. Possibilities include:
*
* - installroot: base installation dir, if not the default
* - nodeps: do not process dependencies of other packages to ensure
* uninstallation does not break things
*/
function uninstall($package, $options = array())
{
if (isset($options['installroot'])) {
$this->config->setInstallRoot($options['installroot']);
$this->installroot = '';
} else {
$this->config->setInstallRoot('');
$this->installroot = '';
}
$this->_registry =& $this->config->getRegistry();
if (is_object($package)) {
$channel = $package->getChannel();
$pkg = $package;
$package = $pkg->getPackage();
} else {
$pkg = false;
$info = $this->_registry->parsePackageName($package, $this->config->get('default_channel'));
$channel = $info['channel'];
$package = $info['package'];
}
$savechannel = $this->config->get('default_channel');
$this->configSet('default_channel', $channel);
if (!is_object($pkg)) {
$pkg = $this->_registry->getPackage($package, $channel);
}
if (!$pkg) {
$this->configSet('default_channel', $savechannel);
return $this->raiseError($this->_registry->parsedPackageNameToString(array('channel' => $channel, 'package' => $package), true) . ' not installed');
}
if ($pkg->getInstalledBinary()) {
// this is just an alias for a binary package
return $this->_registry->deletePackage($package, $channel);
}
$filelist = $pkg->getFilelist();
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
$depchecker =& new PEAR_Dependency2($this->config, $options, array('channel' => $channel, 'package' => $package), PEAR_VALIDATE_UNINSTALLING);
$e = $depchecker->validatePackageUninstall($this);
PEAR::staticPopErrorHandling();
if (PEAR::isError($e)) {
if (!isset($options['ignore-errors'])) {
return $this->raiseError($e);
} else {
if (!isset($options['soft'])) {
$this->log(0, 'WARNING: ' . $e->getMessage());
}
}
} elseif (is_array($e)) {
if (!isset($options['soft'])) {
$this->log(0, $e[0]);
}
}
// {{{ Delete the files
$this->startFileTransaction();
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
if (PEAR::isError($err = $this->_deletePackageFiles($package, $channel))) {
PEAR::popErrorHandling();
$this->rollbackFileTransaction();
$this->configSet('default_channel', $savechannel);
if (!isset($options['ignore-errors'])) {
return $this->raiseError($err);
} else {
if (!isset($options['soft'])) {
$this->log(0, 'WARNING: ' . $err->getMessage());
}
}
} else {
PEAR::popErrorHandling();
}
if (!$this->commitFileTransaction()) {
$this->rollbackFileTransaction();
if (!isset($options['ignore-errors'])) {
return $this->raiseError("uninstall failed");
} elseif (!isset($options['soft'])) {
$this->log(0, 'WARNING: uninstall failed');
}
} else {
$this->startFileTransaction();
if ($dirtree = $pkg->getDirTree()) {
// attempt to delete empty directories
uksort($dirtree, array($this, '_sortDirs'));
foreach ($dirtree as $dir => $notused) {
$this->addFileOperation('rmdir', array($dir));
}
} else {
$this->configSet('default_channel', $savechannel);
//.........这里部分代码省略.........
示例10: package
function package($pkgfile = null, $compress = true, $pkg2 = null)
{
// {{{ validate supplied package.xml file
if (empty($pkgfile)) {
$pkgfile = 'package.xml';
}
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$pkg = new PEAR_PackageFile($this->config, $this->debug);
$pf =& $pkg->fromPackageFile($pkgfile, PEAR_VALIDATE_NORMAL);
$main =& $pf;
PEAR::staticPopErrorHandling();
if (PEAR::isError($pf)) {
if (is_array($pf->getUserInfo())) {
foreach ($pf->getUserInfo() as $error) {
$this->log(0, 'Error: ' . $error['message']);
}
}
$this->log(0, $pf->getMessage());
return $this->raiseError("Cannot package, errors in package file");
}
foreach ($pf->getValidationWarnings() as $warning) {
$this->log(1, 'Warning: ' . $warning['message']);
}
// }}}
if ($pkg2) {
$this->log(0, 'Attempting to process the second package file');
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$pf2 =& $pkg->fromPackageFile($pkg2, PEAR_VALIDATE_NORMAL);
PEAR::staticPopErrorHandling();
if (PEAR::isError($pf2)) {
if (is_array($pf2->getUserInfo())) {
foreach ($pf2->getUserInfo() as $error) {
$this->log(0, 'Error: ' . $error['message']);
}
}
$this->log(0, $pf2->getMessage());
return $this->raiseError("Cannot package, errors in second package file");
}
foreach ($pf2->getValidationWarnings() as $warning) {
$this->log(1, 'Warning: ' . $warning['message']);
}
if ($pf2->getPackagexmlVersion() == '2.0' || $pf2->getPackagexmlVersion() == '2.1') {
$main =& $pf2;
$other =& $pf;
} else {
$main =& $pf;
$other =& $pf2;
}
if ($main->getPackagexmlVersion() != '2.0' && $main->getPackagexmlVersion() != '2.1') {
return PEAR::raiseError('Error: cannot package two package.xml version 1.0, can ' . 'only package together a package.xml 1.0 and package.xml 2.0');
}
if ($other->getPackagexmlVersion() != '1.0') {
return PEAR::raiseError('Error: cannot package two package.xml version 2.0, can ' . 'only package together a package.xml 1.0 and package.xml 2.0');
}
}
$main->setLogger($this);
if (!$main->validate(PEAR_VALIDATE_PACKAGING)) {
foreach ($main->getValidationWarnings() as $warning) {
$this->log(0, 'Error: ' . $warning['message']);
}
return $this->raiseError("Cannot package, errors in package");
}
foreach ($main->getValidationWarnings() as $warning) {
$this->log(1, 'Warning: ' . $warning['message']);
}
if ($pkg2) {
$other->setLogger($this);
$a = false;
if (!$other->validate(PEAR_VALIDATE_NORMAL) || ($a = !$main->isEquivalent($other))) {
foreach ($other->getValidationWarnings() as $warning) {
$this->log(0, 'Error: ' . $warning['message']);
}
foreach ($main->getValidationWarnings() as $warning) {
$this->log(0, 'Error: ' . $warning['message']);
}
if ($a) {
return $this->raiseError('The two package.xml files are not equivalent!');
}
return $this->raiseError("Cannot package, errors in package");
}
foreach ($other->getValidationWarnings() as $warning) {
$this->log(1, 'Warning: ' . $warning['message']);
}
$gen =& $main->getDefaultGenerator();
$tgzfile = $gen->toTgz2($this, $other, $compress);
if (PEAR::isError($tgzfile)) {
return $tgzfile;
}
$dest_package = basename($tgzfile);
$pkgdir = dirname($pkgfile);
// TAR the Package -------------------------------------------
$this->log(1, "Package {$dest_package} done");
if (file_exists("{$pkgdir}/CVS/Root")) {
$cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pf->getVersion());
$cvstag = "RELEASE_{$cvsversion}";
$this->log(1, 'Tag the released code with "pear cvstag ' . $main->getPackageFile() . '"');
$this->log(1, "(or set the CVS tag {$cvstag} by hand)");
} elseif (file_exists("{$pkgdir}/.svn")) {
$svnversion = preg_replace('/[^a-z0-9]/i', '.', $pf->getVersion());
$svntag = $pf->getName() . "-{$svnversion}";
//.........这里部分代码省略.........
示例11: doRunTests
//.........这里部分代码省略.........
if (isset($_ENV['TEST_PHP_INCLUDE_PATH'])) {
$ini_settings .= " -d include_path={$_ENV['TEST_PHP_INCLUDE_PATH']}";
}
if ($ini_settings) {
$this->ui->outputData('Using INI settings: "' . $ini_settings . '"');
}
$skipped = $passed = $failed = array();
$tests_count = count($tests);
$this->ui->outputData('Running ' . $tests_count . ' tests', $command);
$start = time();
if (isset($options['realtimelog']) && file_exists('run-tests.log')) {
unlink('run-tests.log');
}
if (isset($options['tapoutput'])) {
$tap = '1..' . $tests_count . "\n";
}
require_once 'PEAR/RunTest.php';
$run = new PEAR_RunTest($log, $options);
$run->tests_count = $tests_count;
if (isset($options['coverage']) && extension_loaded('xdebug')) {
$run->xdebug_loaded = true;
} else {
$run->xdebug_loaded = false;
}
$j = $i = 1;
foreach ($tests as $t) {
if (isset($options['realtimelog'])) {
$fp = @fopen('run-tests.log', 'a');
if ($fp) {
fwrite($fp, "Running test [{$i} / {$tests_count}] {$t}...");
fclose($fp);
}
}
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
if (isset($options['phpunit'])) {
$result = $run->runPHPUnit($t, $ini_settings);
} else {
$result = $run->run($t, $ini_settings, $j);
}
PEAR::staticPopErrorHandling();
if (PEAR::isError($result)) {
$this->ui->log($result->getMessage());
continue;
}
if (isset($options['tapoutput'])) {
$tap .= $result[0] . ' ' . $i . $result[1] . "\n";
continue;
}
if (isset($options['realtimelog'])) {
$fp = @fopen('run-tests.log', 'a');
if ($fp) {
fwrite($fp, "{$result}\n");
fclose($fp);
}
}
if ($result == 'FAILED') {
$failed[] = $t;
}
if ($result == 'PASSED') {
$passed[] = $t;
}
if ($result == 'SKIPPED') {
$skipped[] = $t;
}
$j++;
}
示例12: executeQuery
/**
* Executes a query.
*
* @param string $query
* @param MDB2_Statement_Common $sth
* @return MDB2_Result_Common|integer
* @throws PIECE_ORM_ERROR_CANNOT_INVOKE
* @throws PIECE_ORM_ERROR_UNEXPECTED_VALUE
* @throws PIECE_ORM_ERROR_CONSTRAINT
*/
function &execute($query, $sth)
{
$dbh =& $this->_mapper->getConnection();
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
if (!$this->_isManip) {
$result =& $dbh->query($query);
} else {
if (is_null($sth)) {
$result = $dbh->exec($query);
} else {
if (!is_subclass_of($sth, 'MDB2_Statement_Common')) {
PEAR::staticPopErrorHandling();
Piece_ORM_Error::push(PIECE_ORM_ERROR_UNEXPECTED_VALUE, 'An unexpected value detected. executeQuery() with a prepared statement can only receive a MDB2_Statement_Common object.');
$return = null;
return $return;
}
$result = $sth->execute();
}
}
PEAR::staticPopErrorHandling();
$this->_mapper->setLastQuery($dbh->last_query);
if (MDB2::isError($result)) {
if ($result->getCode() == MDB2_ERROR_CONSTRAINT) {
$code = PIECE_ORM_ERROR_CONSTRAINT;
} else {
$code = PIECE_ORM_ERROR_CANNOT_INVOKE;
}
Piece_ORM_Error::pushPEARError($result, $code, "Failed to invoke MDB2_Driver_{$dbh->phptype}::query() for any reasons.");
$return = null;
return $return;
}
return $result;
}
示例13: VALUES
ts1,
private,
visitor_ip
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, "Open", NOW(), ?, INET_ATON(?))
')->execute(array($package_name, $_POST['in']['bug_type'], $_POST['in']['email'], $_POST['in']['sdesc'], $fdesc, $_POST['in']['php_version'], $_POST['in']['php_os'], bugs_get_hash($_POST['in']['passwd']), $_POST['in']['reporter_name'], $_POST['in']['private'], $_SERVER['REMOTE_ADDR']));
if (PEAR::isError($res)) {
echo "<pre>";
var_dump($_POST['in'], $fdesc, $package_name);
die($res->getMessage());
}
$cid = $dbh->lastInsertId();
$redirectToPatchAdd = false;
if (!empty($_POST['in']['patchname']) && $_POST['in']['patchname']) {
require_once "{$ROOT_DIR}/include/classes/bug_patchtracker.php";
$tracker = new Bug_Patchtracker();
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$patchrevision = $tracker->attach($cid, 'patchfile', $_POST['in']['patchname'], $_POST['in']['handle'], array());
PEAR::staticPopErrorHandling();
if (PEAR::isError($patchrevision)) {
$redirectToPatchAdd = true;
}
}
if (empty($_POST['in']['handle'])) {
$mailfrom = spam_protect($_POST['in']['email'], 'text');
} else {
$mailfrom = $_POST['in']['handle'];
}
$report = <<<REPORT
From: {$mailfrom}
Operating system: {$_POST['in']['php_os']}
PHP version: {$_POST['in']['php_version']}
示例14: doRunTests
function doRunTests($command, $options, $params)
{
require_once 'PEAR/Common.php';
require_once 'PEAR/RunTest.php';
require_once 'System.php';
$log = new PEAR_Common();
$log->ui =& $this->ui;
// slightly hacky, but it will work
$run = new PEAR_RunTest($log, $options);
$tests = array();
if (isset($options['recur'])) {
$depth = 4;
} else {
$depth = 1;
}
if (!count($params)) {
$params[] = '.';
}
if (isset($options['package'])) {
$oldparams = $params;
$params = array();
$reg =& $this->config->getRegistry();
foreach ($oldparams as $param) {
$pname = $reg->parsePackageName($param, $this->config->get('default_channel'));
if (PEAR::isError($pname)) {
return $this->raiseError($pname);
}
$package =& $reg->getPackage($pname['package'], $pname['channel']);
if (!$package) {
return PEAR::raiseError('Unknown package "' . $reg->parsedPackageNameToString($pname) . '"');
}
$filelist = $package->getFilelist();
foreach ($filelist as $name => $atts) {
if (isset($atts['role']) && $atts['role'] != 'test') {
continue;
}
if (!preg_match('/\\.phpt$/', $name)) {
continue;
}
$params[] = $atts['installed_as'];
}
}
}
foreach ($params as $p) {
if (is_dir($p)) {
$dir = System::find(array($p, '-type', 'f', '-maxdepth', $depth, '-name', '*.phpt'));
$tests = array_merge($tests, $dir);
} else {
if (!@file_exists($p)) {
if (!preg_match('/\\.phpt$/', $p)) {
$p .= '.phpt';
}
$dir = System::find(array(dirname($p), '-type', 'f', '-maxdepth', $depth, '-name', $p));
$tests = array_merge($tests, $dir);
} else {
$tests[] = $p;
}
}
}
$ini_settings = '';
if (isset($options['ini'])) {
$ini_settings .= $options['ini'];
}
if (isset($_ENV['TEST_PHP_INCLUDE_PATH'])) {
$ini_settings .= " -d include_path={$_ENV['TEST_PHP_INCLUDE_PATH']}";
}
if ($ini_settings) {
$this->ui->outputData('Using INI settings: "' . $ini_settings . '"');
}
$skipped = $passed = $failed = array();
$this->ui->outputData('Running ' . count($tests) . ' tests', $command);
$start = time();
if (isset($options['realtimelog'])) {
@unlink('run-tests.log');
}
foreach ($tests as $t) {
if (isset($options['realtimelog'])) {
$fp = @fopen('run-tests.log', 'a');
if ($fp) {
fwrite($fp, "Running test {$t}...");
fclose($fp);
}
}
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
$result = $run->run($t, $ini_settings);
PEAR::staticPopErrorHandling();
if (PEAR::isError($result)) {
$this->ui->log(0, $result->getMessage());
continue;
}
if (OS_WINDOWS) {
for ($i = 0; $i < 2000; $i++) {
$i = $i;
// delay - race conditions on windows
}
}
if (isset($options['realtimelog'])) {
$fp = @fopen('run-tests.log', 'a');
if ($fp) {
fwrite($fp, "{$result}\n");
//.........这里部分代码省略.........
示例15: _initTemplate
/**
* Initialize a TemplateObject
*
* @param string $file filename of the template file
*
* @return object Object of HTML/IT - Template - Class
*/
function _initTemplate($file)
{
// Errors here can not be displayed using the UI
PEAR::staticPushErrorHandling(PEAR_ERROR_DIE);
$tpl_dir = $this->config->get('data_dir') . DIRECTORY_SEPARATOR . 'PEAR_Frontend_Web' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'templates';
if (!file_exists($tpl_dir) || !is_readable($tpl_dir)) {
PEAR::raiseError('<b>Error:</b> the template directory <i>(' . $tpl_dir . ')</i> is not a directory, or not readable. Make sure the \'data_dir\' of your config file <i>(' . $this->config->get('data_dir') . ')</i> points to the correct location !');
}
$tpl = new HTML_Template_IT($tpl_dir);
$tpl->loadTemplateFile($file);
$tpl->setVariable("InstallerURL", $_SERVER["PHP_SELF"]);
PEAR::staticPopErrorHandling();
// reset error handling
return $tpl;
}