-
- cclohman

-
Total Posts: 41
Joined: 2008-06-16
www.Tridian.com
|
Anyone out there on 1.1.6, can you add roles for a web services user?
Go to the Admin, the System -> Web Services -> Roles -> Add new role.
I’ve created a web api user called api_user, but when I try to create a “role” for that user, I get a major error:
Warning: SimpleXMLElement::addAttribute() [function.SimpleXMLElement-addAttribute]: Attribute name and value are required in /www/sites/dev5.tridian.com/files/html/magentostore/magento/lib/Varien/Simplexml/Element.php on line 387 Trace: #0 [internal function]: mageCoreErrorHandler(2, 'SimpleXMLElemen...', '/www/sites/dev5...', 387, Array) #1 /www/sites/dev5.tridian.com/files/html/magentostore/magento/lib/Varien/Simplexml/Element.php(387): SimpleXMLElement->addAttribute('descr', '') #2 /www/sites/dev5.tridian.com/files/html/magentostore/magento/lib/Varien/Simplexml/Element.php(410): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true) #3 /www/sites/dev5.tridian.com/files/html/magentostore/magento/lib/Varien/Simplexml/Element.php(410): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true) #4 /www/sites/dev5.tridian.com/files/html/magentostore/magento/lib/Varien/Simplexml/Element.php(410): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true) #5 /www/sites/dev5.tridian.com/files/html/magentostore/magento/lib/Varien/Simplexml/Element.php(410): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true) #6 /www/sites/dev5.tridian.com/files/html/magentostore/magento/lib/Varien/Simplexml/Element.php(342): Varien_Simplexml_Element->extendChild(Object(Mage_Core_Model_Config_Element), true) #7 /www/sites/dev5.tridian.com/files/html/magentostore/magento/lib/Varien/Simplexml/Config.php(592): Varien_Simplexml_Element->extend(Object(Mage_Core_Model_Config_Element), true) #8 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/code/core/Mage/Api/Model/Config.php(78): Varien_Simplexml_Config->extend(Object(Mage_Core_Model_Config_Base), true) #9 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/code/core/Mage/Api/Model/Config.php(49): Mage_Api_Model_Config->_construct() #10 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/code/core/Mage/Core/Model/Config.php(721): Mage_Api_Model_Config->__construct(Array) #11 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/Mage.php(314): Mage_Core_Model_Config->getModelInstance('api/config', Array) #12 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/Mage.php(328): Mage::getModel('api/config', Array) #13 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/code/core/Mage/Api/Model/Roles.php(70): Mage::getSingleton('api/config') #14 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/code/core/Mage/Api/Model/Roles.php(52): Mage_Api_Model_Roles->_buildResourcesArray() #15 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php(84): Mage_Api_Model_Roles->getResourcesList() #16 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(349): Mage_Adminhtml_Api_RoleController->editRoleAction() #17 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php(143): Mage_Core_Controller_Varien_Action->dispatch('editrole') #18 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(174): Mage_Core_Controller_Varien_Router_Admin->match(Object(Mage_Core_Controller_Request_Http)) #19 /www/sites/dev5.tridian.com/files/html/magentostore/magento/app/Mage.php(447): Mage_Core_Controller_Varien_Front->dispatch() #20 /www/sites/dev5.tridian.com/files/html/magentostore/magento/index.php(52): Mage::run() #21 {main}
|
| |
-
- Posted: September 22 2008
-
| top
-
|
 |
 |
 |
|
|
-
- cclohman

-
Total Posts: 41
Joined: 2008-06-16
www.Tridian.com
|
Okay, so here’s my solution. Turn off error reporting for the extendChild function. I’ve tested it and it works, but I have no idea if it causes any other problems yet. Maybe someone could comment on that for me?
As you can see above, the problem was a warning that was happening on line 385ish when adding the attribute to the $targetChild object. I’ve looked at the 4 api tables in the database and everything looks fine when turning off error reporting as far as creating users and roles.
In /lib/Varien/SimpleXML/Element.php starting on line 355
public function extendChild($source, $overwrite=false) { // this will be our new target node $targetChild = null; .....
I added the following line to turn off error reporting:
public function extendChild($source, $overwrite=false) { // turn off error reporting error_reporting(0); // this will be our new target node $targetChild = null; ......
This also cured my issue with getting a properly formatted and formed WSDL document when creating a new SoapClient to access the API.
|
| |
-
- Posted: September 22 2008
-
| top
| # 1
-
|
 |
 |
 |
|
|
-
- stefan_herxe

-
Total Posts: 44
Joined: 2008-08-20
|
Hello cclohman
i had the same problem ... till now! Thanks a lot for your investigation.
ciao, Stefan
|
| |
-
- Posted: September 25 2008
-
| top
| # 2
-
|
 |
 |
 |
|
|
-
- Georg Ringer

-
Total Posts: 61
Joined: 2008-07-04
Linz, Austria
|
this idea is not very good because it will hide *all* error warnings of your shop! if you ever miss a ; or did any php error, you will get a blank page not knowing what happened and trust me: you will never think about this change and you will loose hours!
georg
|
| |
-
- Posted: September 30 2008
-
| top
| # 3
-
|
 |
 |
 |
|
|
-
- stefan_herxe

-
Total Posts: 44
Joined: 2008-08-20
|
Hallo Georg!
of course, your right. Another solution is… and i guess thats really a better way.
“Attribute name and value are required “ - SimpleXMLElement->addAttribute(’descr’, ‘’) A value for “descr” is not given. OK, this description is or better is not noticed within the api config-file.
/app/code/core/Mage/Api/etc/api.xml
<privilegeSets>
<default>
<view descr="View entity"/>
<edit descr="Edit entity"/>
<delete descr=""/> <-- add something here
<create descr=""/> <-- add something here
</default>
</privilegeSets>
It works in my case, but iam not sure about it.
ciao, Stefan
PS: i try to copy the file to /app/code/local/Mage/Api/etc/api.xml to keep the original file updateable but my new file is ignored. Do the config-files not follow the same way like the php (include-)files?
|
| |
-
- Posted: September 30 2008
-
| top
| # 4
-
|
 |
 |
 |
|
|
-
- Georg Ringer

-
Total Posts: 61
Joined: 2008-07-04
Linz, Austria
|
yeah that works fine, thx! can you post this as bug in the buglist?
|
| |
-
- Posted: September 30 2008
-
| top
| # 5
-
|
 |
 |
 |
|
|
|
|
-
- cclohman

-
Total Posts: 41
Joined: 2008-06-16
www.Tridian.com
|
What you are saying regarding error_reporting is not quite accurate. According to the docs on php.net, the error_reporting function disables error reporting for the duration of the script only, not the entire application as you suggest. Also, by locating the call within the problem function, as opposed to at the top of the php file (as is commonly done), this further limits when error_reporting() is actually executed. As soon as the script finishes executing, the error reporting will return to the value set in php.ini. No other parts of Magento are affected by this.
Cheers,
Chris
|
| |
-
- Posted: October 1 2008
-
| top
| # 7
-
|
 |
 |
 |
|
|
-
- cclohman

-
Total Posts: 41
Joined: 2008-06-16
www.Tridian.com
|
Regardless of the specifics about error_reporting, I agree that Stefan’s suggestion to modify the api.xml file values is clearly the way to go. My initial suggestion fixed the problem, but his fixes the cause. Nice!
Note, apparently you cannot override xml files by duplicating the folder structure and file within the “local” code pool. Just an FYI, because I tried to do this, rather than editing the core version of api.xml.
original:
<privilegeSets> <default> <view descr="View entity"/> <edit descr="Edit entity"/> <delete descr=""/> // this value needs to be changed <create descr=""/> // this value needs to be changed </default> </privilegeSets>
changed to this:
<privilegeSets> <default> <view descr="View entity"/> <edit descr="Edit entity"/> <delete descr="Delete entity"/> // this value changed <create descr="Create entity"/> // this value changed </default> </privilegeSets>
This definitely fixes the problem.
|
| |
-
- Posted: October 1 2008
-
| top
| # 8
-
|
 |
 |
 |
|
|
-
- Georg Ringer

-
Total Posts: 61
Joined: 2008-07-04
Linz, Austria
|
it was just my own experience (product single page got blank because of an error at a complete different script [related products]) but as you said.. the other fix is the way to go
georg
|
| |
-
- Posted: October 2 2008
-
| top
| # 9
-
|
 |
 |
 |
|
|