Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.2, 2.2, 2.2.5, 2.3.2, 2.4
    • Fix Version/s: 2.2.6, 2.3.3
    • Component/s: Chat
    • Labels:
      None
    • Environment:
      Debian Linux amd64.2.6.32-5
    • Database:
      PostgreSQL
    • Testing Instructions:
      Hide

      To test this issue properly MDL-34068 and MDL-35264 must be also integrated

      1. Open a terminal
      2. cd mod/chat
      3. php chatd.php --start
      4. You SHOULD NOT see a "Command line scripts must define CLI_SCRIPT before requiring config.php" error
      5. Open a browser and login as an admin user
      6. Go to admin tree -> Plugins -> Activity modules -> Chat
      7. Set chat_method to "Chat server daemon"
      8. Go to a course and add a chat module instance
      9. Go to the chat instance and click "Click here to enter the chat now"
      10. You SHOULD be able to see a popup window divided in 3 frames without any 404 error message in any frame
      Show
      To test this issue properly MDL-34068 and MDL-35264 must be also integrated Open a terminal cd mod/chat php chatd.php --start You SHOULD NOT see a "Command line scripts must define CLI_SCRIPT before requiring config.php" error Open a browser and login as an admin user Go to admin tree -> Plugins -> Activity modules -> Chat Set chat_method to "Chat server daemon" Go to a course and add a chat module instance Go to the chat instance and click "Click here to enter the chat now" You SHOULD be able to see a popup window divided in 3 frames without any 404 error message in any frame
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-27398_master
    • Rank:
      17087

      Description

      Hi,

      when I try to start chat daemon, chatd.php, with "php moodle/mod/chat/chatd.php --start"
      I obatin:
      "
      Moodle chat daemon v1.0 on PHP 5.3.3-7+squeeze1

      Command line scripts must define CLI_SCRIPT before requiring config.php
      "

      and I can't see the chat if I try to enter.

      Issue renamed, old name for the record: "chatd.php and define CLI_SCRIPT"

        Issue Links

          Activity

          Hide
          Jorge Villalon added a comment -

          Hi.
          I just run into the same problem. I fixed it by adding the line:

          define('CLI_SCRIPT', true);
          

          Just before the first instruction in chatd.php, so my first four lines look like:

          #!/usr/bin/php -q
          <?php
          
          define('CLI_SCRIPT', true);
          
          Show
          Jorge Villalon added a comment - Hi. I just run into the same problem. I fixed it by adding the line: define('CLI_SCRIPT', true); Just before the first instruction in chatd.php, so my first four lines look like: #!/usr/bin/php -q <?php define('CLI_SCRIPT', true);
          Hide
          Jorge Villalon added a comment -

          Well, that wasn't enough. Right after that I got an exception for the allow_call_time_pass_reference directive in the php.ini configuration file. According to http://php.net/manual/en/ini.core.php that setting is deprecated on 5.3.x therefore I commented out the following lines in chatd.php:

          //$passref = ini_get('allow_call_time_pass_reference');
          //if(empty($passref)) {
              //die("Error: Cannot run with PHP allow_call_time_pass_reference = Off. Turn on allow_call_time_pass_reference in php.ini.\n");
          //}
          

          Now the server started, and I was able to get into the room, however an exception was rised:

           The theme has already been set up for this page ready for output. Therefore, you can no longer change the theme, or anything that might affect what the current theme is, for example, the course. Debug: Stack trace when the theme was set up: <ul style="text-align: left"><li>line 1236 of /lib/setuplib.php: call to moodle_page->initialise_theme_and_output()</li><li>line 771 of /mod/chat/lib.php: call to bootstrap_renderer->__call()</li><li>line 771 of /mod/chat/lib.php: call to bootstrap_renderer->user_picture()</li><li>line 731 of /mod/chat/chatd.php: call to chat_format_message_manually()</li><li>line 559 of /mod/chat/chatd.php: call to ChatDaemon->message_broadcast()</li><li>line 606 of /mod/chat/chatd.php: call to ChatDaemon->promote_final()</li><li>line 1060 of /mod/chat/chatd.php: call to ChatDaemon->promote_ufo()</li></ul>
          * line 1502 of /lib/pagelib.php: coding_exception thrown
          * line 727 of /lib/pagelib.php: call to moodle_page->ensure_theme_not_set()
          * line 235 of /mod/chat/chatd.php: call to moodle_page->set_course()
          * line 382 of /mod/chat/chatd.php: call to ChatDaemon->get_user_window()
          * line 577 of /mod/chat/chatd.php: call to ChatDaemon->dispatch_sidekick()
          * line 1060 of /mod/chat/chatd.php: call to ChatDaemon->promote_ufo()
          

          This has to do with the theme used in the chat page. I'll try to do more, but this looks a bit more complex.

          Show
          Jorge Villalon added a comment - Well, that wasn't enough. Right after that I got an exception for the allow_call_time_pass_reference directive in the php.ini configuration file. According to http://php.net/manual/en/ini.core.php that setting is deprecated on 5.3.x therefore I commented out the following lines in chatd.php: //$passref = ini_get('allow_call_time_pass_reference'); //if(empty($passref)) { //die("Error: Cannot run with PHP allow_call_time_pass_reference = Off. Turn on allow_call_time_pass_reference in php.ini.\n"); //} Now the server started, and I was able to get into the room, however an exception was rised: The theme has already been set up for this page ready for output. Therefore, you can no longer change the theme, or anything that might affect what the current theme is, for example, the course. Debug: Stack trace when the theme was set up: <ul style="text-align: left"><li>line 1236 of /lib/setuplib.php: call to moodle_page->initialise_theme_and_output()</li><li>line 771 of /mod/chat/lib.php: call to bootstrap_renderer->__call()</li><li>line 771 of /mod/chat/lib.php: call to bootstrap_renderer->user_picture()</li><li>line 731 of /mod/chat/chatd.php: call to chat_format_message_manually()</li><li>line 559 of /mod/chat/chatd.php: call to ChatDaemon->message_broadcast()</li><li>line 606 of /mod/chat/chatd.php: call to ChatDaemon->promote_final()</li><li>line 1060 of /mod/chat/chatd.php: call to ChatDaemon->promote_ufo()</li></ul> * line 1502 of /lib/pagelib.php: coding_exception thrown * line 727 of /lib/pagelib.php: call to moodle_page->ensure_theme_not_set() * line 235 of /mod/chat/chatd.php: call to moodle_page->set_course() * line 382 of /mod/chat/chatd.php: call to ChatDaemon->get_user_window() * line 577 of /mod/chat/chatd.php: call to ChatDaemon->dispatch_sidekick() * line 1060 of /mod/chat/chatd.php: call to ChatDaemon->promote_ufo() This has to do with the theme used in the chat page. I'll try to do more, but this looks a bit more complex.
          Hide
          Jorge Villalon added a comment -

          Moving further a little bit. I checked that the chatd.php code which tries to set the page course which is already set, that's why the exception, I commented out the following lines in chatd.php:

                  $info = &$this->sets_info[$sessionid];
                  //$PAGE->set_course($info['course']);
          

          and

                          // Simply give them the message
                          //$PAGE->set_course($info['course']);
          

          Now the chat server is working, but I'm getting a few more errors in the logs:

          PHP Notice:  Constant NO_MOODLE_COOKIES already defined in /opt/moodle/lib/setup.php on line 653
          
          Notice: Constant NO_MOODLE_COOKIES already defined in /opt/moodle/lib/setup.php on line 653
          

          and

          [2011-06-26 16:51:26]  *CRITICAL* [php] Undefined index: 01b8910YAfIgopMCsX4QwRHJ8e3vc1P2 on line 130
          [2011-06-26 16:51:26]  *CRITICAL* [php] Trying to get property of non-object on line 130
          [2011-06-26 16:51:26]  *CRITICAL* [php] Undefined index: 01b8910YAfIgopMCsX4QwRHJ8e3vc1P2 on line 133
          

          Any ideas?

          Show
          Jorge Villalon added a comment - Moving further a little bit. I checked that the chatd.php code which tries to set the page course which is already set, that's why the exception, I commented out the following lines in chatd.php: $info = &$this->sets_info[$sessionid]; //$PAGE->set_course($info['course']); and // Simply give them the message //$PAGE->set_course($info['course']); Now the chat server is working, but I'm getting a few more errors in the logs: PHP Notice: Constant NO_MOODLE_COOKIES already defined in /opt/moodle/lib/setup.php on line 653 Notice: Constant NO_MOODLE_COOKIES already defined in /opt/moodle/lib/setup.php on line 653 and [2011-06-26 16:51:26] *CRITICAL* [php] Undefined index: 01b8910YAfIgopMCsX4QwRHJ8e3vc1P2 on line 130 [2011-06-26 16:51:26] *CRITICAL* [php] Trying to get property of non-object on line 130 [2011-06-26 16:51:26] *CRITICAL* [php] Undefined index: 01b8910YAfIgopMCsX4QwRHJ8e3vc1P2 on line 133 Any ideas?
          Hide
          Lucas P added a comment -

          I'm facing exactly the same issue.

          Show
          Lucas P added a comment - I'm facing exactly the same issue.
          Hide
          Lucas P added a comment -

          No one? We'll soon celebrate the anniversary of this issue...

          Show
          Lucas P added a comment - No one? We'll soon celebrate the anniversary of this issue...
          Hide
          Lucas P added a comment - - edited

          Jorge,

          Have you been able to actually use the chat through the web interface? After commenting that "set_course" line I don't get the input field to type the message.

          Aditionally, this is still happening on 2.2.3 (Build: 20120514).

          Show
          Lucas P added a comment - - edited Jorge, Have you been able to actually use the chat through the web interface? After commenting that "set_course" line I don't get the input field to type the message. Aditionally, this is still happening on 2.2.3 (Build: 20120514).
          Hide
          Lucas P added a comment -

          Moodle CHATD without the Input area.

          It's actually being hidden by the "breadcrumb", which for whatever reason is being rendered.

          Show
          Lucas P added a comment - Moodle CHATD without the Input area. It's actually being hidden by the "breadcrumb", which for whatever reason is being rendered.
          Hide
          Lucas P added a comment -

          Hmmm... maybe its related to mod/chat/gui_sockets/chatinput.php ?

          Show
          Lucas P added a comment - Hmmm... maybe its related to mod/chat/gui_sockets/chatinput.php ?
          Hide
          David Monllaó added a comment -

          Hola,

          I've attached the patch for the CLI_SCRIPT problem, the related issues you mention should be addressed on other issues; it seems that the chat daemon requires a deep review to work properly. Submitting for peer review

          Gracias a todos por las contribuciones

          Show
          David Monllaó added a comment - Hola, I've attached the patch for the CLI_SCRIPT problem, the related issues you mention should be addressed on other issues; it seems that the chat daemon requires a deep review to work properly. Submitting for peer review Gracias a todos por las contribuciones
          Hide
          David Monllaó added a comment -

          Waiting for the peer review / integrators comments, with this patch the chat daemon will run but I'm not confident that this will make it usable. Requesting feedback since I don't know if all the issues should be patch together or not

          Show
          David Monllaó added a comment - Waiting for the peer review / integrators comments, with this patch the chat daemon will run but I'm not confident that this will make it usable. Requesting feedback since I don't know if all the issues should be patch together or not
          Hide
          Frédéric Massart added a comment -

          Hi David,

          I have seen your patch, but unfortunately this does not allow me to run the daemon. IMO, this issue should fix the chat daemon except if another issue already exist for it.

          As Jorge, I have noticed that duplicated NO_MOODLE_COOKIES which is not required as CLI_SCRIPT will force it as true.

          The include of config.php should also use dirname() and be included right after the definition of CLI_SCRIPT, at the top of the document.

          I quite dislike the echo of the version of PHP and this is an unnecessary information disclosure (open the URL in your browser). But in fact this should be fixed if the config.php include is moved to the top. (mtrace() might be a better choice than echo in CLI scripts)

          Regarding the ini_get('allow_call_time_pass_reference') I had to comment it to run the server as well, but I have no idea why it is there in the first place, needs investigation.

          I'd also remove the shebang #!/usr/bin/php -q as we're not using it in our usual CLI. Although, if we decide to backport this issue, which we should I think, you might want not leave the shebang in previous versions.

          I can't think of anything else, but while you are it you can add the copyright header I suppose

          Show
          Frédéric Massart added a comment - Hi David, I have seen your patch, but unfortunately this does not allow me to run the daemon. IMO, this issue should fix the chat daemon except if another issue already exist for it. As Jorge, I have noticed that duplicated NO_MOODLE_COOKIES which is not required as CLI_SCRIPT will force it as true. The include of config.php should also use dirname() and be included right after the definition of CLI_SCRIPT, at the top of the document. I quite dislike the echo of the version of PHP and this is an unnecessary information disclosure (open the URL in your browser). But in fact this should be fixed if the config.php include is moved to the top. (mtrace() might be a better choice than echo in CLI scripts) Regarding the ini_get('allow_call_time_pass_reference') I had to comment it to run the server as well, but I have no idea why it is there in the first place, needs investigation. I'd also remove the shebang #!/usr/bin/php -q as we're not using it in our usual CLI. Although, if we decide to backport this issue, which we should I think, you might want not leave the shebang in previous versions. I can't think of anything else, but while you are it you can add the copyright header I suppose
          Hide
          David Monllaó added a comment -

          Thanks for your comments Frédéric, my previous work in this issue was just to being able to test MDL-29463. I've updated the patch and cleaned up old dependencies already covered by moodle 2 requirements.

          Comments:

          • I didn't find any old-styled function call passing arguments by reference in chatd
          • Moodle requires magic_quotes_runtime = off
          • Moodle 2.2, 2.3 and master requires 5.3.2

          About the PHP version echo, I agree with you that mtrace() is more appropriate, but IMO changing the notifications of the chat daemon is not part of this issue, feel free to create a new issue about it if you think more work should be done in this aspect.

          Show
          David Monllaó added a comment - Thanks for your comments Frédéric, my previous work in this issue was just to being able to test MDL-29463 . I've updated the patch and cleaned up old dependencies already covered by moodle 2 requirements. Comments: I didn't find any old-styled function call passing arguments by reference in chatd Moodle requires magic_quotes_runtime = off Moodle 2.2, 2.3 and master requires 5.3.2 About the PHP version echo, I agree with you that mtrace() is more appropriate, but IMO changing the notifications of the chat daemon is not part of this issue, feel free to create a new issue about it if you think more work should be done in this aspect.
          Hide
          David Monllaó added a comment -

          Changing the name according to the problems found during the work on the issue (thanks for Jorge Villalon and Lucas P)

          Show
          David Monllaó added a comment - Changing the name according to the problems found during the work on the issue (thanks for Jorge Villalon and Lucas P)
          Hide
          Frédéric Massart added a comment -

          Hi David,

          your patch looks good, although it is a bit tricky to test as it seems that the chat is broken all over the place.

          • On Firefox, the chat content is displayed as text/plain which makes is unreadable
          • On Chromium, the text field to add a message is not displayed (or hidden somewhere)

          You might want to set some issues as blocker to this one, so that once the daemon is fixed we can test its functionality properly.

          Also, to launch the daemon, I had to to use `php chatd.php --start`.

          So to summarise, your patch does not need any more work, but we need to be able to test its efficiency.

          Thank you.

          Show
          Frédéric Massart added a comment - Hi David, your patch looks good, although it is a bit tricky to test as it seems that the chat is broken all over the place. On Firefox, the chat content is displayed as text/plain which makes is unreadable On Chromium, the text field to add a message is not displayed (or hidden somewhere) You might want to set some issues as blocker to this one, so that once the daemon is fixed we can test its functionality properly. Also, to launch the daemon, I had to to use `php chatd.php --start`. So to summarise, your patch does not need any more work, but we need to be able to test its efficiency. Thank you.
          Hide
          David Monllaó added a comment -

          Thanks Fred, I removed the " (if you can't see the text input field inspect the code and change the frameset for rows="0, *, 90")" part of the testing instructions and I've added two issues blocked by this one, they all should be integrated at the same time to test it all together.

          Show
          David Monllaó added a comment - Thanks Fred, I removed the " (if you can't see the text input field inspect the code and change the frameset for rows="0, *, 90")" part of the testing instructions and I've added two issues blocked by this one, they all should be integrated at the same time to test it all together.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          David Monllaó added a comment -

          Rebased

          Show
          David Monllaó added a comment - Rebased
          Hide
          Aparup Banerjee added a comment -

          Thanks for your contributions here! This has been integrated into 22,23 and master now for testing.

          Show
          Aparup Banerjee added a comment - Thanks for your contributions here! This has been integrated into 22,23 and master now for testing.
          Hide
          Ankit Agarwal added a comment -

          Tested this with random browsers and themes. All working good.
          Thanks

          Show
          Ankit Agarwal added a comment - Tested this with random browsers and themes. All working good. Thanks
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Gutta cavat lapidem, non vi sed saepe cadendo - Ovidio

          This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads).

          Thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Gutta cavat lapidem, non vi sed saepe cadendo - Ovidio This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads). Thanks!

            People

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

              Dates

              • Created:
                Updated:
                Resolved: