本文整理汇总了PHP中wfSuppressWarnings函数的典型用法代码示例。如果您正苦于以下问题:PHP wfSuppressWarnings函数的具体用法?PHP wfSuppressWarnings怎么用?PHP wfSuppressWarnings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfSuppressWarnings函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkIfToolExists
/**
* Check if a tool exist
*
* @param string $path path to the tool
* @return bool
*/
protected function checkIfToolExists($path)
{
wfSuppressWarnings();
$result = file_exists($path);
wfRestoreWarnings();
return $result;
}
示例2: getBackgroundColor
public function getBackgroundColor($subset, $total, $fuzzy = false)
{
wfSuppressWarnings();
$v = round(255 * $subset / $total);
wfRestoreWarnings();
if ($fuzzy) {
// Weigh fuzzy with factor 20.
$v = $v * 20;
if ($v > 255) {
$v = 255;
}
$v = 255 - $v;
}
if ($v < 128) {
// Red to Yellow
$red = 'FF';
$green = sprintf('%02X', 2 * $v);
} else {
// Yellow to Green
$red = sprintf('%02X', 2 * (255 - $v));
$green = 'FF';
}
$blue = '00';
return $red . $green . $blue;
}
示例3: get
/**
* @param $key
* @return Status
*/
function get($key)
{
$hashes = array();
foreach ($this->hostNames as $hostName) {
$hashes[$hostName] = md5($hostName . $key);
}
asort($hashes);
$errno = $errstr = '';
foreach ($hashes as $hostName => $hash) {
if (isset($this->conns[$hostName])) {
$this->refCounts[$hostName]++;
return Status::newGood($this->conns[$hostName]);
}
$parts = explode(':', $hostName, 2);
if (count($parts) < 2) {
$parts[] = 7531;
}
wfProfileIn(__METHOD__ . '-connect');
wfSuppressWarnings();
$conn = fsockopen($parts[0], $parts[1], $errno, $errstr, $this->timeout);
wfRestoreWarnings();
wfProfileOut(__METHOD__ . '-connect');
if ($conn) {
break;
}
}
if (!$conn) {
return Status::newFatal('poolcounter-connection-error', $errstr);
}
wfDebug("Connected to pool counter server: {$hostName}\n");
$this->conns[$hostName] = $conn;
$this->refCounts[$hostName] = 1;
return Status::newGood($conn);
}
示例4: useMWlock
private function useMWlock()
{
global $wgReadOnlyFile, $wgContLang;
wfSuppressWarnings();
$fp = fopen($wgReadOnlyFile, 'w');
wfRestoreWarnings();
// wikia change start
global $wgUser, $wgCityId;
$reason = $this->reason . "\nby " . $wgUser->getName() . ' at ' . $wgContLang->timeanddate(wfTimestampNow());
if (!WikiFactory::setVarByName('wgReadOnly', $wgCityId, $reason) || !WikiFactory::clearCache($wgCityId)) {
return Status::newFatal('lockdb-wikifactory-error');
}
// wikia change end
if (false === $fp) {
# This used to show a file not found error, but the likeliest reason for fopen()
# to fail at this point is insufficient permission to write to the file...good old
# is_writable() is plain wrong in some cases, it seems...
return false;
}
fwrite($fp, $data['Reason']);
$timestamp = wfTimestampNow();
fwrite($fp, "\n<p>" . wfMsgExt('lockedbyandtime', array('content', 'parsemag'), $this->getUser()->getName(), $wgContLang->date($timestamp), $wgContLang->time($timestamp)) . "</p>\n");
fclose($fp);
return true;
}
示例5: cleanupDeletedBatch
/**
* Delete files in the deleted directory if they are not referenced in the
* filearchive table. This needs to be done in the repo because it needs to
* interleave database locks with file operations, which is potentially a
* remote operation.
*
* @param $storageKeys array
*
* @return FileRepoStatus
*/
function cleanupDeletedBatch($storageKeys)
{
$root = $this->getZonePath('deleted');
$dbw = $this->getMasterDB();
$status = $this->newGood();
$storageKeys = array_unique($storageKeys);
foreach ($storageKeys as $key) {
$hashPath = $this->getDeletedHashPath($key);
$path = "{$root}/{$hashPath}{$key}";
$dbw->begin();
$inuse = $dbw->selectField('filearchive', '1', array('fa_storage_group' => 'deleted', 'fa_storage_key' => $key), __METHOD__, array('FOR UPDATE'));
if (!$inuse) {
$sha1 = self::getHashFromKey($key);
$ext = substr($key, strcspn($key, '.') + 1);
$ext = File::normalizeExtension($ext);
$inuse = $dbw->selectField('oldimage', '1', array('oi_sha1' => $sha1, 'oi_archive_name ' . $dbw->buildLike($dbw->anyString(), ".{$ext}"), $dbw->bitAnd('oi_deleted', File::DELETED_FILE) => File::DELETED_FILE), __METHOD__, array('FOR UPDATE'));
}
if (!$inuse) {
wfDebug(__METHOD__ . ": deleting {$key}\n");
wfSuppressWarnings();
$unlink = unlink($path);
wfRestoreWarnings();
if (!$unlink) {
$status->error('undelete-cleanup-error', $path);
$status->failCount++;
}
} else {
wfDebug(__METHOD__ . ": {$key} still in use\n");
$status->successCount++;
}
$dbw->commit();
}
return $status;
}
示例6: stream
/**
* Stream a file to the browser, adding all the headings and fun stuff.
* Headers sent include: Content-type, Content-Length, Last-Modified,
* and Content-Disposition.
*
* @param string $fname Full name and path of the file to stream
* @param array $headers Any additional headers to send
* @param bool $sendErrors Send error messages if errors occur (like 404)
* @throws MWException
* @return bool Success
*/
public static function stream($fname, $headers = array(), $sendErrors = true)
{
wfProfileIn(__METHOD__);
if (FileBackend::isStoragePath($fname)) {
// sanity
wfProfileOut(__METHOD__);
throw new MWException(__FUNCTION__ . " given storage path '{$fname}'.");
}
wfSuppressWarnings();
$stat = stat($fname);
wfRestoreWarnings();
$res = self::prepareForStream($fname, $stat, $headers, $sendErrors);
if ($res == self::NOT_MODIFIED) {
$ok = true;
// use client cache
} elseif ($res == self::READY_STREAM) {
wfProfileIn(__METHOD__ . '-send');
$ok = readfile($fname);
wfProfileOut(__METHOD__ . '-send');
} else {
$ok = false;
// failed
}
wfProfileOut(__METHOD__);
return $ok;
}
示例7: parseToDOM
/**
* Parses given HTML into DOM tree (using XML/HTML parser)
*/
private function parseToDOM($html, $parseAsXML = true)
{
wfProfileIn(__METHOD__);
$ret = false;
wfSuppressWarnings();
if ($parseAsXML) {
// form proper XML string
$html = str_replace('&', '&', $html);
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><body>{$html}</body>";
// try to parse as XML
if ($this->dom->loadXML($xml)) {
// parsing successful
$ret = $this->dom->getElementsByTagName('body')->item(0);
} else {
$this->handleParseErrors(__METHOD__);
}
} else {
// form proper HTML string
$html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>{$html}</body></html>";
// try to parse as HTML
if ($this->dom->loadHTML($html)) {
$ret = $this->dom->getElementsByTagName('body')->item(0);
}
}
wfRestoreWarnings();
wfProfileOut(__METHOD__);
// return <body> node or false if XML parsing failed
return $ret;
}
示例8: dataDirOKmaybeCreate
private static function dataDirOKmaybeCreate($dir, $create = false)
{
if (!is_dir($dir)) {
if (!is_writable(dirname($dir))) {
$webserverGroup = Installer::maybeGetWebserverPrimaryGroup();
if ($webserverGroup !== null) {
return Status::newFatal('config-sqlite-parent-unwritable-group', $dir, dirname($dir), basename($dir), $webserverGroup);
} else {
return Status::newFatal('config-sqlite-parent-unwritable-nogroup', $dir, dirname($dir), basename($dir));
}
}
# Called early on in the installer, later we just want to sanity check
# if it's still writable
if ($create) {
wfSuppressWarnings();
$ok = wfMkdirParents($dir, 0700);
wfRestoreWarnings();
if (!$ok) {
return Status::newFatal('config-sqlite-mkdir-error', $dir);
}
# Put a .htaccess file in in case the user didn't take our advice
file_put_contents("{$dir}/.htaccess", "Deny from all\n");
}
}
if (!is_writable($dir)) {
return Status::newFatal('config-sqlite-dir-unwritable', $dir);
}
# We haven't blown up yet, fall through
return Status::newGood();
}
示例9: __construct
/**
* Constructor
*
* Creates an SVGReader drawing from the source provided
* @param $source String: URI from which to read
*/
function __construct($source)
{
global $wgSVGMetadataCutoff;
$this->reader = new XMLReader();
// Don't use $file->getSize() since file object passed to SVGHandler::getMetadata is bogus.
$size = filesize($source);
if ($size === false) {
throw new MWException("Error getting filesize of SVG.");
}
if ($size > $wgSVGMetadataCutoff) {
$this->debug("SVG is {$size} bytes, which is bigger than {$wgSVGMetadataCutoff}. Truncating.");
$contents = file_get_contents($source, false, null, -1, $wgSVGMetadataCutoff);
if ($contents === false) {
throw new MWException('Error reading SVG file.');
}
$this->reader->XML($contents, null, LIBXML_NOERROR | LIBXML_NOWARNING);
} else {
$this->reader->open($source, null, LIBXML_NOERROR | LIBXML_NOWARNING);
}
$this->metadata['width'] = self::DEFAULT_WIDTH;
$this->metadata['height'] = self::DEFAULT_HEIGHT;
// Because we cut off the end of the svg making an invalid one. Complicated
// try catch thing to make sure warnings get restored. Seems like there should
// be a better way.
wfSuppressWarnings();
try {
$this->read();
} catch (Exception $e) {
wfRestoreWarnings();
throw $e;
}
wfRestoreWarnings();
}
示例10: execute
function execute()
{
global $IP, $wgTitle;
$siteName = isset($this->mArgs[0]) ? $this->mArgs[0] : "Don't care";
// Will not be set if used with --env-checks
$adminName = isset($this->mArgs[1]) ? $this->mArgs[1] : null;
$wgTitle = Title::newFromText('Installer script');
$dbpassfile = $this->getOption('dbpassfile', false);
if ($dbpassfile !== false) {
wfSuppressWarnings();
$dbpass = file_get_contents($dbpassfile);
wfRestoreWarnings();
if ($dbpass === false) {
$this->error("Couldn't open {$dbpassfile}", true);
}
$this->mOptions['dbpass'] = trim($dbpass, "\r\n");
}
$installer = InstallerOverrides::getCliInstaller($siteName, $adminName, $this->mOptions);
$status = $installer->doEnvironmentChecks();
if ($status->isGood()) {
$installer->showMessage('config-env-good');
} else {
$installer->showStatusMessage($status);
return;
}
if (!$this->hasOption('env-checks')) {
$installer->execute();
$installer->writeConfigurationFile($this->getOption('confpath', $IP));
}
}
示例11: initialize
public function initialize()
{
$dbr = wfGetDB(DB_MASTER);
$res = $dbr->select('categorylinks', array('cl_to', 'COUNT(*) AS count'), array(), __METHOD__, array('GROUP BY' => 'cl_to', 'ORDER BY' => 'count DESC', 'LIMIT' => $this->limit));
wfSuppressWarnings();
// prevent PHP from bitching about strtotime()
foreach ($res as $row) {
$tag_name = Title::makeTitle(NS_CATEGORY, $row->cl_to);
$tag_text = $tag_name->getText();
if (strtotime($tag_text) == '') {
// don't want dates to show up
if ($row->count > $this->tags_highest_count) {
$this->tags_highest_count = $row->count;
}
$this->tags[$tag_text] = array('count' => $row->count);
}
}
wfRestoreWarnings();
// sort tag array by key (tag name)
if ($this->tags_highest_count == 0) {
return;
}
ksort($this->tags);
/* and what if we have _1_ category? like on a new wiki with nteen articles, mhm? */
if ($this->tags_highest_count == 1) {
$coef = $this->tags_max_pts - $this->tags_min_pts;
} else {
$coef = ($this->tags_max_pts - $this->tags_min_pts) / (($this->tags_highest_count - 1) * 2);
}
foreach ($this->tags as $tag => $att) {
$this->tags[$tag]['size'] = $this->tags_min_pts + ($this->tags[$tag]['count'] - 1) * $coef;
}
}
示例12: __construct
protected function __construct() {
$idFile = wfTempDir() . '/mw-' . __CLASS__ . '-UID-nodeid';
$nodeId = is_file( $idFile ) ? file_get_contents( $idFile ) : '';
// Try to get some ID that uniquely identifies this machine (RFC 4122)...
if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
wfSuppressWarnings();
if ( wfIsWindows() ) {
// http://technet.microsoft.com/en-us/library/bb490913.aspx
$csv = trim( wfShellExec( 'getmac /NH /FO CSV' ) );
$line = substr( $csv, 0, strcspn( $csv, "\n" ) );
$info = str_getcsv( $line );
$nodeId = isset( $info[0] ) ? str_replace( '-', '', $info[0] ) : '';
} elseif ( is_executable( '/sbin/ifconfig' ) ) { // Linux/BSD/Solaris/OS X
// See http://linux.die.net/man/8/ifconfig
$m = array();
preg_match( '/\s([0-9a-f]{2}(:[0-9a-f]{2}){5})\s/',
wfShellExec( '/sbin/ifconfig -a' ), $m );
$nodeId = isset( $m[1] ) ? str_replace( ':', '', $m[1] ) : '';
}
wfRestoreWarnings();
if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
$nodeId = MWCryptRand::generateHex( 12, true );
$nodeId[1] = dechex( hexdec( $nodeId[1] ) | 0x1 ); // set multicast bit
}
file_put_contents( $idFile, $nodeId ); // cache
}
$this->nodeId32 = wfBaseConvert( substr( sha1( $nodeId ), 0, 8 ), 16, 2, 32 );
$this->nodeId48 = wfBaseConvert( $nodeId, 16, 2, 48 );
// If different processes run as different users, they may have different temp dirs.
// This is dealt with by initializing the clock sequence number and counters randomly.
$this->lockFile88 = wfTempDir() . '/mw-' . __CLASS__ . '-UID-88';
$this->lockFile128 = wfTempDir() . '/mw-' . __CLASS__ . '-UID-128';
}
示例13: sendRPC
/**
* @access private
* @static
*/
function sendRPC($method, $params = array())
{
global $mwBlockerHost, $mwBlockerPort, $mwBlockerDebug;
$client = new XML_RPC_Client('/Blocker', $mwBlockerHost, $mwBlockerPort);
if ($mwBlockerDebug) {
$client->debug = true;
}
$rpcParams = array_map(array('MWBlocker', 'outParam'), $params);
$message = new XML_RPC_Message($method, $rpcParams);
wfSuppressWarnings();
$start = wfTime();
$result = $client->send($message);
$delta = wfTime() - $start;
wfRestoreWarnings();
$debug = sprintf("MWBlocker::sendRPC for %s took %0.2fms\n", $method, $delta * 1000.0);
wfDebug($debug);
if ($mwBlockerDebug) {
echo $debug;
}
if (!is_object($result)) {
throw new MWException("Unknown XML-RPC error");
} elseif ($result->faultCode()) {
throw new MWException($result->faultCode() . ': ' . $result->faultString());
} else {
$value = $result->value();
return $value->getval();
}
}
示例14: extensionCredits
function extensionCredits()
{
global $wgExtensionCredits, $wgExtensionFunctions, $wgSkinExtensionFunction;
if (!count($wgExtensionCredits) && !count($wgExtensionFunctions) && !count($wgSkinExtensionFunction)) {
return '';
}
$extensionTypes = array('specialpage' => 'Special pages', 'parserhook' => 'Parser hooks', 'other' => 'Other');
$out = "\n* Extensions:\n";
foreach ($extensionTypes as $type => $text) {
if (count(@$wgExtensionCredits[$type])) {
$out .= "** {$text}:\n";
foreach ($wgExtensionCredits[$type] as $extension) {
wfSuppressWarnings();
$out .= $this->formatCredits($extension['name'], $extension['version'], $extension['author'], $extension['url'], $extension['description']);
wfRestoreWarnings();
}
}
}
if (count($wgExtensionFunctions)) {
$out .= "** Extension functions:\n";
$out .= '***' . $this->langObj->listToText($wgExtensionFunctions) . "\n";
}
if (count($wgSkinExtensionFunction)) {
$out .= "** Skin extension functions:\n";
$out .= '***' . $this->langObj->listToText($wgSkinExtensionFunction) . "\n";
}
return $out;
}
示例15: getLongDesc
function getLongDesc($image)
{
global $wgLang;
$original = parent::getLongDesc($image);
wfSuppressWarnings();
$metadata = unserialize($image->getMetadata());
wfRestoreWarnings();
if (!$metadata || $metadata['frameCount'] <= 0) {
return $original;
}
$info = array();
$info[] = $original;
if ($metadata['loopCount'] == 0) {
$info[] = wfMsgExt('file-info-png-looped', 'parseinline');
} elseif ($metadata['loopCount'] > 1) {
$info[] = wfMsgExt('file-info-png-repeat', 'parseinline', $metadata['loopCount']);
}
if ($metadata['frameCount'] > 0) {
$info[] = wfMsgExt('file-info-png-frames', 'parseinline', $metadata['frameCount']);
}
if ($metadata['duration']) {
$info[] = $wgLang->formatTimePeriod($metadata['duration']);
}
return $wgLang->commaList($info);
}