Moodle
  1. Moodle
  2. MDL-28381

Moodle cron not completing if PHP not 5.3

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.2
    • Fix Version/s: 2.1.2
    • Component/s: Libraries, Questions, Quiz
    • Labels:
      None
    • Environment:
      Apache version 2.2.19
      PHP version 5.2.17
      MySQL version 5.1.52
      Architecture i686
      Operating system linux
    • Rank:
      18108

      Description

      While debugging cron (quiz email notifications were not being sent), I came across some an "unexpected T_PAAMAYIM_NEKUDOTAYIM" in the lib/cronlib.php - line 338:

      backup_cron_automated_helper::run_automated_backup();

      changed this to:

      $backup_cron_automated_helper->run_automated_backup();

      After correcting this instance, I received the same error in question/engine/lib.php - line 338 (?!) as well:
      return $class::get_required_behaviours();

      changed this to:

      return $class>>get_required_behaviours();

      And the cron script proceeded and I received quiz submission email notifications (finally). However, I am still receiving an error in my cron log:

      Starting processing the event queue...
      done.
      Starting the completion cron...
      Marking users as started
      Running completion_criteria_date->cron()
      Running completion_criteria_activity->cron()
      Running completion_criteria_duration->cron()
      Running completion_criteria_grade->cron()
      Running completion_criteria_course->cron()
      Aggregating completions
      done
      <br />
      <b>Notice</b>: Undefined variable: backup_cron_automated_helper in <b>/home/bugsbunny/public_html/moodle/lib/cronlib.php</b> on line <b>339</b><br />
      <br />
      <b>Fatal error</b>: Call to a member function run_automated_backup() on a non-object in <b>/home/bugsbunny/public_html/moodle/lib/cronlib.php</b> on line <b>339</b><br />

      It appears that I fixed the email notifications, but created this error in Not using the automated backup, however, it would be nice to figure this out and correct it.

        Activity

        Hide
        Dan Poltawski added a comment -

        Hi Rhett,

        I'm not seeing this issue - is this still an issue in the lastest verison?

        Show
        Dan Poltawski added a comment - Hi Rhett, I'm not seeing this issue - is this still an issue in the lastest verison?
        Hide
        Rhett Daniel added a comment -

        Any update on a fix for this issue?

        I have a new instance of Moodle 2.1.1 installed and still having problems with CLI cron. No quiz submission notifications. I was hoping for a fix by now so that I would not have to hack the cronlib.php.

        Show
        Rhett Daniel added a comment - Any update on a fix for this issue? I have a new instance of Moodle 2.1.1 installed and still having problems with CLI cron. No quiz submission notifications. I was hoping for a fix by now so that I would not have to hack the cronlib.php.
        Hide
        Dan Poltawski added a comment -

        Hi,

        I can't reproduce this issue - can you give any more detail?

        Show
        Dan Poltawski added a comment - Hi, I can't reproduce this issue - can you give any more detail?
        Hide
        Rhett Daniel added a comment -

        What kind of detail do you need?

        Standard Moodle install - Moodle 2.1.1+ (Build: 20110811)

        Hosted at Hostgator:

        Php 5.3.6
        MySQL 5.1.52

        Cron job:

        php -q /home/rhett/public_html/study.jonesroadchurch.org/admin/cli/cron.php > /home/rhett/public_html/study.jonesroadchurch.org/admin/cli/cron_log.log

        Output from the cron log:

        Server Time: Fri, 19 Aug 2011 14:00:01 -0500

        Cleaning up stale sessions
        Starting activity modules
        Processing module function assignment_cron ...... used 3 dbqueries
        ... used 0.01854681968689 seconds
        done.
        Processing module function forum_cron ...Starting digest processing...
        Cleaned old digest records
        ... used 3 dbqueries
        ... used 0.0022487640380859 seconds
        done.
        Processing module function scorm_cron ...... used 1 dbqueries
        ... used 0.0043599605560303 seconds
        done.
        Finished activity modules
        Starting blocks
        Processing cron function for rss_client....
        0 feeds refreshed (took 0.00051900000000005 seconds)
        done.
        Finished blocks
        Starting quiz reports
        Finished quiz reports
        Starting admin reports
        Finished admin reports
        Starting main gradebook job ...
        done.
        Starting processing the event queue...

        And it just hangs there on the event queue. I have seen other posts from folks who have the same issue.

        Let me know if there is anything else that I could provide that would help debug/reproduce.

        Show
        Rhett Daniel added a comment - What kind of detail do you need? Standard Moodle install - Moodle 2.1.1+ (Build: 20110811) Hosted at Hostgator: Php 5.3.6 MySQL 5.1.52 Cron job: php -q /home/rhett/public_html/study.jonesroadchurch.org/admin/cli/cron.php > /home/rhett/public_html/study.jonesroadchurch.org/admin/cli/cron_log.log Output from the cron log: Server Time: Fri, 19 Aug 2011 14:00:01 -0500 Cleaning up stale sessions Starting activity modules Processing module function assignment_cron ...... used 3 dbqueries ... used 0.01854681968689 seconds done. Processing module function forum_cron ...Starting digest processing... Cleaned old digest records ... used 3 dbqueries ... used 0.0022487640380859 seconds done. Processing module function scorm_cron ...... used 1 dbqueries ... used 0.0043599605560303 seconds done. Finished activity modules Starting blocks Processing cron function for rss_client.... 0 feeds refreshed (took 0.00051900000000005 seconds) done. Finished blocks Starting quiz reports Finished quiz reports Starting admin reports Finished admin reports Starting main gradebook job ... done. Starting processing the event queue... And it just hangs there on the event queue. I have seen other posts from folks who have the same issue. Let me know if there is anything else that I could provide that would help debug/reproduce.
        Hide
        Robert Northcutt added a comment -

        I am having a similar issue using 2.1.1+ (Aug 18 Release). Was getting the error message below in /moodle/admin/cli/error.log every 90 minutes (the first time the cron job tried to run automated backups after the backup "already running" timer expired). Earlier backups were not finishing and leaving some courses in "Error" or "Not Finished" state.

        moodle backup T_PAAMAYIM_NEKUDOTAYIM in /home/rlnmonta/public_html/moodle/question/engine/lib.php on line 338
        Potential coding error - existing temptables found when disposing

        I changed the "::" to "->" on line 338 in /question/engine/lib.php. The first time it ran after changing (about an hour ago), all course backups completed successfully, and no error were written to error.log in /admin/cli directory. I hope it did not break anything else.

        Show
        Robert Northcutt added a comment - I am having a similar issue using 2.1.1+ (Aug 18 Release). Was getting the error message below in /moodle/admin/cli/error.log every 90 minutes (the first time the cron job tried to run automated backups after the backup "already running" timer expired). Earlier backups were not finishing and leaving some courses in "Error" or "Not Finished" state. moodle backup T_PAAMAYIM_NEKUDOTAYIM in /home/rlnmonta/public_html/moodle/question/engine/lib.php on line 338 Potential coding error - existing temptables found when disposing I changed the "::" to "->" on line 338 in /question/engine/lib.php. The first time it ran after changing (about an hour ago), all course backups completed successfully, and no error were written to error.log in /admin/cli directory. I hope it did not break anything else.
        Hide
        Petr Škoda added a comment -

        Hello, could you please double check that you really are running at least PHP 5.3.2?

        The info above says PHP version 5.2.17....

        Show
        Petr Škoda added a comment - Hello, could you please double check that you really are running at least PHP 5.3.2? The info above says PHP version 5.2.17....
        Hide
        Robert Northcutt added a comment - - edited

        My environment: PHP Version 5.3.6 (from PHP info page in Moodle). Using .htaccess in Moodle home directory with:

        "AddHandler application/x-httpd-php53 php"

        Hosting provider configured to both PHP 5.2 (default) and PHP 5.3.

        Show
        Robert Northcutt added a comment - - edited My environment: PHP Version 5.3.6 (from PHP info page in Moodle). Using .htaccess in Moodle home directory with: "AddHandler application/x-httpd-php53 php" Hosting provider configured to both PHP 5.2 (default) and PHP 5.3.
        Hide
        Rhett Daniel added a comment -

        Petr,

        The environment info was taken from my Hostgator cPanel and is not accurate for the Moodle instance - I have the same handler as Robert's added to my .htaccess:

        AddHandler application/x-httpd-php53 .php

        And Moodle sees PHP 5.3:

        php version 5.3.2 is required and you are running 5.3.6

        Show
        Rhett Daniel added a comment - Petr, The environment info was taken from my Hostgator cPanel and is not accurate for the Moodle instance - I have the same handler as Robert's added to my .htaccess: AddHandler application/x-httpd-php53 .php And Moodle sees PHP 5.3: php version 5.3.2 is required and you are running 5.3.6
        Hide
        Petr Škoda added a comment -

        But does it use PHP 5.3.6 when running the cron from CLI?

        Show
        Petr Škoda added a comment - But does it use PHP 5.3.6 when running the cron from CLI?
        Hide
        Robert Northcutt added a comment -

        Petr, you are correct I believe that the cron job was being handled by PHP 5.2. My cron job was setup as "php /moodle/admin/cli/cron.php" and it should have been "/usr/bin/php53 ..." (per my host's directions). I have changed the cron call and changed line 338 in /question/engine/lib.php from "->" back to "::" (see my earlier change). I will watch for error.log the next time automated backup runs.

        Show
        Robert Northcutt added a comment - Petr, you are correct I believe that the cron job was being handled by PHP 5.2. My cron job was setup as "php /moodle/admin/cli/cron.php" and it should have been "/usr/bin/php53 ..." (per my host's directions). I have changed the cron call and changed line 338 in /question/engine/lib.php from "->" back to "::" (see my earlier change). I will watch for error.log the next time automated backup runs.
        Hide
        Robert Northcutt added a comment -

        Cron just ran the full automated backup successfully with no errors. Updating the cron job to "/usr/bin/php53" appears to have resolved this issue for me...but will continue to monitor over the next few days.

        Show
        Robert Northcutt added a comment - Cron just ran the full automated backup successfully with no errors. Updating the cron job to "/usr/bin/php53" appears to have resolved this issue for me...but will continue to monitor over the next few days.
        Hide
        Petr Škoda added a comment -

        Hmm, maybe we should detect PHP version in all CLI scripts - I suppose this problem is more widespread then I expected.

        Show
        Petr Škoda added a comment - Hmm, maybe we should detect PHP version in all CLI scripts - I suppose this problem is more widespread then I expected.
        Hide
        Robert Northcutt added a comment -

        Most hosting services seem to be lagging on the move to PHP 5.3 as the standard. I actually switched hosting providers just to have 5.3 available for Moodle 2.1. This may not be an issue in a year or two but it is right now. Making the underlying problem more visible in the error message would be helpful - detecting the PHP version as you suggest would do that.

        Show
        Robert Northcutt added a comment - Most hosting services seem to be lagging on the move to PHP 5.3 as the standard. I actually switched hosting providers just to have 5.3 available for Moodle 2.1. This may not be an issue in a year or two but it is right now. Making the underlying problem more visible in the error message would be helpful - detecting the PHP version as you suggest would do that.
        Hide
        Petr Škoda added a comment -

        Thanks for the detailed bug report and all cooperation!

        Show
        Petr Škoda added a comment - Thanks for the detailed bug report and all cooperation!
        Hide
        Rhett Daniel added a comment -

        Just wanted to report back and let you know that explicitly pointing to php53 worked for me as well.

        Thank you for your help!

        Show
        Rhett Daniel added a comment - Just wanted to report back and let you know that explicitly pointing to php53 worked for me as well. Thank you for your help!
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Integrated, thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Integrated, thanks!
        Hide
        Rajesh Taneja added a comment -

        Works Great
        Thanks for fixing this Petr.

        Show
        Rajesh Taneja added a comment - Works Great Thanks for fixing this Petr.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

        Show
        Eloy Lafuente (stronk7) added a comment - Many thanks for the hard work, this has been sent upstream and is available in all the git and cvs repositories.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: