Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Web Services - Add a new role - Simple XML error - possible bug? 
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

I am trying to start using the Web Services feature in Magento, but I get an error when I attempt to add a new role via SYSTEM->WEB SERVICES->ROLES->Add a new role. The error is posted below as an image. I am running debian with the latest php/mysql/simplexml packages in the debian repo’s. Any help or guidance with this would be greatly appreciated. I am very code oriented, but new (2 months) to Magento.

The problem is in /lib/Varien/Simplexml/Element.php on like 376, which reads:

$targetChild->addAttribute($key$this->xmlentities($value));

Apparently, $value is holding no value, because as the image below shows… name and value are required. Also, I have added a simple space character to $value and then I recieve no errors. Here is my modified code:

$targetChild->addAttribute($key$this->xmlentities($value " "));

Here is the code altogether in case any of you can’t access the file at this time:

foreach ($source->attributes() as $key=>$value{
       $targetChild
->addAttribute($key$this->xmlentities($value));
       
//$targetChild->addAttribute($key, $this->xmlentities($value . " "));
}
return $this;

I assume the $source->attributres() function is the problem because the error states “/Element.php(367): SimpleXMLElement->addAttribute(’descr’, ‘’)”...which would mean the $key = descr and the value was null. Perhaps the variable $source is the problem. Has anyone else had this issue? Would this be worthy of reporting as a bug? Hopefully someone from Magento will see this and give some feedback. I am not going to paste the error from the screen as text in here so that other members searching the forum for this problem, might find this post…

WarningSimpleXMLElement::addAttribute() [function.SimpleXMLElement-addAttribute]Attribute name and value are required  in /home/blakew/www/magento/lib/Varien/Simplexml/Element.php on line 367
Trace
:
#0 [internal function]: mageCoreErrorHandler(2, 'SimpleXMLElemen...', '/home/blakew/ww...', 367, Array)
#1 /home/blakew/www/magento/lib/Varien/Simplexml/Element.php(367): SimpleXMLElement->addAttribute('descr', '')
#2 /home/blakew/www/magento/lib/Varien/Simplexml/Element.php(388): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#3 /home/blakew/www/magento/lib/Varien/Simplexml/Element.php(388): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#4 /home/blakew/www/magento/lib/Varien/Simplexml/Element.php(388): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#5 /home/blakew/www/magento/lib/Varien/Simplexml/Element.php(388): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#6 /home/blakew/www/magento/lib/Varien/Simplexml/Element.php(326): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true)
#7 /home/blakew/www/magento/lib/Varien/Simplexml/Config.php(586): Varien_Simplexml_Element->extend(Object(Mage_Core_Model_Config_Element), true)
#8 /home/blakew/www/magento/app/code/core/Mage/Api/Model/Config.php(72): Varien_Simplexml_Config->extend(Object(Mage_Core_Model_Config_Base), true)
#9 /home/blakew/www/magento/app/code/core/Mage/Api/Model/Config.php(43): Mage_Api_Model_Config->_construct()
#10 /home/blakew/www/magento/app/code/core/Mage/Core/Model/Config.php(715): Mage_Api_Model_Config->__construct(Array)
#11 /home/blakew/www/magento/app/Mage.php(287): Mage_Core_Model_Config->getModelInstance('api/config', Array)
#12 /home/blakew/www/magento/app/Mage.php(301): Mage::getModel('api/config', Array)
#13 /home/blakew/www/magento/app/code/core/Mage/Api/Model/Roles.php(64): Mage::getSingleton('api/config')
#14 /home/blakew/www/magento/app/code/core/Mage/Api/Model/Roles.php(46): Mage_Api_Model_Roles->_buildResourcesArray()
#15 /home/blakew/www/magento/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php(78): Mage_Api_Model_Roles->getResourcesList()
#16 /home/blakew/www/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(343): Mage_Adminhtml_Api_RoleController->editRoleAction()
#17 /home/blakew/www/magento/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php(137): Mage_Core_Controller_Varien_Action->dispatch('editrole')
#18 /home/blakew/www/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(168): Mage_Core_Controller_Varien_Router_Admin->match(Object(Mage_Core_Controller_Request_Http))
#19 /home/blakew/www/magento/app/Mage.php(420): Mage_Core_Controller_Varien_Front->dispatch()
#20 /home/blakew/www/magento/index.php(46): Mage::run()
#21 {main}
Image Attachments
simplexml_error.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
Camulos
Jr. Member
 
Total Posts:  10
Joined:  2008-07-15
 

Your PHP version by chance 5.2.1 (or lower)?
Because there is a bug in the SimpleXML function of PHP where empty attributes generates an error.

check: http://bugs.php.net/bug.php?id=41175

An upgrade (to 5.2.2 or higher) should do the trick! good luck

 
Magento Community Magento Community
Magento Community
Magento Community
 
blakew
Sr. Member
 
Total Posts:  107
Joined:  2008-06-20
 

thank you Camulos, I thought I had the latest version after running apt-get and apt-upgrade, but I didn’t. I added a dotdeb repo and it upgraded to 5.2.6… works great as far as I can tell now. Thanks for posting, it saved me a headache and a bunch of time. Have a great day.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top