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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3, 2.3.1, 2.4
    • Fix Version/s: 2.2.5, 2.3.2
    • Component/s: Repositories
    • Labels:
    • Testing Instructions:
      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
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-35034-master

      Description

      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.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Sep/12