Permalink
Browse files

MDL-26660 libraries: Do not try to parse non-valid XML

Conflicts:

	lib/googleapi.php
  • Loading branch information...
1 parent 10c3c37 commit c4bc6e90221feb16b56e7a945c8f7b42fd86634c @FMCorz FMCorz committed Oct 30, 2012
Showing with 13 additions and 9 deletions.
  1. +13 −9 lib/googleapi.php
View
@@ -485,13 +485,16 @@ public function do_photo_search($query){
*
* @return mixes $files Array in the format get_listing uses for folders
*/
- public function get_albums(){
+ public function get_albums() {
+ $files = array();
$content = $this->google_curl->get(google_picasa::LIST_ALBUMS_URL);
- $xml = new SimpleXMLElement($content);
- $files = array();
+ if (empty($content)) {
+ return $files;
+ }
- foreach($xml->entry as $album){
+ $xml = new SimpleXMLElement($content);
+ foreach ($xml->entry as $album) {
$gphoto = $album->children('http://schemas.google.com/photos/2007');
$mediainfo = $album->children('http://search.yahoo.com/mrss/');
@@ -507,7 +510,6 @@ public function get_albums(){
'thumbnail_height' => 160,
'children' => array(),
);
-
}
return $files;
@@ -520,14 +522,16 @@ public function get_albums(){
* @param string $rawxml XML from picasa api
* @return mixed $files A list of files for the file picker
*/
- public function get_photo_details($rawxml){
+ public function get_photo_details($rawxml) {
+ $files = array();
+ if (empty($rawxml)) {
+ return $files;
+ }
$xml = new SimpleXMLElement($rawxml);
$this->lastalbumname = (string)$xml->title;
- $files = array();
-
- foreach($xml->entry as $photo){
+ foreach ($xml->entry as $photo) {
$gphoto = $photo->children('http://schemas.google.com/photos/2007');
$mediainfo = $photo->children('http://search.yahoo.com/mrss/');

0 comments on commit c4bc6e9

Please sign in to comment.