Re: REST, Xml::fromArray() and find('all')
I can confirm this issue. The Xml class does not play nice with the array structure generated by the model find method when multiple records are returned. Due to the time sensitive nature of my task, I opted to use JSON rather than debug a core utility class. That said, I would certainly love to hear the fix if anyone has it readily available. Ryan On Thursday, 23 August 2012 04:47:02 UTC-6, Alexandre LeprĂȘtre wrote: Hi everyone, I am trying to build a nice REST API for my website and I had never tried it through CakePHP. I started to follow the (short) instructions, however, the way it works looks totally different from what I can read in the Cookbook. I use CakePHP 2.2.1. Here's what I've done so far: *app/Controller/OrdersController.php* ?php class OrdersController extends AppController { public function fetch($accountId) { $this-loadModel('Account'); $this-Account-id = $accountId; $orders = $this-Order-find('all', array( 'conditions' = array('Order.account_id' = $accountId) )); $response = $orders; $this-set(compact('response')); } } *app/View/Orders/xml/fetch.ctp* ?php $xml = Xml::fromArray(array('orders' = $orders)); echo $xml-asXML(); I tried this with the first account and everything was fine *Ouput:* orders Order id502cc39f-5b74-4a25-9bb2-670458d0d2b2/id order_ref96277/order_ref account_id502cc39d-8640-465a-b0da-670458d0d2b2/account_id created2012-08-16 09:55:43/created modified2012-08-16 09:55:43/modified /Order /orders Everything is fine with an account that has one order. However, with an account that has several orders, this doesn't work anymore. *Expected output:* orders Order id502cc39f-66eb-59d2-2337-670458d0d2b2/id order_ref96255/order_ref account_id502cc39d-6325-ad25-5b64-670458d0d2b2/account_id created2012-08-16 09:42:33/created modified2012-08-16 09:42:33/modified /Order Order id502cc39f-ee21-3c89-8120-670458d0d2b2/id order_ref96231/order_ref account_id502cc39d-6325-ad25-5b64-670458d0d2b2/account_id created2012-08-16 09:21:01/created modified2012-08-16 09:21:01/modified /Order /orders * * *What I get:* This page contains the following errors: error on line 1 at column 367: Entity 'nbsp' not defined Below is a rendering of the page up to the first error.*Warning* (2)http://devapi.ssl247.net/orders/fetch/502cc1be-7e48-4913-89c2-65f058d0d2b2.xml: SimpleXMLElement::__construct() [simplexmlelement.--constructhttp://devapi.ssl247.net/orders/fetch/simplexmlelement.--construct]: Entity: line 3: parser error : Extra content at the end of the document [* CORE\Cake\Utility\Xml.php*, line *197*]Codehttp://devapi.ssl247.net/orders/fetch/502cc1be-7e48-4913-89c2-65f058d0d2b2.xml Contexthttp://devapi.ssl247.net/orders/fetch/502cc1be-7e48-4913-89c2-65f058d0d2b2.xml I assume that Xml::fromArray() doesn't accept multiple numeric keys. Or something like this. I don't mind editing my PHP array to get he XML I expect but I really don't know how I should write my array for this :-( Any help is welcome. Thank you!! Alex -- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
Re: Intermittent cache write failures with files or memcached - NginX, PHP-FPM, Load Balanced
It was a write permissions error on the files and a storage error in Memcached. Oddly enough, I can no longer reproduce these. It must be a server level problem. Thanks for your response and I will update if I figure out what it was. Ryan On Thu, Aug 9, 2012 at 9:20 PM, Dr. Tarique Sani tariques...@gmail.comwrote: What is the error you are getting then attempting to re-write cache? OR is it that the code is not reaching the write to cache stage? Tarique On Thu, Aug 9, 2012 at 10:03 PM, Ryan Willis techno...@gmail.com wrote: Howdy :) To give you a feel for the environment, we have a highly available configuration of two load balanced web servers and two database servers (master/slave). We are using CakePHP 2.2.1 on NginX and PHP-FPM with PHP 5.4. We are noticing intermittent cache write failures despite having tried both file based caching and memcached. For file based caching, even with permissions being 777 and the umask set to 777, a cache file cannot be overwritten once it is written. On the memcached side, the store failures follow the same pattern. Once it has been written, it cannot be overwritten when it expires. I am at a loss. At first I thought it had something to do with our file syncing on the web servers but then we moved to memcached to sitestep the issue and we are having the same problem. Any ideas? Thanks in advance! -- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en-US. -- = PHP for E-Biz: http://sanisoft.com = -- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en-US. -- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
Intermittent cache write failures with files or memcached - NginX, PHP-FPM, Load Balanced
Howdy :) To give you a feel for the environment, we have a highly available configuration of two load balanced web servers and two database servers (master/slave). We are using CakePHP 2.2.1 on NginX and PHP-FPM with PHP 5.4. We are noticing intermittent cache write failures despite having tried both file based caching and memcached. For file based caching, even with permissions being 777 and the umask set to 777, a cache file cannot be overwritten once it is written. On the memcached side, the store failures follow the same pattern. Once it has been written, it cannot be overwritten when it expires. I am at a loss. At first I thought it had something to do with our file syncing on the web servers but then we moved to memcached to sitestep the issue and we are having the same problem. Any ideas? Thanks in advance! -- You received this message because you are subscribed to the Google Groups CakePHP group. To post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en-US.