Skip to content

Moodle 4.5: scheduled task "\block_exacomp\task\clear_exacomp_weekly_schedule" fails #32

@abkoch

Description

@abkoch

Dear developer,

in Moodle Moodle 4.5+ (Build: 20241025) with PHP 8.1 scheduled task "\block_exacomp\task\clear_exacomp_weekly_schedule" fails with the following error.

Best regards
Andreas

Execute scheduled task: Alle unbearbeiteten Aufgaben im Wochenplan der letzten Woche entfernen und wieder in den Planungsspeicher schieben. Alle Einträge im Planungsspeicher löschen, welche keinem Kurs zugeordnet sind (z.B. Kurs wurde gelöscht). (block_exacomp\task\clear_exacomp_weekly_schedule)
... started 12:30:02. Current memory use 23.7 MB.
Debugging increased temporarily due to faildelay of 86400
Exabis Competence Grid: clear_exacomp_weekly_schedule "Sonntagsscript" task is running:
... used 3 dbqueries
... used 0.041341066360474 seconds
Scheduled task failed: Alle unbearbeiteten Aufgaben im Wochenplan der letzten Woche entfernen und wieder in den Planungsspeicher schieben. Alle Einträge im Planungsspeicher löschen, welche keinem Kurs zugeordnet sind (z.B. Kurs wurde gelöscht). (block_exacomp\task\clear_exacomp_weekly_schedule),Fehler beim Schreiben der Datenbank (You can't specify target table 'mdl_block_exacompschedule' for update in FROM clause
UPDATE mdl_block_exacompschedule
    SET start = null, endtime = null, is_overdue = 1
    WHERE id IN (
        SELECT schedule.id
        FROM mdl_block_exacompschedule schedule
        JOIN mdl_block_exacompexamples ex ON ex.id = schedule.exampleid
        WHERE schedule.start > ?
        AND schedule.start < ?
        AND ex.blocking_event = 0
        AND schedule.id NOT IN (
            SELECT sched.id
            -- select table inside a subquery, because else we get a
            -- 'You can't specify target table 'schedule' for update in FROM clause'
            -- error
            FROM (SELECT id, exampleid, start FROM mdl_block_exacompschedule) AS sched
            JOIN mdl_block_exacompitem_mm item_mm ON sched.exampleid = item_mm.exacomp_record_id
            JOIN mdl_block_exaportitem item ON item_mm.itemid = item.id
            WHERE sched.start > ?
            AND sched.start < ?
        )
    )
[array (
  0 => 1731065402,
  1 => 1731670202,
  2 => 1731065402,
  3 => 1731670202,
)])
Debug info:
You can't specify target table 'mdl_block_exacompschedule' for update in FROM clause
UPDATE mdl_block_exacompschedule
    SET start = null, endtime = null, is_overdue = 1
    WHERE id IN (
        SELECT schedule.id
        FROM mdl_block_exacompschedule schedule
        JOIN mdl_block_exacompexamples ex ON ex.id = schedule.exampleid
        WHERE schedule.start > ?
        AND schedule.start < ?
        AND ex.blocking_event = 0
        AND schedule.id NOT IN (
            SELECT sched.id
            -- select table inside a subquery, because else we get a
            -- 'You can't specify target table 'schedule' for update in FROM clause'
            -- error
            FROM (SELECT id, exampleid, start FROM mdl_block_exacompschedule) AS sched
            JOIN mdl_block_exacompitem_mm item_mm ON sched.exampleid = item_mm.exacomp_record_id
            JOIN mdl_block_exaportitem item ON item_mm.itemid = item.id
            WHERE sched.start > ?
            AND sched.start < ?
        )
    )
[array (
  0 => 1731065402,
  1 => 1731670202,
  2 => 1731065402,
  3 => 1731670202,
)]
Backtrace:
* line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
* line 1258 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
* line 14785 of /blocks/exacomp/lib/lib.php: call to mysqli_native_moodle_database->execute()
* line 36 of /blocks/exacomp/classes/task/clear_exacomp_weekly_schedule.php: call to block_exacomp_clear_exacomp_weekly_schedule()
* line 410 of /lib/classes/cron.php: call to block_exacomp\task\clear_exacomp_weekly_schedule->execute()
* line 208 of /lib/classes/cron.php: call to core\cron::run_inner_scheduled_task()
* line 125 of /lib/classes/cron.php: call to core\cron::run_scheduled_tasks()
* line 186 of /admin/cli/cron.php: call to core\cron::run_main_process()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions