| Michael de Vries
                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Thursday 19 February 2009 1:21:30 am 
                                                                
                                                                 Hi all! 
I'm trying to write a soap plugin for Exponential, so I can publish content to eZ from another content system. Except for not finding a lot of documentation about how to do this it is coming along fine.
 
So, what I have done until now:I wrote a plugin which uses soap, this is working fine, I can talk to eZ, fetch objects and even put some stuff in.
 But now I am at the point where I want to add an article to the system. If I try this with the code below, my httpd process crashes, no errors are written to the system or Exponential log.
 The code I use is the following: initialize.php 
<?php
// in extensions/my_soap_extension/soap/initialize.php
$server->registerFunction("createObject", array("title" => "string", "short_title" => "string", "intro" => "string", "body" => "string", "enable_comments" => "boolean", "username" => "string", "password" => "string"));
function createObject($title, $short_title, $intro, $body, $enable_comments, $username, $password){
	$user = checkUser($username, $password);
	if(!$user){
		return new eZSOAPFault("1", "Access denied, check username and password");
	}
	// Fetch parent node
	$parentNodeId = 2; //Main Exponential Node
	$parentNode =& eZContentObjectTreeNode::fetch($parentNodeId); //make a copy of the parent node
	
	if(!is_object($parentNode)){
		//if we come here, then parent node is a fake!
		return new eZSOAPFault("1", "Parent node doesn't exist!");
	}
	//fetch some useful variables
	$parentContentObject =& $parentNode->attribute("object");
	$sectionId = $parentContentObject->attribute("section_id");
	$userId =& $user->attribute("contentobject_id");
	
	//fetch class (article)
	$contentClass =& eZContentClass::fetchByIdentifier("Article");
	if(!is_object($contentClass)){
		//the contentclass doesn't exist, abort mission
		return new eZSOAPFault("1", "Article ContentClass doesn't exist!");
	}
	
	//create new ContentObject of this ContentClass
	$contentObject =& $contentClass->instantiate($userId, $sectionId);
}
?>
So, when I run this code, the httpd process crashes and after some investigation it seems to come from the following statement: 
$contentClass->instantiate($userId, $sectionId);
 This functions calls the following function: 
$object->setName( ezi18n( "kernel/contentclass", "New %1", null, array( $this->name( $languageCode ) ) ), false, $languageCode );
 And in this setName function there is the following line: 
$backtrace = debug_backtrace();
 When I remove that line, everything goes fine, no error or crashes occur. Zend Studio says the line is useless, because the $backtrace variable is never used, so why is this line there and why does it crash on that line? |