本文整理汇总了PHP中Wikia::logBacktrace方法的典型用法代码示例。如果您正苦于以下问题:PHP Wikia::logBacktrace方法的具体用法?PHP Wikia::logBacktrace怎么用?PHP Wikia::logBacktrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikia
的用法示例。
在下文中一共展示了Wikia::logBacktrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: app_operation
/**
* Send a packet to SFlow daemon
*
* @param $app_name
* @param $op_name
* @param string $attributes
* @param int $status
* @param string $status_descr
* @param int $req_bytes
* @param int $resp_bytes
* @param int $uS
*/
private static function app_operation($app_name, $op_name, $attributes = "", $status = 0, $status_descr = "", $req_bytes = 0, $resp_bytes = 0, $uS = 0)
{
global $wgSFlowHost, $wgSFlowPort, $wgSFlowSampling;
// sampling handling
$sampling_rate = $wgSFlowSampling;
if ($sampling_rate > 1) {
if (mt_rand(1, $sampling_rate) != 1) {
return;
}
}
wfProfileIn(__METHOD__);
try {
$sock = fsockopen("udp://" . $wgSFlowHost, $wgSFlowPort, $errno, $errstr);
if (!$sock) {
wfProfileOut(__METHOD__);
return;
}
$data = ["flow_sample" => ["app_name" => $app_name, "sampling_rate" => $sampling_rate, "app_operation" => ["operation" => $op_name, "attributes" => $attributes, "status_descr" => $status_descr, "status" => $status, "req_bytes" => $req_bytes, "resp_bytes" => $resp_bytes, "uS" => $uS]]];
$payload = json_encode($data);
wfDebug(sprintf("%s: sending '%s'\n", __METHOD__, $payload));
fwrite($sock, $payload);
fclose($sock);
} catch (\Exception $e) {
\Wikia::log(__METHOD__, 'send', $e->getMessage(), true);
\Wikia::logBacktrace(__METHOD__);
}
wfProfileOut(__METHOD__);
}
示例2: __construct
/**
* Constructor
*
* @link http://pl2.php.net/manual/en/exception.construct.php
* @param string $message
* @param int $code
* @param Exception $exception
*/
public function __construct($message = '', $code = 0, Exception $previous = null)
{
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
parent::__construct($message, $code);
$this->_previous = $previous;
} else {
parent::__construct($message, $code, $previous);
}
// log more details (macbre)
Wikia::logBacktrace(__METHOD__);
}
示例3: loadStructuredData
protected function loadStructuredData(EditHubModel $model, $params)
{
try {
$apiResponse = $this->app->sendRequest('WAMApi', 'getWAMIndex', $params)->getData();
} catch (WikiaHttpException $e) {
$logMsg = 'Message: ' . $e->getLogMessage() . ' Details: ' . $e->getDetails();
Wikia::log(__METHOD__, false, $logMsg);
Wikia::logBacktrace(__METHOD__);
}
$data = ['vertical_id' => $params['vertical_id'], 'api_response' => $apiResponse];
return $this->getStructuredData($data);
}
示例4: renderDataList
protected static function renderDataList($list)
{
$result = array();
foreach ($list as $v) {
if (is_object($v)) {
$item = $v->getRenderData();
if ($item) {
$result[] = $item;
}
} else {
Wikia::log(__METHOD__, false, 'BugID: 21498');
Wikia::logBacktrace(__METHOD__);
}
}
return $result;
}
示例5: getTouchedKey
protected function getTouchedKey($title)
{
//fb#24914
if ($title instanceof Title) {
$key = wfMemcKey('category_touched', md5($title->getDBKey()), self::CACHE_VERSION);
return $key;
} else {
Wikia::log(__METHOD__, '', '$title not an instance of Title');
Wikia::logBacktrace(__METHOD__);
return null;
}
}
示例6: getPackage
/**
* Get messages for a given package as key => value structure
*
* Resolve messages list (entries matching "feature-*" pattern)
*
* @param string $name - name of the messages package
* @param boolean $allowWildcards - can packages with wildcard be added?
* @return array - key/value array of messages
*/
private static function getPackage($name, $allowWildcards = true)
{
wfProfileIn(__METHOD__);
$ret = null;
if (isset(self::$packages[$name])) {
self::log(__METHOD__, $name);
// get messages
$messages = self::$packages[$name];
$ret = array();
foreach ($messages as $message) {
// pattern to match messages (e.g. "feature-*")
if (substr($message, -1) == '*') {
// BugId:18482
if ($allowWildcards) {
$msgs = self::resolveMessagesPattern($message);
if (!empty($msgs)) {
$ret = array_merge($ret, $msgs);
}
} else {
Wikia::logBacktrace(__METHOD__);
wfProfileOut(__METHOD__);
trigger_error("JSMessages: '{$name}' package with wildcard matching can only be used in EXTERNAL mode", E_USER_ERROR);
return;
}
} else {
//@todo - this removes the {{PLURAL prefix, so plurals won't work in JS
//on the other hand we cannot simply set $transform to true, as we want the wiki links to be parsed
$msg = wfMsgGetKey($message, true);
// check for not existing message
if ($msg == htmlspecialchars("<{$message}>")) {
$msg = false;
}
$ret[$message] = $msg;
}
}
}
wfProfileOut(__METHOD__);
return $ret;
}
示例7: wfDevBoxLogExceptions
function wfDevBoxLogExceptions($errorText)
{
Wikia::logBacktrace("wfDevBoxLogExceptions");
Wikia::log($errorText);
return $errorText;
}
示例8: dispatch
//.........这里部分代码省略.........
$response->getView()->setTemplate($controllerName, $method);
} catch (WikiaException $e) {
throw new MethodNotFoundException("{$controllerClassName}::{$method}");
}
}
$method = "execute{$method}";
$params = $request->getParams();
// old modules expect params in a different place
} else {
$hookMethod = $method;
$params = array();
}
if (!$request->isInternal() && !$controller->allowsExternalRequests() || in_array($method, array('allowsExternalRequests', 'getRequest', 'setRequest', 'getResponse', 'setResponse', 'getApp', 'setApp', 'init')) || !method_exists($controller, $method) || !is_callable(array($controller, $method))) {
throw new MethodNotFoundException("{$controllerClassName}::{$method}");
}
if (!$request->isInternal()) {
$this->testIfUserHasPermissionsOrThrow($app, $controller, $method);
}
// Initialize the RequestContext object if it is not already set
// SpecialPageController context is already set by SpecialPageFactory::execute by the time it gets here
if ($controller->getContext() === null) {
$controller->setContext(RequestContext::getMain());
}
// If a SpecialPageController is dispatching a request to itself, preserve the original request context
// TODO: come up with a better fix for this (it's because of the setInstance call in WikiaSpecialPageController)
$originalRequest = $controller->getRequest();
$originalResponse = $controller->getResponse();
$controller->setRequest($request);
$controller->setResponse($response);
$controller->setApp($app);
$controller->init();
if (method_exists($controller, 'preventBlockedUsage') && $controller->preventBlockedUsage($controller->getContext()->getUser(), $method)) {
$result = false;
} elseif (method_exists($controller, 'userAllowedRequirementCheck') && $controller->userAllowedRequirementCheck($controller->getContext()->getUser(), $method)) {
$result = false;
} else {
// Actually call the controller::method!
$result = $controller->{$method}($params);
}
if ($result === false) {
// skip template rendering when false returned
$controller->skipRendering();
}
// Preserve original request (this is for SpecialPageControllers)
if ($originalRequest != null) {
$controller->setRequest($originalRequest);
}
if ($originalResponse != null) {
$controller->setResponse($originalResponse);
}
// keep the AfterExecute hooks for now, refactor later using "after" dispatching
$app->runHook("{$controllerName}{$hookMethod}AfterExecute", array(&$controller, &$params));
wfProfileOut($profilename);
} catch (WikiaHttpException $e) {
if ($request->isInternal()) {
//if it is internal call rethrow it so we can apply normal handling
wfProfileOut(__METHOD__);
throw $e;
} else {
wfProfileOut($profilename);
$response->setException($e);
$response->setFormat('json');
$response->setCode($e->getCode());
$response->setVal('error', get_class($e));
$details = $e->getDetails();
if (!empty($details)) {
$response->setVal('message', $details);
}
}
} catch (Exception $e) {
if ($profilename) {
wfProfileOut($profilename);
}
$response->setException($e);
Wikia::log(__METHOD__, $e->getMessage());
// if we catch an exception, forward to the WikiaError controller unless we are already dispatching Error
if (empty($controllerClassName) || $controllerClassName != 'WikiaErrorController') {
$controller = new WikiaErrorController();
$controller->forward('WikiaError', 'error', false);
// keep params for error controller
$response->getView()->setTemplatePath(null);
// response is re-used so skip the original template
}
}
} while ($controller && $controller->hasNext());
if ($request->isInternal() && $response->hasException() && $request->getExceptionMode() !== WikiaRequest::EXCEPTION_MODE_RETURN) {
Wikia::logBacktrace(__METHOD__ . '::exception');
wfProfileOut(__METHOD__);
switch ($request->getExceptionMode()) {
case WikiaRequest::EXCEPTION_MODE_THROW:
throw $response->getException();
// case WikiaRequest::EXCEPTION_MODE_WRAP_AND_THROW:
// case WikiaRequest::EXCEPTION_MODE_WRAP_AND_THROW:
default:
throw new WikiaDispatchedException("Internal Throw ({$response->getException()->getMessage()})", $response->getException());
}
}
wfProfileOut(__METHOD__);
return $response;
}
示例9: __construct
/**
* constructor
* @param $globalRegistry WikiaGlobalRegistry
* @param $localRegistry WikiaLocalRegistry
* @param $hookDispatcher WikiaHookDispatcher
*/
public function __construct(WikiaGlobalRegistry $globalRegistry = null, WikiaLocalRegistry $localRegistry = null, WikiaHookDispatcher $hookDispatcher = null, WikiaFunctionWrapper $functionWrapper = null)
{
if (!is_object($globalRegistry)) {
F::setInstance('WikiaGlobalRegistry', new WikiaGlobalRegistry());
$globalRegistry = F::build('WikiaGlobalRegistry');
}
if (!is_object($localRegistry)) {
F::setInstance('WikiaLocalRegistry', new WikiaLocalRegistry());
$localRegistry = F::build('WikiaLocalRegistry');
}
if (!is_object($hookDispatcher)) {
F::setInstance('WikiaHookDispatcher', new WikiaHookDispatcher());
$hookDispatcher = F::build('WikiaHookDispatcher');
}
if (!is_object($functionWrapper)) {
$functionWrapper = F::build('WikiaFunctionWrapper');
}
$this->localRegistry = $localRegistry;
$this->hookDispatcher = $hookDispatcher;
// set helper accessors
$this->wg = $globalRegistry;
$this->wf = $functionWrapper;
// register ajax dispatcher
if (is_object($this->wg)) {
$this->wg->append('wgAjaxExportList', 'WikiaApp::ajax');
} else {
Wikia::log(__METHOD__, false, 'WikiaGlobalRegistry not set in ' . __CLASS__ . ' ' . __METHOD__);
Wikia::logBacktrace(__METHOD__);
}
}
示例10: dispatch
//.........这里部分代码省略.........
throw new WikiaException("wgAutoloadClasses is empty, cannot dispatch Request");
}
$format = $request->getVal('format', WikiaResponse::FORMAT_HTML);
$response = F::build('WikiaResponse', array('format' => $format, 'request' => $request));
if ($app->wg->EnableSkinTemplateOverride && $app->isSkinInitialized()) {
$response->setSkinName($app->wg->User->getSkin()->getSkinName());
}
// Main dispatch is a loop because Controllers can forward to each other
// Error condition is also handled via dispatching to the error controller
do {
$request->setDispatched(true);
try {
$method = $this->getMethodName($request);
// Determine the "base" name for the controller, stripping off Controller/Service/Module
$controllerName = $app->getBaseName($request->getVal('controller'));
// Service classes must be dispatched by full name otherwise we look for a controller.
if ($app->isService($request->getVal('controller'))) {
$controllerClassName = $app->getServiceClassName($controllerName);
} else {
$controllerClassName = $app->getControllerClassName($controllerName);
}
$profilename = __METHOD__ . " ({$controllerName}_{$method})";
if (empty($controllerName)) {
throw new WikiaException("Invalid controller name: {$controllerName}");
}
if (empty($autoloadClasses[$controllerClassName])) {
throw new WikiaException("Controller class does not exist: {$controllerClassName}");
}
$app->wf->profileIn($profilename);
$response->setControllerName($controllerClassName);
$response->setMethodName($method);
$controller = F::build($controllerClassName);
/* @var $controller WikiaController */
// map X to executeX method names for things that used to be modules
if (!method_exists($controller, $method)) {
$method = ucfirst($method);
// This will throw an exception if the template is missing
// Refactor the offending class to not use executeXYZ methods or set format in request params
if ($format == WikiaResponse::FORMAT_HTML) {
$response->getView()->setTemplate($controllerName, $method);
}
$method = "execute{$method}";
$params = $request->getParams();
// old modules expect params in a different place
}
if (!$request->isInternal() && !$controller->allowsExternalRequests() || in_array($method, array('allowsExternalRequests', 'getRequest', 'setRequest', 'getResponse', 'setResponse', 'getApp', 'setApp', 'init')) || !method_exists($controller, $method) || !is_callable(array($controller, $method))) {
throw new WikiaException("Could not dispatch {$controllerClassName}::{$method}");
}
// Initialize the RequestContext object if it is not already set
// SpecialPageController context is already set by SpecialPageFactory::execute by the time it gets here
if ($controller->getContext() === null) {
$controller->setContext(RequestContext::getMain());
}
// If a SpecialPageController is dispatching a request to itself, preserve the original request context
// TODO: come up with a better fix for this (it's because of the setInstance call in WikiaSpecialPageController)
$originalRequest = $controller->getRequest();
$originalResponse = $controller->getResponse();
$controller->setRequest($request);
$controller->setResponse($response);
$controller->setApp($app);
$controller->init();
// BugId:5125 - keep old hooks naming convention
$hookMethod = ucfirst($this->getMethodName($request));
$hookResult = $app->runHook("{$controllerName}{$hookMethod}BeforeExecute", array(&$controller, &$params));
if ($hookResult) {
$result = $controller->{$method}($params);
if ($result === false) {
// skip template rendering when false returned
$controller->skipRendering();
}
}
// Preserve original request (this is for SpecialPageControllers)
if ($originalRequest != null) {
$controller->setRequest($originalRequest);
}
if ($originalResponse != null) {
$controller->setResponse($originalResponse);
}
// we ignore the result of the AfterExecute hook
$app->runHook("{$controllerName}{$hookMethod}AfterExecute", array(&$controller, &$params));
$app->wf->profileOut($profilename);
} catch (Exception $e) {
$app->wf->profileOut($profilename);
$response->setException($e);
Wikia::log(__METHOD__, $e->getMessage());
// if we catch an exception, redirect to the WikiaError controller
if ($controllerClassName != 'WikiaErrorController' && $method != 'error') {
$response->getView()->setTemplatePath(null);
$request->setVal('controller', 'WikiaError');
$request->setVal('method', 'error');
$request->setDispatched(false);
}
}
} while (!$request->isDispatched());
if ($request->isInternal() && $response->hasException()) {
Wikia::logBacktrace(__METHOD__ . '::exception');
throw new WikiaDispatchedException("Internal Throw ({$response->getException()->getMessage()})", $response->getException());
}
return $response;
}
示例11: wfWikiaErrorHandler
/**
* Defines error handler to log backtrace for PHP (catchable) fatal errors
*
* @author Maciej Brencz <macbre@wikia-inc.com>
*/
function wfWikiaErrorHandler($errno, $errstr, $errfile, $errline)
{
switch ($errno) {
case E_RECOVERABLE_ERROR:
Wikia::logBacktrace("PHP fatal error caught ({$errstr})");
break;
}
// error was not really handled
return false;
}
示例12: buildNewMessageAndPost
/**
* @static
* @param $body
* @param $page
* @param $user
* @param string $metaTitle
* @param bool|WallMessage $parent
* @param array $relatedTopics
* @param bool $notify
* @param bool $notifyEveryone
* @return WallMessage|Bool
*/
public static function buildNewMessageAndPost($body, $page, $user, $metaTitle = '', $parent = false, $relatedTopics = array(), $notify = true, $notifyEveryone = false)
{
wfProfileIn(__METHOD__);
if ($page instanceof Title) {
$userPageTitle = $page;
} else {
$userPageTitle = Title::newFromText($page, NS_USER_WALL);
}
// if message wall was just created, we should later use MASTER db when creating title object
$useMasterDB = false;
// create wall page by bot if not exist
if ($userPageTitle instanceof Title && !$userPageTitle->exists()) {
$userPageTitle = self::addMessageWall($userPageTitle);
$useMasterDB = true;
}
if (empty($userPageTitle)) {
Wikia::log(__METHOD__, '', '$userPageTitle not an instance of Title');
Wikia::logBacktrace(__METHOD__);
wfProfileOut(__METHOD__);
return false;
}
if ($parent === false) {
$metaData = array('title' => $metaTitle);
if ($notifyEveryone) {
$metaData['notify_everyone'] = time();
}
if (!empty($relatedTopics)) {
$metaData['related_topics'] = implode('|', $relatedTopics);
}
$acStatus = ArticleComment::doPost($body, $user, $userPageTitle, false, $metaData);
} else {
if (!$parent->canReply()) {
wfProfileOut(__METHOD__);
return false;
}
$acStatus = ArticleComment::doPost($body, $user, $userPageTitle, $parent->getId(), null);
}
if ($acStatus === false) {
wfProfileOut(__METHOD__);
return false;
}
$ac = ArticleComment::newFromId($acStatus[1]->getId());
if (empty($ac)) {
wfProfileOut(__METHOD__);
return false;
}
// after successful posting invalidate Wall cache
/**
* @var $class WallMessage
*/
$class = new WallMessage($ac->getTitle(), $ac);
if ($parent === false) {
// $db = DB_SLAVE
$class->storeRelatedTopicsInDB($relatedTopics);
$class->setOrderId(1);
$class->getWall()->invalidateCache();
} else {
$count = $parent->getOrderId(true);
// this is not work perfect with transations
if (is_numeric($count)) {
$count++;
$parent->setOrderId($count);
$class->setOrderId($count);
}
// after successful posting invalidate Thread cache
$class->getThread()->invalidateCache();
$rp = new WallRelatedPages();
$rp->setLastUpdate($parent->getId());
}
// Build data for sweet url ? id#number_of_comment
// notify
if ($notify) {
$class->sendNotificationAboutLastRev($useMasterDB);
}
if ($parent === false && $notifyEveryone) {
$class->notifyEveryone();
}
$class->addWatch($user);
wfRunHooks('AfterBuildNewMessageAndPost', array(&$class));
wfProfileOut(__METHOD__);
return $class;
}
示例13: recordUpload2
/**
* Record a file upload in the upload log and the image table
*/
function recordUpload2($oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null)
{
global $wgCityId;
if (is_null($user)) {
global $wgUser;
$user = $wgUser;
}
$dbw = $this->repo->getMasterDB();
$dbw->begin();
if (!$props) {
$props = $this->repo->getFileProps($this->getVirtualUrl());
}
if ($timestamp === false) {
$timestamp = $dbw->timestamp();
}
$props['description'] = $comment;
$props['user'] = $user->getId();
$props['user_text'] = $user->getName();
$props['timestamp'] = wfTimestamp(TS_MW, $timestamp);
// DB -> TS_MW
$this->setProps($props);
# Fail now if the file isn't there
if (!$this->fileExists) {
wfDebug(__METHOD__ . ": File " . $this->getRel() . " went missing!\n");
return false;
}
$reupload = false;
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
$dbw->insert('image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), __METHOD__, 'IGNORE');
if ($dbw->affectedRows() == 0) {
if ($oldver == '') {
// XXX
# (bug 34993) publish() can displace the current file and yet fail to save
# a new one. The next publish attempt will treat the file as a brand new file
# and pass an empty $oldver. Allow this bogus value so we can displace the
# `image` row to `oldimage`, leaving room for the new current file `image` row.
#throw new MWException( "Empty oi_archive_name. Database and storage out of sync?" );
Wikia::logBacktrace(__METHOD__ . "::oi_archive_name - [{$this->getName()}]");
// Wikia change (BAC-1068)
}
$reupload = true;
# Collision, this is an update of a file
# Insert previous contents into oldimage
$dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text', 'oi_metadata' => 'img_metadata', 'oi_media_type' => 'img_media_type', 'oi_major_mime' => 'img_major_mime', 'oi_minor_mime' => 'img_minor_mime', 'oi_sha1' => 'img_sha1'), array('img_name' => $this->getName()), __METHOD__);
# Update the current image row
$dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), array('img_name' => $this->getName()), __METHOD__);
} else {
# This is a new file
# Update the image count
$dbw->begin(__METHOD__);
$dbw->update('site_stats', array('ss_images = ss_images+1'), '*', __METHOD__);
$dbw->commit(__METHOD__);
}
$descTitle = $this->getTitle();
$wikiPage = new WikiFilePage($descTitle);
$wikiPage->setFile($this);
# Add the log entry
$log = new LogPage('upload');
$action = $reupload ? 'overwrite' : 'upload';
$log->addEntry($action, $descTitle, $comment, array(), $user);
if ($descTitle->exists()) {
# Create a null revision
$latest = $descTitle->getLatestRevID();
$nullRevision = Revision::newNullRevision($dbw, $descTitle->getArticleId(), $log->getRcComment(), false);
if (!is_null($nullRevision)) {
$nullRevision->insertOn($dbw);
wfRunHooks('NewRevisionFromEditComplete', array($wikiPage, $nullRevision, $latest, $user));
$wikiPage->updateRevisionOn($dbw, $nullRevision);
}
# Invalidate the cache for the description page
$descTitle->invalidateCache();
$descTitle->purgeSquid();
} else {
# New file; create the description page.
# There's already a log entry, so don't make a second RC entry
# Squid and file cache for the description page are purged by doEdit.
$wikiPage->doEdit($pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user);
}
/* wikia change - begin (VID-1568) */
// Update/Insert video info
try {
\VideoInfoHooksHelper::upsertVideoInfo($this, $reupload);
} catch (\Exception $e) {
$dbw->rollback();
return false;
}
/* wikia change - end (VID-1568) */
# Commit the transaction now, in case something goes wrong later
# The most important thing is that files don't get lost, especially archives
$dbw->commit();
# Save to cache and purge the squid
# We shall not saveToCache before the commit since otherwise
# in case of a rollback there is an usable file from memcached
# which in fact doesn't really exist (bug 24978)
$this->saveToCache();
//.........这里部分代码省略.........
示例14: getProps
/**
* Get an associative array containing information about
* a file with the given storage path.
*
* @param $ext Mixed: the file extension, or true to extract it from the filename.
* Set it to false to ignore the extension.
*
* @return array
*/
public function getProps($ext = true)
{
wfProfileIn(__METHOD__);
wfDebug(__METHOD__ . ": Getting file info for {$this->path}\n");
$info = self::placeholderProps();
$info['fileExists'] = $this->exists();
if ($info['fileExists']) {
$magic = MimeMagic::singleton();
# get the file extension
if ($ext === true) {
$ext = self::extensionFromPath($this->path);
}
# mime type according to file contents
$info['file-mime'] = $this->getMimeType();
# logical mime type
$info['mime'] = $magic->improveTypeFromExtension($info['file-mime'], $ext);
list($info['major_mime'], $info['minor_mime']) = File::splitMime($info['mime']);
$info['media_type'] = $magic->getMediaType($this->path, $info['mime']);
# Get size in bytes
$info['size'] = $this->getSize();
# Wikia change - begin
# @author macbre - BAC-773
if (empty($info['size'])) {
Wikia::log(__METHOD__, 'emptySize', sprintf('filesize() returned "%s"', print_r($info['size'], true)), true);
Wikia::logBacktrace(__METHOD__ . '-emptySize');
}
# Wikia change - end
# Height, width and metadata
$handler = MediaHandler::getHandler($info['mime']);
if ($handler) {
$tempImage = (object) array();
$info['metadata'] = $handler->getMetadata($tempImage, $this->path);
$gis = $handler->getImageSize($tempImage, $this->path, $info['metadata']);
if (is_array($gis)) {
$info = $this->extractImageSizeInfo($gis) + $info;
}
}
$info['sha1'] = $this->getSha1Base36();
wfDebug(__METHOD__ . ": {$this->path} loaded, {$info['size']} bytes, {$info['mime']}.\n");
} else {
wfDebug(__METHOD__ . ": {$this->path} NOT FOUND!\n");
}
wfProfileOut(__METHOD__);
return $info;
}
示例15: doIncrementalUpdate
protected function doIncrementalUpdate()
{
// Wikia change - start (BAC-597)
if ($this->mId === 0) {
Wikia::logBacktrace(__CLASS__ . '::mIdIsZero - update skipped');
return;
}
// Wikia change - end
wfProfileIn(__METHOD__);
# Page links
$existing = $this->getExistingLinks();
$this->incrTableUpdate('pagelinks', 'pl', $this->getLinkDeletions($existing), $this->getLinkInsertions($existing));
# Image links
$existing = $this->getExistingImages();
$imageDeletes = $this->getImageDeletions($existing);
/* Wikia change begin - @author: mech */
$imageInserts = $this->getImageInsertions($existing);
Wikia::setVar('imageDeletes', $imageDeletes);
// images are in array keys!
Wikia::setVar('imageInserts', $imageInserts);
$this->incrTableUpdate('imagelinks', 'il', $imageDeletes, $imageInserts);
/* Wikia change end */
# Invalidate all image description pages which had links added or removed
$imageUpdates = $imageDeletes + array_diff_key($this->mImages, $existing);
/* Wikia change CE-677 @author Kamil Koterba kamil@wikia-inc.com */
$this->queueImageDescriptionsInvalidation($imageUpdates);
/* Wikia change end */
# External links
$existing = $this->getExistingExternals();
$this->incrTableUpdate('externallinks', 'el', $this->getExternalDeletions($existing), $this->getExternalInsertions($existing));
# Language links
$existing = $this->getExistingInterlangs();
$this->incrTableUpdate('langlinks', 'll', $this->getInterlangDeletions($existing), $this->getInterlangInsertions($existing));
# Inline interwiki links
$existing = $this->getExistingInterwikis();
$this->incrTableUpdate('iwlinks', 'iwl', $this->getInterwikiDeletions($existing), $this->getInterwikiInsertions($existing));
# Template links
$existing = $this->getExistingTemplates();
$this->incrTableUpdate('templatelinks', 'tl', $this->getTemplateDeletions($existing), $this->getTemplateInsertions($existing));
# Category links
$existing = $this->getExistingCategories();
$categoryDeletes = $this->getCategoryDeletions($existing);
$this->incrTableUpdate('categorylinks', 'cl', $categoryDeletes, $this->getCategoryInsertions($existing));
# Invalidate all categories which were added, deleted or changed (set symmetric difference)
$categoryInserts = array_diff_assoc($this->mCategories, $existing);
$categoryUpdates = $categoryInserts + $categoryDeletes;
/* Wikia change CE-677 @author Kamil Koterba kamil@wikia-inc.com */
$this->queueCategoriesInvalidation($categoryUpdates);
# do the actual invalidation in all pages queued so far
$this->invalidatePages();
/* Wikia change end */
$this->updateCategoryCounts($categoryInserts, $categoryDeletes);
wfRunHooks('AfterCategoriesUpdate', array($categoryInserts, $categoryDeletes, $this->mTitle));
Wikia::setVar('categoryInserts', $categoryInserts);
# Page properties
$existing = $this->getExistingProperties();
$propertiesDeletes = $this->getPropertyDeletions($existing);
$this->incrTableUpdate('page_props', 'pp', $propertiesDeletes, $this->getPropertyInsertions($existing));
# Invalidate the necessary pages
$changed = $propertiesDeletes + array_diff_assoc($this->mProperties, $existing);
$this->invalidateProperties($changed);
# Refresh links of all pages including this page
# This will be in a separate transaction
if ($this->mRecursive) {
$this->queueRecursiveJobs();
}
wfProfileOut(__METHOD__);
}