Moodle
  1. Moodle
  2. MDL-27921

Youtube Repository Error "Invalid JSON String"

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0.3
    • Fix Version/s: None
    • Component/s: Repositories
    • Labels:
      None
    • Environment:
      Linux moodle20.localhost 2.6.32-71.el6.i686 #1 SMP Wed Sep 1 01:26:34 EDT 2010 i686 i686 i386 GNU/Linux
    • Database:
      MySQL
    • Workaround:
      Hide

      Embed the URL as an OBJECT in the HTML source code. This will force the site administrator to enable "Allow EMBED and OBJECT " option!!

      Show
      Embed the URL as an OBJECT in the HTML source code. This will force the site administrator to enable "Allow EMBED and OBJECT " option!!
    • Affected Branches:
      MOODLE_20_STABLE

      Description

      I have Moodle 2.0.3 (Build: 20110505) installed, whenever I try to search youtube for a video using the repository built in I get an error message saying "INVALID JSON STRING".

      Replication instructions:
      1. Enabled "Youtube videos" repository in Moodle 2.0.3 (Site administration -> Plugins -> Repositories -> Manage repositories)
      2. Access any course and add a "Page" resource.
      3. Click on "Moodle Media" in the text box toolbar.
      4. Click on "Find or upload a sound, video or applet..."
      5. From the "File Picker" select the "YouTube" repository and search for a video.

      This result the error to appear to me.

        Gliffy Diagrams

          Activity

          Hide
          Michael de Raadt added a comment -

          Hi, Amjad.

          I wasn't able to replicate this. Searching for YouTube videos seems to be working file.

          I wonder if this could be a problem with your networking or proxy settings. Could you try some changes there and see what happens?

          Michael;

          Show
          Michael de Raadt added a comment - Hi, Amjad. I wasn't able to replicate this. Searching for YouTube videos seems to be working file. I wonder if this could be a problem with your networking or proxy settings. Could you try some changes there and see what happens? Michael;
          Hide
          Michael de Raadt added a comment -

          From Dongsheng:

          "I cannot reproduce it, not sure it's php settings or networking, some people got this error when magic_quotes_gpc = on"

          Show
          Michael de Raadt added a comment - From Dongsheng: "I cannot reproduce it, not sure it's php settings or networking, some people got this error when magic_quotes_gpc = on"
          Hide
          Amjad Mohammed added a comment -

          Thanks Michael for your great comments. It is true that my Moodle server sits behind a proxy server. As a result I went to (Site administration -> Server -> HTTP) and filled all the required “Web proxy” details, but with no luck.

          Also I have checked the “magic_quotes_gpc” value in php.ini and I found it has been set to “off”. But with all these changes and checking, I still get the “INVALID JSON STRING” error. I even stopped the firewall on my Moodle server, but did not get anywhere!!

          Any other advice will be highly appreciated.

          Show
          Amjad Mohammed added a comment - Thanks Michael for your great comments. It is true that my Moodle server sits behind a proxy server. As a result I went to (Site administration -> Server -> HTTP) and filled all the required “Web proxy” details, but with no luck. Also I have checked the “magic_quotes_gpc” value in php.ini and I found it has been set to “off”. But with all these changes and checking, I still get the “INVALID JSON STRING” error. I even stopped the firewall on my Moodle server, but did not get anywhere!! Any other advice will be highly appreciated.
          Hide
          Richard Price added a comment -

          I am Also getting the same Error, on Youtube Repository in exactly same circumstance on a live server. WikiMedia works fine and Gives no such errors.
          My Environment:
          Moodle 2.2.4 20120706
          PHP: 5.3.2.1.4.17
          MySQL: InnoDB, (5.1.63.0.0.10.04.1)
          Server: Ubuntu 10.04 Sits on a network, and accesses Internet through a Proxy, which is entered within the Site Admin/Server/HTTP section.

          Replicates this step and Error Every time.
          Stack gives a pile of errors similar to but each cluster different.

          ( ! ) Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 41: parser error : Opening and ending tag mismatch: link line 5 and head in /var/www/moodle/repository/youtube/lib.php on line 102
          Call Stack
          #TimeMemoryFunctionLocation
          10.0014823464

          {main}( )../repository_ajax.php:0
          20.212341645840repository_youtube->search( )../repository_ajax.php:162
          30.212441647048repository_youtube->_get_collection( )../lib.php:82
          40.245341669152simplexml_load_string
          ( )../lib.php:102


          Multiple entries warning about similar for Line 102.
          ( ! ) Warning: simplexml_load_string() [function.simplexml-load-string]: </head> in /var/www/moodle/repository/youtube/lib.php on line 102
          Call Stack
          #TimeMemoryFunctionLocation
          10.0014823464{main}

          ( )../repository_ajax.php:0
          20.212341645840repository_youtube->search( )../repository_ajax.php:162
          30.212441647048repository_youtube->_get_collection( )../lib.php:82
          40.245341669152simplexml_load_string
          ( )../lib.php:102

          If useful i will post the rest of this stack trace.

          Show
          Richard Price added a comment - I am Also getting the same Error, on Youtube Repository in exactly same circumstance on a live server. WikiMedia works fine and Gives no such errors. My Environment: Moodle 2.2.4 20120706 PHP: 5.3.2.1.4.17 MySQL: InnoDB, (5.1.63.0.0.10.04.1) Server: Ubuntu 10.04 Sits on a network, and accesses Internet through a Proxy, which is entered within the Site Admin/Server/HTTP section. Replicates this step and Error Every time. Stack gives a pile of errors similar to but each cluster different. ( ! ) Warning: simplexml_load_string() [function.simplexml-load-string] : Entity: line 41: parser error : Opening and ending tag mismatch: link line 5 and head in /var/www/moodle/repository/youtube/lib.php on line 102 Call Stack #TimeMemoryFunctionLocation 10.0014823464 {main}( )../repository_ajax.php:0 20.212341645840repository_youtube->search( )../repository_ajax.php:162 30.212441647048repository_youtube->_get_collection( )../lib.php:82 40.245341669152simplexml_load_string ( )../lib.php:102 Multiple entries warning about similar for Line 102. ( ! ) Warning: simplexml_load_string() [function.simplexml-load-string] : </head> in /var/www/moodle/repository/youtube/lib.php on line 102 Call Stack #TimeMemoryFunctionLocation 10.0014823464{main} ( )../repository_ajax.php:0 20.212341645840repository_youtube->search( )../repository_ajax.php:162 30.212441647048repository_youtube->_get_collection( )../lib.php:82 40.245341669152simplexml_load_string ( )../lib.php:102 If useful i will post the rest of this stack trace.
          Hide
          Richard Price added a comment -

          Had a further look into this and can get it to work but only by sending the traffic (Site Settings, Server, HTTP) out a different way (only possible to do as a test). The Plugin uses the setting here and not the user's internet access settings. On playback, the video is fetched as usual and played using the user's internet settings.

          Our Moodle is open to get what it wants, but perhaps there is an issue with the route taken in that something is breaking in repository. Response times?, timeouts? Likely to affect large numbers of UK schools as usually all traffic is routed and filtered to some extent.

          On the server, within /repository/youtube/lib.php
          private function _get_collection obtains a feed from gdata.youtube.com,
          e.g. feed://gdata.youtube.com/feeds/api/videos?q=test&format=5&start-index=1&max-results=50&orderby=relevance

          Which is an XML feed. tried this in a browser (safari) and loads ok using the proxy that moodle is/was on, doesnt seem to have errors, but cannot work out why it is breaking in The Repository, perhaps it is too busy in the raw xml and takes too long to parse.

          Show
          Richard Price added a comment - Had a further look into this and can get it to work but only by sending the traffic (Site Settings, Server, HTTP) out a different way (only possible to do as a test). The Plugin uses the setting here and not the user's internet access settings. On playback, the video is fetched as usual and played using the user's internet settings. Our Moodle is open to get what it wants, but perhaps there is an issue with the route taken in that something is breaking in repository. Response times?, timeouts? Likely to affect large numbers of UK schools as usually all traffic is routed and filtered to some extent. On the server, within /repository/youtube/lib.php private function _get_collection obtains a feed from gdata.youtube.com, e.g. feed://gdata.youtube.com/feeds/api/videos?q=test&format=5&start-index=1&max-results=50&orderby=relevance Which is an XML feed. tried this in a browser (safari) and loads ok using the proxy that moodle is/was on, doesnt seem to have errors, but cannot work out why it is breaking in The Repository, perhaps it is too busy in the raw xml and takes too long to parse.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: