Moodle
  1. Moodle
  2. MDL-16371

patch: support for firePHP debuging aid tool in firefox

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.2
    • Fix Version/s: None
    • Component/s: Libraries
    • Labels:
    • Environment:
      apache 2 , php 5 , mysql 5 , moodle 1.9.2
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      656

      Description

      i have added php debugging support into moodle that uses the firePHP (firebug) extension

      it needs review because it has very basic functionality. and it only implemented for debugging()

      first you have to be using firefox then download firebug and then add firephp.
      see instructions: http://www.firephp.org/Wiki/Main/QuickStart

      i have downloaded the "FirePHP Core Library" from http://www.firephp.org/ and placed it under moodle/lib
      in the folder /moodle/lib/FirePHPCore (three files : fb.php , FirePHP.class.php , LICENSE )

      i added a new "echo" to firePHP function in /moodle/lib/weblib.php called echo_fb() and changed debugging() a little bit
      to echo its output to firePHP as well.

      here is the echo_fb:

      /**

      • echo some firePHP debug info plus internal system variables
      • @param string $msg - some text message to output
      • @param string $var - variable array we wish to see in firebug php
      • @param integer $level - warrning level (as used in FirePHP presets
        */
        function echo_fb($msg, $var=NULL, $level=0) {
        global $CFG;
        require_once($CFG->libdir.'/FirePHPCore/FirePHP.class.php');
        ob_start();

      $firephp = FirePHP::getInstance(true);

      if ($level == 0)

      { $level = FirePHP::WARN; }

      $firephp->fb($msg,array($var),$level);
      ob_end_clean();
      }

      and here is a patched debugging() function:
      function debugging($message='', $level=DEBUG_NORMAL) {

      global $CFG, $USER;

      if (empty($CFG->debug))

      { return false; }

      //nadavkav
      //echo 'debugging for admin user = '.$USER->id == 2 ONLY;
      if ($CFG->debug >= $level && $USER->id == 2) {
      if ($message) {
      $callers = debug_backtrace();
      $from = '<ul style="direction: ltr; text-align: left">';
      foreach ($callers as $caller) {
      $fb_log = '';
      $fb_log_ct = '';
      if (!isset($caller['line']))

      { $caller['line'] = '?'; // probably call_user_func() }

      if (!isset($caller['file']))

      { $caller['file'] = $CFG->dirroot.'/unknownfile'; // probably call_user_func() }

      $from .= '<li>line ' . $caller['line'] . ' of ' . substr($caller['file'], strlen($CFG->dirroot) + 1);
      if (isset($caller['function'])) {
      $from .= ': call to ';
      if (isset($caller['class']))

      { $from .= $caller['class'] . $caller['type']; $fb_log_ct = $caller['class'] . $caller['type']; }

      $from .= $caller['function'] . '()';
      }
      $from .= '</li>';
      $fb_log = 'line[' . $caller['line'] . '] file[' . $caller['file'] . '] func[' . $fb_log_ct . $caller['function'] . ']';
      }
      $from .= '</ul>';
      if (!isset($CFG->debugdisplay))

      { $CFG->debugdisplay = ini_get_bool('display_errors'); }

      if ($CFG->debugdisplay) {
      if (!defined('DEBUGGING_PRINTED'))

      { define('DEBUGGING_PRINTED', 1); // indicates we have printed something }

      notify($message . $from, 'notifytiny');
      echo_fb($fb_log,array($callers));
      } else

      { trigger_error($message . $from, E_USER_NOTICE); }

      }
      return true;
      }
      return false;
      }

      you can notice i have debugging displayed only for Admin (userid == 2)
      if you do not like this, please ignore it and remove it
      (many teachers complained that they see the warnings when i "work" on the moodle code,
      so i set it this way so only i can see them)

      i am attaching a capture screen to show how useful it is to display the contents of php variables
      i just put the variable in the echo_fb msg (as an arry()) and it is visible to the firephp

      hope you like too

      1. patch-16371-firephp.patch
        30 kB
        Mathieu Petit-Clair
      1. moodle-firephp.jpg
        103 kB

        Activity

        Nadav Kavalerchik created issue -
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Assigning this to Petr and adding watchers.... as we are changing debugging(), print_error(), exceptions and so on... perhaps this could be a nice add for 2.0

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Assigning this to Petr and adding watchers.... as we are changing debugging(), print_error(), exceptions and so on... perhaps this could be a nice add for 2.0 Ciao
        Eloy Lafuente (stronk7) made changes -
        Field Original Value New Value
        Assignee Eloy Lafuente (stronk7) [ stronk7 ] Petr Skoda [ skodak ]
        Hide
        Martin Dougiamas added a comment -

        Love it. Please can we get this in 2.0? Perhaps triggered by the same $CFG->developmentsite = true setting we talked about for unit testing.

        Show
        Martin Dougiamas added a comment - Love it. Please can we get this in 2.0? Perhaps triggered by the same $CFG->developmentsite = true setting we talked about for unit testing.
        Martin Dougiamas made changes -
        Fix Version/s 2.0 [ 10122 ]
        Hide
        Mathieu Petit-Clair added a comment -

        Attaching a patch (against 2.0) for this, including the latest FirePHP code. A new admin setting for this would be nice.

        Works fine for me.

        Show
        Mathieu Petit-Clair added a comment - Attaching a patch (against 2.0) for this, including the latest FirePHP code. A new admin setting for this would be nice. Works fine for me.
        Mathieu Petit-Clair made changes -
        Attachment patch-16371-firephp.patch [ 15099 ]
        Petr Škoda made changes -
        Security Could be a security issue [ 10030 ]
        Hide
        Mathieu Petit-Clair added a comment -

        A few comments, after testing this a bit:
        1) In the patch, I removed the check for the current userid .. but it creates a problem if the current user does not have the firephp extension installed.
        2) in some cases, the call to notify() breaks the firephp output
        3) this feature is (in this patch) linked to $CFG->debugdisplay, it would be nice to have a separate setting for it

        Show
        Mathieu Petit-Clair added a comment - A few comments, after testing this a bit: 1) In the patch, I removed the check for the current userid .. but it creates a problem if the current user does not have the firephp extension installed. 2) in some cases, the call to notify() breaks the firephp output 3) this feature is (in this patch) linked to $CFG->debugdisplay, it would be nice to have a separate setting for it
        Hide
        Dongsheng Cai added a comment -

        Cool! Thanks!

        Show
        Dongsheng Cai added a comment - Cool! Thanks!
        Hide
        Mathieu Petit-Clair added a comment -

        To add some more on "2)" in my comment above, the case where it breaks is when debugging stuff sent back on ajax calls.

        Show
        Mathieu Petit-Clair added a comment - To add some more on "2)" in my comment above, the case where it breaks is when debugging stuff sent back on ajax calls.
        Hide
        Christoph Dorn added a comment -

        Hi everyone,

        I am the author of FirePHP.

        Great to see that you are integrating FirePHP into Moodle.

        If you run into any problems or have any questions about FirePHP, please let me know. Best place to post feedback/questions would be here:

        http://n2.nabble.com/Framework-Integrations-f1111809ef842658.html

        When the integration is released with Moodle 2.0 let me know so I can add a link to it on the FirePHP wiki.

        Christoph

        Show
        Christoph Dorn added a comment - Hi everyone, I am the author of FirePHP. Great to see that you are integrating FirePHP into Moodle. If you run into any problems or have any questions about FirePHP, please let me know. Best place to post feedback/questions would be here: http://n2.nabble.com/Framework-Integrations-f1111809ef842658.html When the integration is released with Moodle 2.0 let me know so I can add a link to it on the FirePHP wiki. Christoph
        Hide
        Frank Ralf added a comment -

        Hi,

        I created a plugin which provides some basic FirePHP integration for Moodle, see http://moodle.org/mod/forum/discuss.php?d=119961
        It's still work in progress so any comments and suggestions for improvements are welcome!

        Frank

        Show
        Frank Ralf added a comment - Hi, I created a plugin which provides some basic FirePHP integration for Moodle, see http://moodle.org/mod/forum/discuss.php?d=119961 It's still work in progress so any comments and suggestions for improvements are welcome! Frank
        Martin Dougiamas made changes -
        Fix Version/s 2.0.1 [ 10420 ]
        Fix Version/s 2.0 [ 10122 ]
        Martin Dougiamas made changes -
        Workflow jira [ 28309 ] MDL Workflow [ 43861 ]
        Petr Škoda made changes -
        Assignee Petr Škoda (skodak) [ skodak ] moodle.com [ moodle.com ]
        Fix Version/s DEV backlog [ 10464 ]
        Fix Version/s 2.0.1 [ 10420 ]
        Hide
        Dongsheng Cai added a comment -

        I have been using this for nearly two years, it is very helpfully for ajax debuging.

        Show
        Dongsheng Cai added a comment - I have been using this for nearly two years, it is very helpfully for ajax debuging.
        Hide
        Nadav Kavalerchik added a comment -

        Several months ago, i have installed phpStorm and xdebug on the Apache server
        since then, life was changed and debugging php became "a walk in the park"

        I encourage everyone to check it out

        phpStorm: http://www.jetbrains.com/phpstorm/

        free open source project license:
        http://www.jetbrains.com/phpstorm/buy/buy.jsp#opensource_

        xdebug: http://www.xdebug.org/

        + css-x-fire extenstion to firebug + plugin to phpStorm
        Connects Firebug CSS editor with any IDE with CSS capabilities
        http://plugins.intellij.net/plugin/?ruby&id=5348

        Show
        Nadav Kavalerchik added a comment - Several months ago, i have installed phpStorm and xdebug on the Apache server since then, life was changed and debugging php became "a walk in the park" I encourage everyone to check it out phpStorm: http://www.jetbrains.com/phpstorm/ free open source project license: http://www.jetbrains.com/phpstorm/buy/buy.jsp#opensource_ xdebug: http://www.xdebug.org/ + css-x-fire extenstion to firebug + plugin to phpStorm Connects Firebug CSS editor with any IDE with CSS capabilities http://plugins.intellij.net/plugin/?ruby&id=5348
        Martin Dougiamas made changes -
        Workflow MDL Workflow [ 43861 ] MDL Full Workflow [ 72247 ]
        Hide
        Frank Ralf added a comment -

        JFTR

        The FirePHP block mentioned above is now available at http://moodle.org/mod/data/view.php?d=13&rid=4793 and https://github.com/nakohdo/moodle-block_firephp

        Show
        Frank Ralf added a comment - JFTR The FirePHP block mentioned above is now available at http://moodle.org/mod/data/view.php?d=13&rid=4793 and https://github.com/nakohdo/moodle-block_firephp
        Hide
        Anthony Borrow added a comment -

        Nadav - I had tried to get the open source license; however, I received the following reply:

        "The issue is that, like I mentioned earlier to Jérôme Mouneyrac, unfortunately we can't provide you with Open Source license, since one of our key OS license terms states: 'You qualify for a
        free license if you do not perform any paid support, consulting or training services for your open source software'. (http://www.jetbrains.com/phpstorm/buy/buy.jsp#opensource_)"

        As I recall, it was determined for that reason that Moodle HQ did not qualify for the open source license. I don't think that I pushed the issue that I do not get paid. I decided to stick with an open source IDE.

        There seemed to be some enthusiasm for getting this into 2.0. It seems somewhat related to the work that Rajesh is doing with a data generator (only in the sense that it prepares a good development environment). Rajesh is working on data generation and this deals with setting up a nice interface for working with the code.

        Peace - Anthony

        Show
        Anthony Borrow added a comment - Nadav - I had tried to get the open source license; however, I received the following reply: "The issue is that, like I mentioned earlier to Jérôme Mouneyrac, unfortunately we can't provide you with Open Source license, since one of our key OS license terms states: 'You qualify for a free license if you do not perform any paid support, consulting or training services for your open source software'. ( http://www.jetbrains.com/phpstorm/buy/buy.jsp#opensource_ )" As I recall, it was determined for that reason that Moodle HQ did not qualify for the open source license. I don't think that I pushed the issue that I do not get paid. I decided to stick with an open source IDE. There seemed to be some enthusiasm for getting this into 2.0. It seems somewhat related to the work that Rajesh is doing with a data generator (only in the sense that it prepares a good development environment). Rajesh is working on data generation and this deals with setting up a nice interface for working with the code. Peace - Anthony
        Hide
        Nadav Kavalerchik added a comment -

        Anthony - I paid 50$ for phpStorm but i know some developers, part of Academic institutes teams in Israel, that got a free open source license.

        btw, I have not used phpFire for alooooong time. I am using xdebug with phpStorm (you can use it with NetBeans too)
        As far as i concern, we can drop this issue, unless it is useful for anyone?

        Show
        Nadav Kavalerchik added a comment - Anthony - I paid 50$ for phpStorm but i know some developers, part of Academic institutes teams in Israel, that got a free open source license. btw, I have not used phpFire for alooooong time. I am using xdebug with phpStorm (you can use it with NetBeans too) As far as i concern, we can drop this issue, unless it is useful for anyone?
        Hide
        Anthony Borrow added a comment -

        There seemed to be some initial enthusiasm among some of the HQ developers. I am not sure if there is still interest. If not, perhaps we should move this to a CONTRIB issue and possibly see if Frank Ralf might be interested in maintaining the block. Peace - Anthony

        Show
        Anthony Borrow added a comment - There seemed to be some initial enthusiasm among some of the HQ developers. I am not sure if there is still interest. If not, perhaps we should move this to a CONTRIB issue and possibly see if Frank Ralf might be interested in maintaining the block. Peace - Anthony
        Hide
        Michael de Raadt added a comment -

        This seems like a useful tool.

        I'm inclined to say that the best place for this is in CONTRIB rather than core, primarily because it relies on the FirePHP framework. I don't think that would make it any less significant; the code checker from OU is a good example of that.

        Show
        Michael de Raadt added a comment - This seems like a useful tool. I'm inclined to say that the best place for this is in CONTRIB rather than core, primarily because it relies on the FirePHP framework. I don't think that would make it any less significant; the code checker from OU is a good example of that.
        Hide
        Frank Ralf added a comment -

        I'm not a heavy user of the FirePHP block myself (yet) but I will try to keep the block in working condition with current Moodle releases

        Show
        Frank Ralf added a comment - I'm not a heavy user of the FirePHP block myself (yet) but I will try to keep the block in working condition with current Moodle releases
        Michael de Raadt made changes -
        Labels plugin-candidate
        Hide
        Michael de Raadt added a comment -

        It would be great if you could share this in the Plugins Directory. We are trying to make it easier for people to access plugins from there.

        For now I am closing this issue in the hope that someone will take on the responsibility for this plugin candidate.

        Show
        Michael de Raadt added a comment - It would be great if you could share this in the Plugins Directory. We are trying to make it easier for people to access plugins from there. For now I am closing this issue in the hope that someone will take on the responsibility for this plugin candidate.
        Michael de Raadt made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s DEV backlog [ 10464 ]
        Resolution Won't Fix [ 2 ]
        Michael de Raadt made changes -
        Labels plugin-candidate addon-candidate
        Michael de Raadt made changes -
        Labels addon-candidate addon_candidate
        Hide
        Frank Ralf added a comment -

        Michael, I will try to move the plugin to the new Plugins Directory as soon as I find the time.

        Show
        Frank Ralf added a comment - Michael, I will try to move the plugin to the new Plugins Directory as soon as I find the time.
        Hide
        Frank Ralf added a comment -
        Show
        Frank Ralf added a comment - I did it https://moodle.org/plugins/view.php?plugin=block_firephp (awaiting approval)
        Hide
        Michael de Raadt added a comment -

        Well done, Frank.

        Show
        Michael de Raadt added a comment - Well done, Frank.
        Hide
        Aparup Banerjee added a comment -

        Thanks Frank! (had dropped by to drop the link but i see its already here :-D)

        Show
        Aparup Banerjee added a comment - Thanks Frank! (had dropped by to drop the link but i see its already here :-D)

          People

          • Votes:
            4 Vote for this issue
            Watchers:
            14 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: