Moodle
  1. Moodle
  2. MDL-26660

Invalid JSON String when use picasa repository plugin and no photos/folders i account

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.2, 2.2.6, 2.3.3
    • Fix Version/s: 2.2.7, 2.3.4
    • Component/s: Repositories
    • Labels:
    • Environment:
      Win 7, Linux, Firefox, IE, Safari,
    • Database:
      MySQL
    • Testing Instructions:
      Hide

      Test pre-requisites

      • Picasa repository enabled
      • A brand new google account without any albums or photos in picasa (don't even login to picasa)

      Test steps

      1. Go to your private files and open Picasa
      2. Make sure there is no error while browsing the content (which should be empty as you are using an empty account)
      3. Add some files to Picasa
      4. Make sure there is no error, and the files are displayed
      5. Make sure that you can download the files and view them in Moodle.
      Show
      Test pre-requisites Picasa repository enabled A brand new google account without any albums or photos in picasa (don't even login to picasa) Test steps Go to your private files and open Picasa Make sure there is no error while browsing the content (which should be empty as you are using an empty account) Add some files to Picasa Make sure there is no error, and the files are displayed Make sure that you can download the files and view them in Moodle.
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-26660-master
    • Rank:
      16246

      Description

      Dear:
      Picasa Web Album repository, gave me the following error:
      "Invalid JSON String"

      When upgraded with the latest installation of moodle, now I get the following error:
      "Exception - String not could be parsed as XML"

      The problem only occurs with this repository. The rest of the repositories work well.

      Chek as everything is OK, but the problem persists. I tested with a new facility on the same server with the same pc and a different subdomain and there it works correctly.

      ERROR: Invalid JSON String

      Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : Start tag expected, '<' not found in /0campusCapacVirtual/lib/googleapi.php on line 479

      Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Unknown user. in /0campusCapacVirtual/lib/googleapi.php on line 479

      Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /0campusCapacVirtual/lib/googleapi.php on line 479

      {"error":"Excepci\u00f3n - String could not be parsed as XML","stacktrace":"* line 479 of \/lib\/googleapi.php: Exception thrown\n* line 479 of \/lib\/googleapi.php: call to SimpleXMLElement->__construct()\n* line 440 of \/lib\/googleapi.php: call to google_picasa->get_albums()\n* line 87 of \/repository\/picasa\/lib.php: call to google_picasa->get_file_list()\n* line 140 of \/repository\/repository_ajax.php: call to repository_picasa->get_listing()\n","debuginfo":null,"reproductionlink":"http:\/\/www.myweb.com\/"}

        Activity

        Hide
        Thom Rawson added a comment -

        Seeing the same kind of error here in Nagasaki. Activated Picasa's repository, then clicked it in the file picker. This message popped up.

        ERROR: Invalid JSON string

        Warning: SimpleXMLElement::__construct(): Entity:

        line 1: parser error : Start tag expected, '__construct()\n*
        line 438 of \/lib\/googleapi.php: call to google_picasa->get_albums()\n*
        line 87 of \/repository\/picasa\/lib.php: call to google_picasa->get_file_list()\n*
        line 140 of \/repository\/repository_ajax.php: call to repository_picasa->get_listing()\n",
        "debuginfo":null,"reproductionlink":"https:\/\/orc.sun.ac.jp\/"}

        Show
        Thom Rawson added a comment - Seeing the same kind of error here in Nagasaki. Activated Picasa's repository, then clicked it in the file picker. This message popped up. ERROR: Invalid JSON string Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '__construct()\n* line 438 of \/lib\/googleapi.php: call to google_picasa->get_albums()\n* line 87 of \/repository\/picasa\/lib.php: call to google_picasa->get_file_list()\n* line 140 of \/repository\/repository_ajax.php: call to repository_picasa->get_listing()\n", "debuginfo":null,"reproductionlink":"https:\/\/orc.sun.ac.jp\/"}
        Hide
        Thom Rawson added a comment -

        Ok, just ran this through a bit more. Looks like the person didn't have any photos in their Google Picasa account. Once they added photos, the error went away.

        Perhaps when this type of error throws because of some some code mentioning no "Picasa account found" or "No Photos" is needed. Just FYI.

        Show
        Thom Rawson added a comment - Ok, just ran this through a bit more. Looks like the person didn't have any photos in their Google Picasa account. Once they added photos, the error went away. Perhaps when this type of error throws because of some some code mentioning no "Picasa account found" or "No Photos" is needed. Just FYI.
        Hide
        Dan Poltawski added a comment -

        Hi Thom,

        thanks that really useful info for testing.

        Show
        Dan Poltawski added a comment - Hi Thom, thanks that really useful info for testing.
        Hide
        Frédéric Massart added a comment -

        Here is a patch that adds a small validation to check whether the content was empty or not. I am not entirely convinced by this solution, I guess we could handle the exception properly instead of using empty(). But I quite dislike passively handling the exception and returning an empty array() because it would block the debugging.

        Also, I could not reproduce this error on master nor the latest 2.2, I used an account without albums or photos.

        Dear reviewers, please express your thoughts!

        Show
        Frédéric Massart added a comment - Here is a patch that adds a small validation to check whether the content was empty or not. I am not entirely convinced by this solution, I guess we could handle the exception properly instead of using empty(). But I quite dislike passively handling the exception and returning an empty array() because it would block the debugging. Also, I could not reproduce this error on master nor the latest 2.2, I used an account without albums or photos. Dear reviewers, please express your thoughts!
        Hide
        Frédéric Massart added a comment -

        By the way, Thom and Edgar, could you please tell us if you are still experiencing this issue, and if yes did you find steps to reproduce it? Thanks!

        Show
        Frédéric Massart added a comment - By the way, Thom and Edgar, could you please tell us if you are still experiencing this issue, and if yes did you find steps to reproduce it? Thanks!
        Hide
        Rajesh Taneja added a comment -

        Patch looks spot-on Fred, pushing for integration.

        [y] Syntax
        [-] Output
        [y] Whitespace
        [-] Language
        [-] Databases
        [-] Testing
        [-] Security
        [-] Documentation
        [y] Git
        [y] Sanity check

        Show
        Rajesh Taneja added a comment - Patch looks spot-on Fred, pushing for integration. [y] Syntax [-] Output [y] Whitespace [-] Language [-] Databases [-] Testing [-] Security [-] Documentation [y] Git [y] Sanity check
        Hide
        Dan Poltawski added a comment -

        The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

        TIA and ciao

        Show
        Dan Poltawski added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
        Hide
        Dan Poltawski added a comment -

        Thanks Fred, i've integrated this now (22, 23 and master).

        Show
        Dan Poltawski added a comment - Thanks Fred, i've integrated this now (22, 23 and master).
        Hide
        David Monllaó added a comment -

        It fails. Tested in master with a fresh new user

        Invalid JSON string
        
        
        ( ! ) Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '&lt;' not found in /home/davidm/Desktop/moodlecode/INTEGRATION/master/lib/googleapi.php on line 327
        Call Stack
        #TimeMemoryFunctionLocation
        10.0006334912{main}(  )../repository_ajax.php:0
        20.115419008616repository_picasa->get_listing(  )../repository_ajax.php:129
        30.115419009904google_picasa->get_file_list(  )../lib.php:79
        40.115419009952google_picasa->get_albums(  )../googleapi.php:273
        51.327719023320SimpleXMLElement->__construct(  )../googleapi.php:327
        
        
        
        ( ! ) Warning: SimpleXMLElement::__construct(): Unknown user. in /home/davidm/Desktop/moodlecode/INTEGRATION/master/lib/googleapi.php on line 327
        Call Stack
        #TimeMemoryFunctionLocation
        10.0006334912{main}(  )../repository_ajax.php:0
        20.115419008616repository_picasa->get_listing(  )../repository_ajax.php:129
        30.115419009904google_picasa->get_file_list(  )../lib.php:79
        40.115419009952google_picasa->get_albums(  )../googleapi.php:273
        51.327719023320SimpleXMLElement->__construct(  )../googleapi.php:327
        
        
        
        ( ! ) Warning: SimpleXMLElement::__construct(): ^ in /home/davidm/Desktop/moodlecode/INTEGRATION/master/lib/googleapi.php on line 327
        Call Stack
        #TimeMemoryFunctionLocation
        10.0006334912{main}(  )../repository_ajax.php:0
        20.115419008616repository_picasa->get_listing(  )../repository_ajax.php:129
        30.115419009904google_picasa->get_file_list(  )../lib.php:79
        40.115419009952google_picasa->get_albums(  )../googleapi.php:273
        51.327719023320SimpleXMLElement->__construct(  )../googleapi.php:327
        
        {"error":"Exception - String could not be parsed as XML","stacktrace":"* line 327 of \/lib\/googleapi.php: Exception thrown\n* line 327 of \/lib\/googleapi.php: call to SimpleXMLElement->__construct()\n* line 273 of \/lib\/googleapi.php: call to google_picasa->get_albums()\n* line 79 of \/repository\/picasa\/lib.php: call to google_picasa->get_file_list()\n* line 129 of \/repository\/repository_ajax.php: call to repository_picasa->get_listing()\n","debuginfo":"\nError code: generalexceptionmessage","reproductionlink":"http:\/\/localhost\/INTEGRATION\/master\/"}
        
        Show
        David Monllaó added a comment - It fails. Tested in master with a fresh new user Invalid JSON string ( ! ) Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '&lt;' not found in /home/davidm/Desktop/moodlecode/INTEGRATION/master/lib/googleapi.php on line 327 Call Stack #TimeMemoryFunctionLocation 10.0006334912{main}( )../repository_ajax.php:0 20.115419008616repository_picasa->get_listing( )../repository_ajax.php:129 30.115419009904google_picasa->get_file_list( )../lib.php:79 40.115419009952google_picasa->get_albums( )../googleapi.php:273 51.327719023320SimpleXMLElement->__construct( )../googleapi.php:327 ( ! ) Warning: SimpleXMLElement::__construct(): Unknown user. in /home/davidm/Desktop/moodlecode/INTEGRATION/master/lib/googleapi.php on line 327 Call Stack #TimeMemoryFunctionLocation 10.0006334912{main}( )../repository_ajax.php:0 20.115419008616repository_picasa->get_listing( )../repository_ajax.php:129 30.115419009904google_picasa->get_file_list( )../lib.php:79 40.115419009952google_picasa->get_albums( )../googleapi.php:273 51.327719023320SimpleXMLElement->__construct( )../googleapi.php:327 ( ! ) Warning: SimpleXMLElement::__construct(): ^ in /home/davidm/Desktop/moodlecode/INTEGRATION/master/lib/googleapi.php on line 327 Call Stack #TimeMemoryFunctionLocation 10.0006334912{main}( )../repository_ajax.php:0 20.115419008616repository_picasa->get_listing( )../repository_ajax.php:129 30.115419009904google_picasa->get_file_list( )../lib.php:79 40.115419009952google_picasa->get_albums( )../googleapi.php:273 51.327719023320SimpleXMLElement->__construct( )../googleapi.php:327 { "error" : "Exception - String could not be parsed as XML" , "stacktrace" : "* line 327 of \/lib\/googleapi.php: Exception thrown\n* line 327 of \/lib\/googleapi.php: call to SimpleXMLElement->__construct()\n* line 273 of \/lib\/googleapi.php: call to google_picasa->get_albums()\n* line 79 of \/repository\/picasa\/lib.php: call to google_picasa->get_file_list()\n* line 129 of \/repository\/repository_ajax.php: call to repository_picasa->get_listing()\n" , "debuginfo" : "\nError code: generalexceptionmessage" , "reproductionlink" : "http:\/\/localhost\/INTEGRATION\/master\/" }
        Hide
        Frédéric Massart added a comment -

        Thanks for testing this David.
        I have added a commmit on top of my branches to handle the errors. I decide to handle the exception thrown by SimpleXML, but also to add a simple test to check that we receive a valid XML string. Without that check, the JSON error would happen with DEBUG_NORMAL and more.
        Cheers,
        Fred

        Show
        Frédéric Massart added a comment - Thanks for testing this David. I have added a commmit on top of my branches to handle the errors. I decide to handle the exception thrown by SimpleXML, but also to add a simple test to check that we receive a valid XML string. Without that check, the JSON error would happen with DEBUG_NORMAL and more. Cheers, Fred
        Hide
        Dan Poltawski added a comment -

        I've pulled that, can you re-test David?

        Show
        Dan Poltawski added a comment - I've pulled that, can you re-test David?
        Hide
        David Monllaó added a comment -

        It passes. I've received no error when having no photos, also been able to select, download and delete files from Moodle after adding a file in picassa

        Show
        David Monllaó added a comment - It passes. I've received no error when having no photos, also been able to select, download and delete files from Moodle after adding a file in picassa
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Many, many thanks for your effort!

        Millions of people will enjoy the results of your work, yay!

        Closing as fixed. Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Many, many thanks for your effort! Millions of people will enjoy the results of your work, yay! Closing as fixed. Ciao

          People

          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: