Moodle

Mailout debugger utility

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9, 2.0
  • Fix Version/s: None
  • Component/s: Libraries
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE

Description

Creating a mailout debugger that acts like sendmail.

Activity

Hide
Martín Langhoff added a comment -

Brief howto at http://moodle.org/mod/forum/post.php?reply=349457

Quick rundown of the technique I've been using today to work in the guts of
forum cron with confidence...

  • Grab a production database, full of users with real emails, and real forum
    posts. Go, mangle those emails a bit just in case.
  • Make sure your dev machine doesn't have an MTA. It's safer that way...
  • Make sure $CFG->smtphost = '';
  • In your SQL utility, say: UPDATE mdl_forum_posts SET mailed=0 WHERE created
    > >= 1183611278 AND mailed!=0; UPDATE mdl_modules SET lastcron=0 WHERE
    name='forum';
  • On the commandline, run your cron script setting the sendmail_path: php -d
    sendmail_path=/path/to/modle/admin/mailout-debugger.php

So with this trick, I

  • Create a "baseline" run, and mv the log to baseline.log
  • Change the code wildly
  • Reset the 'mailed' flag and re-run the script
  • mv it to wip.log
  • Compare the new log with the baseline, skipping lines that have timestamps
    and other variant bits
  • Did what you wanted to change change? Other things, did they say the same?

To run the comparison with the proper exceptions, use

diff I '(-oi|boundary|-b|====)' baseline-B2.log wip-B2.log

You can use sdiff with the same commandline to get a nice side-by-side.

Show
Martín Langhoff added a comment - Brief howto at http://moodle.org/mod/forum/post.php?reply=349457 Quick rundown of the technique I've been using today to work in the guts of forum cron with confidence...
  • Grab a production database, full of users with real emails, and real forum posts. Go, mangle those emails a bit just in case.
  • Make sure your dev machine doesn't have an MTA. It's safer that way...
  • Make sure $CFG->smtphost = '';
  • In your SQL utility, say: UPDATE mdl_forum_posts SET mailed=0 WHERE created > >= 1183611278 AND mailed!=0; UPDATE mdl_modules SET lastcron=0 WHERE name='forum';
  • On the commandline, run your cron script setting the sendmail_path: php -d sendmail_path=/path/to/modle/admin/mailout-debugger.php
So with this trick, I
  • Create a "baseline" run, and mv the log to baseline.log
  • Change the code wildly
  • Reset the 'mailed' flag and re-run the script
  • mv it to wip.log
  • Compare the new log with the baseline, skipping lines that have timestamps and other variant bits
  • Did what you wanted to change change? Other things, did they say the same?
To run the comparison with the proper exceptions, use diff I '(-oi|boundary|-b|====)' baseline-B2.log wip-B2.log You can use sdiff with the same commandline to get a nice side-by-side.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: