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

Google docs repository "Invalid JSON string" message for PDF document solution

XMLWordPrintable

    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • MOODLE_22_STABLE, MOODLE_23_STABLE
    • MDL-35034-master
    • Hide

      Test pre-requisites

      • A Google Docs/Drive account with some files
      • Upload a file to Google Docs, and set it to 'Prevent download' using a right click
      • The Google Docs repository enabled

      Test steps

      1. Navigate to your private files
      2. Click on 'Add' and explore your Google Docs
      3. Make sure the file listing is correct
      4. Make sure you can download any file
      5. Make sure you CANNOT download the file with restricted download
      Show
      Test pre-requisites A Google Docs/Drive account with some files Upload a file to Google Docs, and set it to 'Prevent download' using a right click The Google Docs repository enabled Test steps Navigate to your private files Click on 'Add' and explore your Google Docs Make sure the file listing is correct Make sure you can download any file Make sure you CANNOT download the file with restricted download

      I configured the Google Docs repository but with some accounts i get the message "Invalid JSON string".

      I think i found a problem in the file lib/googleapi.php (line 115), the code is...

      $source = (string)$gdoc->content[0]->attributes()->src;,

      ...but in the XML entry for PDF documents there is no "content" or "src" attributes.

      Debugging the xml file i found this

      [title] => Test file.pdf
      [link] => Array
          (
              [0] => SimpleXMLElement Object
                  (
                      [@attributes] => Array
                          (
                              [rel] => alternate
                              [type] => text/html
                              [href] => https://docs.google.com/file/test/test-test-test-test/edit
                          )
       
                  )
      ...

      So the correct path to parse this XML entry is different than what appears on lib/googleapi.php (line 115). I changed it to this...

      $source = (string)$gdoc->link[0]->attributes()->href;

      ...and now it works fine

      Sorry if this issue is duplicated, i tried to find something similar without success.

            fred Frédéric Massart
            dacapri David Cabrera Primo
            Rajesh Taneja Rajesh Taneja
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

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