https://bugzilla.wikimedia.org/show_bug.cgi?id=25580

--- Comment #3 from Dmitriy <c...@uniyar.ac.ru> 2010-10-20 05:36:23 UTC ---
I am not calling any hook remotely. I use that 1.17 wiki remotely via API
action=import&xml&token:

    static function importXML( $dstImportToken, $xmldata ) {
        if ( self::$directionToLocal ) {
            $json_result = new WikiSyncJSONresult( false );
// TODO: unfinished..
            return $json_result->getResult();
        } else {
            $APIparams = array(
                'action' => 'import',
                'format' => 'json',
                'token' => $dstImportToken,
            );
            list( $fname, $fp ) = self::tempnam_sfx( '', '.xml' );
            fwrite( $fp, $xmldata, strlen( $xmldata ) );
            fclose( $fp );
            $APIfiles = array(
                'xml'=>$fname
            );
            $jr = self::remoteAPIget( self::$remoteContextJSON, $APIparams,
$APIfiles, false, true );
            return $jr;
        }
    }

    static function remoteAPIget() {
        # get params
        $args = func_get_args();
        // by default will encode JSON result to string
        $encodeResult = count( $args ) < 4 || $args[3] !== false;
        // by default will NOT use 'multipart/form-data' encoding
        $useMultipart = count( $args ) > 4 && $args[4] === true;
        $json_result = new WikiSyncJSONresult( $encodeResult );
        if ( !WikiSyncSetup::initUser() ) {
            # not enough priviledges to run this method
            return $json_result->getResult( 'noaccess' );
        }
        # snoopy api_params are associative array
        $api_params = is_array( $args[1] ) ? $args[1] : json_decode( $args[1],
true );
        $api_files = count( $args ) > 2 ? $args[2] : '';
        $snoopy = new WikiSnoopy();
        $snoopy->setContext( $args[0] );
        if ( $useMultipart ) {
            $snoopy->set_submit_multipart();
            $snoopy->httpmethod = "POST";
        } else {
            $snoopy->set_submit_normal();
            $snoopy->httpmethod = "GET";
        }
        $snoopy->submitToApi( $api_params, $api_files );
        # transport level error ?
        if ( $snoopy->error != '' ) {
            return $json_result->getResult( 'http', $snoopy->error );
        }
        $response = json_decode( $snoopy->results, true );
        # proxy returned html instead of json ?
        if ( $response === null ) {
            return $json_result->getResult( 'http' );
        }
        $json_result->append( $response ); // no HTTP error & valid AJAX
        if ( isset( $response['error'] ) ) {
            return $json_result->getResult( $response['error']['code'],
$response['error']['info'] ); // API reported error
        }
        $json_result->setStatus( '1' ); // API success
        return $json_result->getResult();
    }

XML seems to be remotely imported fine, but with warnings in error_log file.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to