Skip to content

Commit c61711b

Browse files
committed
adjusting ExplainAction
1 parent d667b77 commit c61711b

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Yii Framework 2 mongodb extension Change Log
1717
- Enh #41: Added `yii\mongodb\Connection::driverOptions` allowing setup of the options for the MongoDB driver (klimov-paul)
1818
- Enh #57: Added i18n support via `yii\mongodb\i18n\MongoDbMessageSource` (klimov-paul)
1919
- Enh #69: Fixed log target to display exceptions like DbTarget in Yii core, also avoids problems with Exceptions that contain closures (cebe)
20+
- Enh #74: Added explain method to `MongoDbPanel` debug panel (webdevsega)
2021
- Enh #102: `MongoDbTarget` now uses `batchInsert()` while exporting log messages (klimov-paul)
2122

2223

debug/ExplainAction.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
<?php
2+
/**
3+
* @link http://www.yiiframework.com/
4+
* @copyright Copyright (c) 2008 Yii Software LLC
5+
* @license http://www.yiiframework.com/license/
6+
*/
27

38
namespace yii\mongodb\debug;
49

510
use yii\base\Action;
6-
use yii\base\InvalidParamException;
7-
use yii\debug\panels\DbPanel;
8-
use yii\helpers\ArrayHelper;
911
use yii\helpers\Json;
1012
use yii\web\HttpException;
1113

1214
/**
1315
* ExplainAction provides EXPLAIN information for MongoDB queries
16+
*
17+
* @author Sergey Smirnov <[email protected]>
18+
* @since 2.0.5
1419
*/
1520
class ExplainAction extends Action
1621
{
1722
/**
18-
* @var DbPanel
23+
* @var MongoDbPanel related debug toolbar panel
1924
*/
2025
public $panel;
2126

27+
2228
/**
23-
* Runs the action
24-
*
25-
* @return string result content
29+
* Runs the explain action
30+
* @param integer $seq
31+
* @param string $tag
32+
* @return string explain result content
33+
* @throws HttpException if requested log not found
2634
*/
2735
public function run($seq, $tag)
2836
{
@@ -37,12 +45,12 @@ public function run($seq, $tag)
3745
$query = $timings[$seq]['info'];
3846
preg_match('/^.+\((.*)\)$/', $query, $matches);
3947
if (!isset($matches[1])) {
40-
return;
48+
return '';
4149
}
4250

4351
$cursor = $this->getCursorFromQueryLog($matches[1]);
4452
if (!$cursor) {
45-
return;
53+
return '';
4654
}
4755
$result = $cursor->explain();
4856

debug/MongoDbPanel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
*/
1919
class MongoDbPanel extends DbPanel
2020
{
21+
/**
22+
* @inheritdoc
23+
*/
24+
public $db = 'mongodb';
25+
26+
2127
/**
2228
* @inheritdoc
2329
*/

0 commit comments

Comments
 (0)