Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-81645

blog_cron_task breaks on invalid RSS feed URL

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 4.2 regressions
    • Blog
    • None

      To fetch the RSS feeds the library simplepie is utilised. This has been updated to 1.8.0 in the Moodle 4.2 release (see https://tracker.moodle.org/browse/MDL-76909). Unfortunately this is causing some issues. Once a URL that no longer exists, or returns no body, is passed to the library, it raises an error.

      The library is in the process of releasing version 1.9.0, see https://github.com/simplepie/simplepie/pull/850. When the simplepie library was updated to the latest changes on the `master` branch, a new error occurred.

      This issue is causing working urls to not synchronise too. To identify the failing external blogs there is a flag in the database schema in the table `mdl_blog_external`. The column `failedlastsync` is the flag that identifies is the last synchronisation has failed. The following query is used to identify these records.

        SELECT *,  to_timestamp(timefetched)::date as timefetcheddate 
          FROM mdl_blog_external 
         WHERE failedlastsync = 1 
      ORDER BY timefetched DESC;


      Steps to reproduce

      1. As a user, log in and open /blog/external_blogs.php
      2. Register an external blog with:
        1. A valid feed: https://developer.chrome.com/static/blog/feed.xml
        2. Name: invalid_feed_test
        3. Save changes.
      3. Update the database record by running the following SQL:

        UPDATE mdl_blog_external SET url = 'https://fake-domain-1.com/feed.xml', timefetched = 0 WHERE name = 'invalid_feed_test';

      4. Open /admin/tool/task/schedule_task.php?task=core%5Ctask%5Cblog_cron_task
      5. Click 'Run now'

      Expected (output on Moodle 4.1):

      Execute scheduled task: Sync external blogs (core\task\blog_cron_task)
      ... started 13:43:11. Current memory use 18.1 MB.
      ... used 3 dbqueries
      ... used 0.43810200691223 seconds
      Scheduled task complete: Sync external blogs (core\task\blog_cron_task)
      

      Actual (output on Moodle >= 4.2):

        
      Execute scheduled task: Sync external blogs (core\task\blog_cron_task)
      ... started 13:45:47. Current memory use 18.5 MB.
      ... used 1 dbqueries
      ... used 0.27439188957214 seconds
      Scheduled task failed: Sync external blogs (core\task\blog_cron_task),strspn(): Argument #1 ($string) must be of type string, null given
      Backtrace:
      * line 153 of /lib/simplepie/src/Content/Type/Sniffer.php: call to strspn()
      * line 124 of /lib/simplepie/src/Content/Type/Sniffer.php: call to SimplePie\Content\Type\Sniffer->unknown()
      * line 148 of /lib/simplepie/src/Locator.php: call to SimplePie\Content\Type\Sniffer->get_type()
      * line 173 of /blog/lib.php: call to SimplePie\Locator->is_feed()
      * line 55 of /lib/classes/task/blog_cron_task.php: call to blog_sync_external_entries()
      * line 405 of /lib/classes/cron.php: call to core\task\blog_cron_task->execute()
      * line 166 of /admin/cli/scheduled_task.php: call to core\cron::run_inner_scheduled_task()
      

            Unassigned Unassigned
            scottverbeek Scott Verbeek
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.