Moodle

cron.php executed on the CLI makes output to STDERR

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.3
  • Fix Version/s: 1.9.4
  • Component/s: Administration
  • Labels:
    None
  • Environment:
    Unix + PHP 5.2.6
  • Database:
    Any
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

I am executing cron.php the recommended way - via PHP's CLI instead of accessing it with a browser, having browser access completely disallowed (Site Administration -> Security -> Site policies -> Cron execution via command line only: Yes). My crontab entry is:

*/30 * * * * php -d safe_mode="off" -d open_basedir="" /path_to/moodle/admin/cron.php > /dev/null

However, this writes a warning to STDOUT, which will then get emailed every time:
PHP Notice: Undefined index: REMOTE_ADDR in /path_to/moodle/lib/moodlelib.php on line 7513

The notice of course does not harm, it is annoying however to receive all these emails. Thus, the code should be cleaned ensuring not producing any notice/warning.

Activity

Hide
Robert Allerstorfer added a comment -

The attached patch fixes this bug.

Show
Robert Allerstorfer added a comment - The attached patch fixes this bug.
Hide
Eloy Lafuente (stronk7) added a comment -

Addressing for 1.9.4+ and assigning to Dongsheng. Patch looks fine IMO. Thanks Robert!

Show
Eloy Lafuente (stronk7) added a comment - Addressing for 1.9.4+ and assigning to Dongsheng. Patch looks fine IMO. Thanks Robert!
Hide
Dongsheng Cai added a comment -

Thanks, Robert, please review.

Show
Dongsheng Cai added a comment - Thanks, Robert, please review.
Hide
Tatsuya Shirai added a comment -

The same notice occurs in function getremoteaddr() when admin/cron.php is executed via PHP's CLI.

return cleanremoteaddr($_SERVER['REMOTE_ADDR']);

Futrhermore, if any errors are happened while cron process is running, null data is recorded in the IPaddress cell of log table (mdl_log)...

Show
Tatsuya Shirai added a comment - The same notice occurs in function getremoteaddr() when admin/cron.php is executed via PHP's CLI. return cleanremoteaddr($_SERVER['REMOTE_ADDR']); Futrhermore, if any errors are happened while cron process is running, null data is recorded in the IPaddress cell of log table (mdl_log)...
Hide
Dongsheng Cai added a comment -

Thanks for your report, Tatsuya, I fixed these on CVS.

Show
Dongsheng Cai added a comment - Thanks for your report, Tatsuya, I fixed these on CVS.
Hide
Petr Škoda (skodak) added a comment -

reviewed, thanks

Show
Petr Škoda (skodak) added a comment - reviewed, thanks

Dates

  • Created:
    Updated:
    Resolved: