new initDynamicDebug method

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

new initDynamicDebug method

Günter Hipler
Hi,

after we deployed a version based on VuFind 2.5 last month I just merged the latest master code into our development branch.
I got in trouble with the new initDynamicDebug method in Bootstrapper using our Application in Console mode.
Could it be there is a Condition missing asking for console mode because in Console mode we don't have any Request object. (as it is done in other init Methods of Bootstrapper)

By the way: what is the background for this method?

Thanks!
Günter

/**
 * Initialize dynamic debug mode.
 *
 * @return void
 */
protected function initDynamicDebug()
{

//not part of the current code	
    if (Console::isConsole()) {
        return;
    }


    $app = $this->event->getApplication();
    $sm = $app->getServiceManager();
    $debugOverride = $sm->get('Request')->getQuery()->get('debug');
    if ($debugOverride) {
        $auth = $sm->get('ZfcRbac\Service\AuthorizationService');
        if ($auth->isGranted('access.DebugMode')) {
            $logger = $sm->get('VuFind\Logger');
            $logger->addDebugWriter($debugOverride);
        }
    }
}


-- 
UNIVERSITÄT BASEL
Universitätsbibliothek
Günter Hipler
Projekt swissbib
Schönbeinstrasse 18-20
4056 Basel, Schweiz
Tel.: +41 61 267 31 12 
Fax: +41 61 267 31 03
E-Mail [hidden email]
URL www.swissbib.org

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|

Re: new initDynamicDebug method

Demian Katz

Günter,

 

Sorry about the bug – your fix makes sense and has been applied to master.

 

This relates to a requested feature that adding ?debug=true to the URL can be used to dynamically enable debug mode. The reason this is handled in the bootstrapper is that the dynamic debug mode is tied to a permission (because we don’t want “just anyone” turning on this setting and potentially exposing sensitive information). We can’t resolve the permission in the factory for the logger, because it would create a circular dependency (can’t have the logger dependent on the permission system, because parts of the permission system are already dependent on the logger).

 

Perhaps the whole thing is ill-conceived – but it seemed potentially useful, so  I threw together a simple implementation on Friday (clearly without giving it sufficient thought).

 

- Demian

 

From: Günter Hipler [mailto:[hidden email]]
Sent: Monday, November 09, 2015 11:09 AM
To: [hidden email]
Subject: [VuFind-Tech] new initDynamicDebug method

 

Hi,

after we deployed a version based on VuFind 2.5 last month I just merged the latest master code into our development branch.
I got in trouble with the new initDynamicDebug method in Bootstrapper using our Application in Console mode.
Could it be there is a Condition missing asking for console mode because in Console mode we don't have any Request object. (as it is done in other init Methods of Bootstrapper)

By the way: what is the background for this method?

Thanks!
Günter

/**
 * Initialize dynamic debug mode.
 *
 * @return void
 */
protected function initDynamicDebug()
{
 
//not part of the current code                 
    if (Console::isConsole()) {
        return;
    }
 
 
    $app = $this->event->getApplication();
    $sm = $app->getServiceManager();
    $debugOverride = $sm->get('Request')->getQuery()->get('debug');
    if ($debugOverride) {
        $auth = $sm->get('ZfcRbac\Service\AuthorizationService');
        if ($auth->isGranted('access.DebugMode')) {
            $logger = $sm->get('VuFind\Logger');
            $logger->addDebugWriter($debugOverride);
        }
    }
}




-- 
UNIVERSITÄT BASEL
Universitätsbibliothek
Günter Hipler
Projekt swissbib
Schönbeinstrasse 18-20
4056 Basel, Schweiz
Tel.: +41 61 267 31 12 
Fax: +41 61 267 31 03
E-Mail [hidden email]
URL www.swissbib.org

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|

Re: new initDynamicDebug method

Günter Hipler
Hi Demian,
thanks for the quick patch, this works now - and thanks for background information.


I try to take part at the Developer call tomorrow. I have to use the telephone equipment. Other possibilities are not available for us at the moment.

Günter


On 11/09/2015 05:36 PM, Demian Katz wrote:

Günter,

 

Sorry about the bug – your fix makes sense and has been applied to master.

 

This relates to a requested feature that adding ?debug=true to the URL can be used to dynamically enable debug mode. The reason this is handled in the bootstrapper is that the dynamic debug mode is tied to a permission (because we don’t want “just anyone” turning on this setting and potentially exposing sensitive information). We can’t resolve the permission in the factory for the logger, because it would create a circular dependency (can’t have the logger dependent on the permission system, because parts of the permission system are already dependent on the logger).

 

Perhaps the whole thing is ill-conceived – but it seemed potentially useful, so  I threw together a simple implementation on Friday (clearly without giving it sufficient thought).

 

- Demian

 

From: Günter Hipler [[hidden email]]
Sent: Monday, November 09, 2015 11:09 AM
To: [hidden email]
Subject: [VuFind-Tech] new initDynamicDebug method

 

Hi,

after we deployed a version based on VuFind 2.5 last month I just merged the latest master code into our development branch.
I got in trouble with the new initDynamicDebug method in Bootstrapper using our Application in Console mode.
Could it be there is a Condition missing asking for console mode because in Console mode we don't have any Request object. (as it is done in other init Methods of Bootstrapper)

By the way: what is the background for this method?

Thanks!
Günter

/**
 * Initialize dynamic debug mode.
 *
 * @return void
 */
protected function initDynamicDebug()
{
 
//not part of the current code                 
    if (Console::isConsole()) {
        return;
    }
 
 
    $app = $this->event->getApplication();
    $sm = $app->getServiceManager();
    $debugOverride = $sm->get('Request')->getQuery()->get('de
 bug');
    if ($debugOverride) {
        $auth = $sm->get('ZfcRbac\Service\AuthorizationService');
        if ($auth->isGranted('access.DebugMode')) {
            $logger = $sm->get('VuFind\Logger');
            $logger->addDebugWriter($debugOverride);
        }
    }
}




-- 
UNIVERSITÄT BASEL
Universitätsbibliothek
Günter Hipler
Projekt swissbib
Schönbeinstrasse 18-20
4056 Basel, Schweiz
Tel.: +41 61 267 31 12 
Fax: +41 61 267 31 03
E-Mail [hidden email]
URL www.swissbib.org

-- 
UNIVERSITÄT BASEL
Universitätsbibliothek
Günter Hipler
Projekt swissbib
Schönbeinstrasse 18-20
4056 Basel, Schweiz
Tel.: +41 61 267 31 12 
Fax: +41 61 267 31 03
E-Mail [hidden email]
URL www.swissbib.org

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech