Tuesday, October 2, 2012

Re: CakePHP 2.2.2 and DebugKit don't play nice

Add "Session" to components in app controller

Andras Kende
818-851-1177
andras@kende.com
http://www.kende.com

On Oct 2, 2012, at 13:57, Paul Willis <paul.willis@me.com> wrote:

> I created a CakePHP 2.2.2 app. I did the basic installation steps, security salt, /tmp permissions etc. All the green bars on the home page.
>
> I added a MySQL database with a Reports table...
>
> CREATE TABLE `reports` (
> `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
> `title` varchar(100) DEFAULT NULL,
> `created` datetime DEFAULT NULL,
> `modified` datetime DEFAULT NULL,
> PRIMARY KEY (`id`)
> ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
>
> I then baked a model, controller and views for the Reports table.
>
> Everything works fine as you would expect, I can add, edit and delete records.
>
> In the command line I cd into my app/Plugin and run...
>
> git clone -b master git://github.com/cakephp/debug_kit.git DebugKit
>
> As per the instructions I add
>
> CakePlugin::load('DebugKit');
>
> To app/Config/bootstrap.php and add
>
> public $components = array('DebugKit.Toolbar');
>
> to AppController.php.
>
> I refresh my page and I see the DebugKit tab. It works fine.
>
> However as soon as I add/edit or delete a record I get a Fatal error although the add/edit is saved to the database. For instance on edit as soon as I submit I see…
>
> Fatal Error
> Error: Call to a member function setFlash() on a non-object
> File: /Library/WebServer/Documents/MySites/debugtest/app/Controller/ReportsController.php
> Line: 66
>
> Looking at line 66 in ReportsController I see the baked setFlash message line…
>
> $this->Session->setFlash(__('The report has been saved'));
>
> If I comment out the line then my app works fine again (obviously without the flash messages)
>
> If I leave the setFlash uncommented but comment out public $components = array('DebugKit.Toolbar'); from AppController.php (ie: turn off DebigKit) my app works fine.
>
> I've tried this setup twice now, with clean installs and setting up and it happened both times.
>
> When the error shows I looked in DebugKit and under the 'Request' tab 'Current Route' has a warning…
>
> Invalid argument supplied for foreach() [APP/Plugin/DebugKit/View/Helper/HtmlToolbarHelper.php, line 68]
>
> If I click the code button I see…
>
> $values[] = '(empty)';
> }
> foreach ($values as $key => $value) {
>
> Where "foreach ($values as $key => $value) {" is line 68 in HtmlToolbarHelper.php
>
> The context button shows…
>
> $values = '(object)CakeRoute'
> $openDepth = (int) 0
> $currentDepth = (int) 0
> $doubleEncode = false
> $className = 'neat-array depth-0'
> $nextDepth = (int) 1
> $out = '<ul class="neat-array depth-0">'
>
> Has anyone got any ideas what is going on here?
>
> Cheers
>
> Paul
>
> --
> Like Us on FacekBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> 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+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>

--
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.

No comments: