PHP7 Soap Server Bug Ticket


I have opened a ticket for the problems caused by the PHP internal Soap Server handling responses with references in class member variables.

The Test Script (works with PHP 5.3, crashes in PHP7)

The Soap Server

// SOAP config array
$soap_config = array(
   'encoding' => 'UTF-8',
   'uri' => 'testNamespace'
);

// Don't cache WSDL files, mandatory for development
ini_set('soap.wsdl_cache_enabled', '0');

class MySoapServer
{

   public function getPosts()
   {
      $response = new Response();
      return $response;
   }
}

class Response{
   public $posts = array();

   public function __construct(){
      $this->posts = array(
         array('title' => 'Demo Post 1', 'body' => 'Demo content 1'),
         array('title' => 'Demo Post 2', 'body' => 'Demo content 2'),
         array('title' => 'Demo Post 3', 'body' => 'Demo content 3'),
         array('title' => 'Demo Post 4', 'body' => 'Demo content 4')
      );
      //this breaks the code
      sort($this->posts);
      //or
      //array_push($this->posts,array('title' => 'Demo Post 5', 'body' => 'Demo content 5'));
      //array_multisort($this->posts);
      //arsort($this->posts);
      //krsort($this->posts);
      //or
      //$this->posts = &$this->posts;
   }

}

// Run SOAP server
$soapserver = new SoapServer(null, $soap_config);
$soapserver->setClass('MySoapServer');
$soapserver->handle();

The Soap Client

// Create new SOAP client
$soap_config = array(
   'encoding' => 'UTF-8',
   'location' => 'localhost/server.php', //adjust this URL
   'uri' => 'testNamespace',
);
$soap_client = new SoapClient(null, $soap_config);
if (is_object($soap_client)) {
   $soap_result = $soap_client->getPosts();
   // Debug output
   echo "<pre>";
   print_r($soap_result);
   echo "</pre>";
} else {
   throw new Exception('SOAP Server not available');

Hinterlasse eine Antwort

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>