Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/174191
Change subject: Profiler: Explicitly convert output type to class name
......................................................................
Profiler: Explicitly convert output type to class name
Follows-up b8d93fb4fd06.
Change-Id: I50faa25fdc4fb980e0ff71014b8d1b2a5818af80
---
M includes/profiler/Profiler.php
1 file changed, 16 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/91/174191/1
diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php
index 12e999b..d23c777 100644
--- a/includes/profiler/Profiler.php
+++ b/includes/profiler/Profiler.php
@@ -39,6 +39,15 @@
/** @var TransactionProfiler */
protected $trxProfiler;
+ /**
+ * @var array Mapping of output type to class name
+ */
+ private static $outputTypes = array(
+ 'db' => 'ProfilerOutputDb',
+ 'text' => 'ProfilerOutputText',
+ 'udp' => 'ProfilerOutputUdp',
+ );
+
// @codingStandardsIgnoreStart
PSR2.Classes.PropertyDeclaration.Underscore
/** @var Profiler Do not call this outside Profiler and ProfileSection
*/
public static $__instance = null;
@@ -131,6 +140,7 @@
/**
* Log the data to some store or even the page output
*
+ * @throws MWException
* @since 1.25
*/
public function logData() {
@@ -147,7 +157,12 @@
}
foreach ( $output as $outType ) {
- $class = 'ProfilerOutput' . ucfirst( strtolower(
$outType ) );
+ if ( isset( self::$outputTypes[$outType] ) ) {
+ $class = self::$outputTypes[$outType];
+ } else {
+ throw new MWException( "'$outType' is an
invalid output type" );
+ }
+ /** @var ProfilerOutput $profileOut */
$profileOut = new $class( $this, $this->params );
if ( $profileOut->canUse() ) {
$profileOut->log();
--
To view, visit https://gerrit.wikimedia.org/r/174191
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I50faa25fdc4fb980e0ff71014b8d1b2a5818af80
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits