sasanrose / phpredmin

Yet another web interface for Redis
BSD 3-Clause "New" or "Revised" License
404 stars 96 forks source link

Get the following error when browsing the UI #86

Closed barrychapman closed 7 years ago

barrychapman commented 7 years ago
    ( ! ) Notice: Undefined index: dbs in /var/www/vhosts/redis_gui/views/layout.php on line 129
    Call Stack
    #   Time    Memory  Function    Location
    1   0.0000  360888  {main}( )   .../index.php:0
    2   0.1430  370560  router->route( )    .../index.php:51
    3   0.1439  403152  Welcome_Controller->indexAction( )  .../router.php:117
    4   0.1440  405064  PhpTemplate->render( )  .../welcome.php:7
    5   0.1442  419824  PhpTemplate->renderPartial( )   .../php.php:23
    6   0.1446  438960  include( '/var/www/vhosts/redis_gui/views/layout.php' ) .../php.php:32**
    **

Config:

    'database'  => array(
            'driver' => 'redis',
            'mysql'  => array(
                'host'     => 'xxxxxxxxx:2999',
                'username' => 'user',
                'password' => 'Password!'
            ),
            'redis' => array(
                array(
                    'host'     => '172.123.4.233',
                    'port'     => '6379',
                    'password' => null,
                    'database' => 0,
                    'max_databases' => 16, /* Manual configuration of max databases for Redis < 2.6 */
                    'stats'    => array(
                        'enable'   => 1,
                        'database' => 0,
                    ),
                    'dbNames' => array(
                        'redis' => 'Redis DB'
                    /* Name databases. key should be database id and value is the name */
                    ),
                ),
            ),
        ),
sasanrose commented 7 years ago

@barrychapman I can't reproduce this, can you provide more information? like the exact steps to reproduce this bug, and how did you install php redmin? Are you using Docker?

mnvx commented 7 years ago

Problem is here: https://github.com/sasanrose/phpredmin/blob/master/views/layout.php#L128

And Here: https://github.com/sasanrose/phpredmin/blob/master/libraries/controller.php#L47

If $this->infoModel->getDbs($info); return empty array ([]) then index 'dbs' will not be found in layout. It can be fixed by changing line expression in layout:

<?= ($this->app->current['dbs'][$this->app->current['database']]['name'] ? $this->app->current['dbs'][$this->app->current['database']]['name'] . " (DB {$this->app->current['database']})" : "DB {$this->app->current['database']}") ?>

to

<?= (isset($this->app->current['dbs'][$this->app->current['database']]['name']) ? $this->app->current['dbs'][$this->app->current['database']]['name'] . " (DB {$this->app->current['database']})" : "DB {$this->app->current['database']}") ?>