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

Creating ad-hoc task with array for custom data fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 2.7.2
    • Component/s: General
    • Labels:

      Description

      The example for creating addhoc tasks in the 2.7 docs uses an array for custom data:

         $domination = new take_over_the_world();
         $domination->set_custom_data(array(
             'plansfortomorrownight' => 'The same thing we do every night, Pinky!'
         ));
         \core\task\manager::queue_adhoc_task($domination);
      

      Actually doing this fails, because the custom data column is an object and so cannot be inserted into the DB.

      See public static function record_from_adhoc_task($task):

      $record->customdata = $task->get_custom_data();
      

      And see adhoc_task::get_custom_data():

      return json_decode($this->customdata);
      

      json_decode will return an object, when what we want is the raw (encoded) string.

        Attachments

          Activity

            People

            Assignee:
            damyon Damyon Wiese
            Reporter:
            skylarkelty Skylar Kelty
            Peer reviewer:
            Andrew Nicols
            Integrator:
            Sam Hemelryk
            Tester:
            Adrian Greeve
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              8/Sep/14