...somewhat damaged.

CakePHP 1.3.3 Broken Pagination Sort Options

CakePHP 1.3.3 Broken Pagination Sort Options

Working with CakePHP v1.3.3 and the Pagination helper I discovered that the Direction option for the Sort method sort of goes ignored— or more like over-written with whatever value CakePHP decides to use.   I’m not happy with my hack, but I need this functionality today.  I’m also not too fond of having to hack-up source code when upgrades will be involved because I have to keep porting forward my patches.  So anyhow.  Here’s what I’m trying to do.

In my view, I’d like to have sort options such as, Most Recent, Most Viewed, Longest Video, Shortest Video.  I’ve tried hard-coding the URL for the Paginator to use, this didn’t work well with some of the search options.  I tried to be crafty with $this->here, $this->action and $this->name.   I figured it’d be best to let the Paginator deal with it.  So I dug up the documentation on $this->Paginator->sort();  Set ‘direction’=>’desc’, and the generated link wasn’t in Descending order. :-S   Here’s what I found.

$dir = isset($options['direction']) ? $options['direction'] : 'asc';
unset($options['direction']);

$sortKey = $this->sortKey($options['model']);
$defaultModel = $this->defaultModel();
$isSorted = (
	$sortKey === $key ||
	$sortKey === $defaultModel . '.' . $key ||
	$key === $defaultModel . '.' . $sortKey
);
if ($isSorted) {....}

I changed it to check for the Direction option.

$dir = isset($options['direction']) ? $options['direction'] : 'asc';
//unset($options['direction']);

$isSorted = false;
if (!isset($options['direction']))
{
	$sortKey = $this->sortKey($options['model']);
	$defaultModel = $this->defaultModel();
	$isSorted = (
		$sortKey === $key ||
		$sortKey === $defaultModel . '.' . $key ||
		$key === $defaultModel . '.' . $sortKey
	);
}

if ($isSorted) {....}

Seems to work with all my other pagination throughout the site. I haven’t tested it heavily, but it appears to work.

Read More

Using CakePHP with Plesk 10

Using CakePHP with Plesk 10

If you haven’t already figured it out, you can’t just unarchive CakePHP and drop it into your httpdocs folder under Plesk. There’s some minor changes you need to make before Plesk plays nicely with CakePHP.

First think that needs to be done is to create a vhost.conf file in /var/www/vhosts/domain.com/conf/ directory that contains the following

 

<Directory /var/www/vhosts/domain.com>
	php_admin_flag engine on
	php_admin_value open_basedir none
</Directory>

After you’ve done that, you’ll need to run the Plesk command line tool to regenerate the vhost files.

/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain domain.com
Read More

Vimeo, OAuth and CakePHP Session Security Settings

Vimeo, OAuth and CakePHP Session Security Settings

So after ripping my hair out for a good 2-3hrs trying to figure out why my Vimeo OAuth requests wasn’t returning any sessions variables, I finally figured it out.

CakePHP’s Configure::write(‘Security.level’, ‘medium’); sets PHP’s session.referer_check and denies any other hosts from setting session variables. I was wondering why half my sessions vars were gone and it would appear I was logged-out. Setting Configure::write(‘Security.level’, ‘low’); seems to have fixed the issue. But anytime you read ‘Security Low’ in the same sentence, it leaves you with some sort of uncomfortable feeling.

I’m not exactly sure what the status of this is. But I found a link that pretty much explains it all. session.referer_check PHP ini var should be decoupled from ‘High’ and ‘Medium’ Session Security levels

Read More

Hosting CakePHP on GoDaddy

Hosting CakePHP on GoDaddy

Found this simple .htaccess fix for getting CakePHP to work on GoDaddy.

mod_rewrite On GoDaddy Shared Hosting

Just adding the leading / fixes the “500 Internal Server Error” I was getting.

Read More

CentOS 5.2 w/ CakePHP + PCRE

After wondering why CakePHP’s Inflector::slug() was returning gibberish, I found this post about how to fix it.

Unicode Support on CentOS 5.2 with PHP and PCRE

Read More