Some interesting findings from web-dev land…
I was experiencing this issue with some larger file uploads using the CakePHP Media plugin.
https://bugs.webkit.org/show_bug.cgi?id=5760
Add this to the virtual host declaration in your Apache config file to fix it:
123456<VirtualHost x.x.x.x:x>
# Prevent Safari from hanging on uploads
BrowserMatch Safari nokeepalive
</VirtualHost>
If you’re trying to use the CakePHP Media plugin with 1.3 (I’m running RC3) and you get this error when deleting an attachment:
1Call to undefined method Folder::ls() in /path_to_app/app/plugins/media/models/behaviors/media.php on line 277
ls() has been deprecated in favour of read(), change line 277 of /path_to_app/app/plugins/media/models/behaviors/media.php to:
1list($versions, ) = $Folder->read();
All should work fine thereafter ;]
I wasn’t having much luck with the example given in the CakePHP book for a Has and Belongs To Many relationship with a single option select menu in the view.
Anyway overriding the element type does the trick:
1<?php echo $form->input(’ResellerField’, array(’multiple’ => false)) ?>
Quick refresher for my own records. CakePHP ACL component console commands:
1234567891011121314151617181920212223# View ACO tree
cake acl view aco
# Create root ACO container – in this instance site
cake acl create aco root site
# Create ACO controller node – in this instance the products controller
cake acl create aco site Products
# Create ACO controller action node – in [...]
This is quite handy if you’re working in a team and you don’t want the designer/client poking about in the controllers to set page titles. You can set them in the view using this code:
1<? $this->pageTitle = ‘My page title’ ?>
I’ve been using the containable behavio(u)r in CakePHP along with the $recursive = -1 property in my models to cut down on the amount of SQL querying going on.
I needed to specify a second level recursion on one of my associated models and managed it by doing this:
12345$this->paginate[’Invoice’][’contain’] = array(
‘Order’ => ‘OrderedProduct’,
[...]
If you use the CakePHP Auth component and you need some conditions for users attempting to login, you can set this attribute/property in the Auth object:
1$this->Auth->userScope = array(’User.status’ => 1);
The userScope attribute behaves pretty much like an Active Record find condition definition.
So in the above example, only users with a status of 1 (active) can [...]
Tried to do a schema snapshot of my db today (cake schema generate) to throw in SVN. I’d added an enum column to one of my tables and it threw this error:
1Notice: Schema generation error: invalid column type enum(’flat_fee’,'per_unit’) does not exist in DBO in /vhosts/site.com/accounts/cake/libs/model/schema.php on line 475
Enum must be too old-school and crusty [...]
This is quite a handy method for your tools class. It will split camelcase strings up nicely. You could then explode if necessary:
123456static function splitByCaps($string){
return preg_replace(’/[A-Z]/’, ‘ $0′, $string);
}
Tools::splitByCaps(’HelloWorld’);
#Will return ‘Hello World’
I managed to recompile PHP with some new directives and install it on my live production server with minimal downtime.
I followed these steps:
1) Downloaded the source of PHP. I stuck to the same branch (5.2) as there was nothing I required in 5.3.
2) Backed up my /etc/php.ini file.
3) Compiled PHP with ./configure using my old [...]