Plugin Directory

Changeset 549327


Ignore:
Timestamp:
05/26/2012 06:42:03 PM (13 years ago)
Author:
hel.io
Message:

Added ignore_errors option for context for older PHP versions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • backup/trunk/backup.php

    r549264 r549327  
    22/*
    33Plugin Name: Backup
    4 Version: 1.1.5
     4Version: 1.1.6
    55Plugin URI: http://hel.io/wordpress/backup/
    66Description: Backup your WordPress website to Google Drive.
     
    384384    $context = array(
    385385        'http' => array(
     386            'ignore_errors' => true,
    386387            'follow_location' => false,
    387388            'method'  => 'POST',
     
    458459    $context = array(
    459460        'http' => array(
     461            'ignore_errors' => true,
    460462            'follow_location' => false,
    461463            'method' => 'PUT',
     
    483485        }
    484486        elseif ( strpos( $response, '201' ) ) {
    485             return new SimpleXMLElement( $result );
     487            $xml = simplexml_load_string( $result );
     488            if ( $xml === false ) {
     489                backup_log( 'ERROR', 'Could not create SimpleXMLElement from ' . $result, __FILE__, __LINE__ );
     490                return false;
     491            }
     492            else
     493                return $xml;
    486494        }
    487495        else {
     
    536544    $context = array(
    537545        'http' => array(
     546            'ignore_errors' => true,
    538547            'method' => 'GET',
    539548            'header' => join( "\r\n", $header )
     
    548557
    549558    if ( $result !== false ) {
    550         $xml = new SimpleXMLElement( $result );
    551         error_log( $result );
    552         foreach ( $xml->link as $link )
    553             if ( $link['rel'] == 'http://schemas.google.com/g/2005#resumable-create-media' )
    554                 return $link['href'];
     559        $xml = simplexml_load_string( $result );
     560        if ( $xml === false ) {
     561            backup_log( 'ERROR', 'Could not create SimpleXMLElement from ' . $result, __FILE__, __LINE__ );
     562                return false;
     563        }
     564        else
     565            foreach ( $xml->link as $link )
     566                if ( $link['rel'] == 'http://schemas.google.com/g/2005#resumable-create-media' )
     567                    return $link['href'];
    555568    }
    556569    return false;
Note: See TracChangeset for help on using the changeset viewer.