Enrollments based on enrol/database are being dropped from courses during the cron.php run. This seems to occur only on courses which have an e-mail waiting to be sent, such as a subscribed forum post or news posting.
Expected behavior: Enrol/database enrolls according to the external database, with no other effects.
Actual behavior: Unenrollment (or other action set in enrol/database) occurs in courses with pending e-mails when cron.php is run.
Steps to reproduce:
1. Take a test course with database enrollments. Verify the user status as fully enrolled via external database.
2. Post to news forum with "mail now" checked.
3. Run admin/cron.php
4. Refresh user page for course to see unenrollment has taken place.
5. Run CLI script for enrol/database to restore prior enrollments.