I forgot to mention that I *did* try debugging this with the
controller's $components line commented. In fact, right now, with or
without $components available, this still gives me a truncated array:
public function add($media_type_slug = null)
{
die(Debugger::dump($this->data));
... whereas, a simple die(debug($this->data)); works as expected.
On Mon, Jan 12, 2009 at 2:59 PM, brian <[email protected]> wrote:
> Got it working. Unfortunately, I'm still in the dark on this. None of
> what I did to make it work explains why Debugger was repeating the
> statements. I ruled out (from the access log) the action being
> accessed more than once. And, why Debugger's dump would show nothing
> when a die(debug($this-data)) immediately before it would show the
> data.
>
> Anyway, it seems that *part* of my problem was that my component had:
>
> function init(&$controller)
> {
> $this->controller = $controller;
> }
>
> followed by:
>
> public function save($dir, $options, $filename = null)
> {
> $this->controller_data =& $this->controller->data['MYModel'];
> ...
>
> I changed inti() to startup() and that seemed to fix things. I say
> "seemed" because I also did a lot of fiddling and, anyway, I can't
> figure out why just this change would resolve the problem.
>
> And, again, Debugger was *still* doing some weird things here. I wish
> I had the time to delve into this some more but I'm in the final
> stretch in this project and have to make up for a day's worth of
> hair-pulling. I'd need to learn a lot more about Cake internals before
> getting a grip on this.
>
>
> On Mon, Jan 12, 2009 at 12:16 PM, brian <[email protected]> wrote:
>> Thanks, but no luck. The access log doesn't show anything strange that
>> I can see. But, I still see Debugger's statements repeated a couple
>> seconds later.
>>
>> But, the strangest thing of all is this:
>>
>> public function add($media_type_slug = null)
>> {
>> die(debug($this->data));
>> die(Debugger::dump($this->data));
>> ...
>>
>> This prints the data just fine. All of it is there, as I'd expect it.
>> Sadly, I have to kill the data in order to save it, as it were ;-)
>>
>> However, when I comment the first line, I get an array with only the
>> model name keys, both of which contain empty arrays, in turn. That is,
>> not even any fieldname keys.
>>
>> array(
>> "Record" => array(),
>> "Discipline" => array()
>> )
>>
>> So, unless I've missed something crucial in the docs, something's
>> quite wrong here. I'd post this to Trac but I wouldn't know where to
>> begin to write a test case for this.
>>
>> The thing is, I've no idea if they're even related. The Debugger
>> statements are not causing the data to disappear--if I comment them
>> all, I'm still left with a damaged $data array.
>>
>> You can imagine how much fun this is, given I'm SO close to putting
>> this site live :-(
>>
>>
>> On Mon, Jan 12, 2009 at 6:12 AM, grigri <[email protected]> wrote:
>>>
>>> Try logging the exact url that was requested each time - I had a
>>> similar problem a while ago which was due to an incorrectly formatted
>>> image tag - I just had
>>>
>>> <img src="img/something.png" alt="" />
>>>
>>> On the /customers/login page this would end up generating a request
>>> for
>>>
>>> `/customers/login/img/something.png`
>>>
>>> which was processed through the login action of the customers
>>> controller, resulting in the method being called twice for each page
>>> request.
>>>
>>> This was driving me nuts until I looked at the actual request logs and
>>> spotted the strange url.
>>>
>>> hth
>>> grigri
>>>
>>> On Jan 12, 6:58 am, brian <[email protected]> wrote:
>>>> more: I put this immediately inside add()
>>>>
>>>> die(debug($this->data));
>>>> Debugger::dump($this->data);
>>>>
>>>> This dumps the data--intact--onto the page. When I comment out the
>>>> die() line, I get:
>>>>
>>>> array(
>>>> "Record" => array(),
>>>> "Discipline" => array()
>>>> )
>>>>
>>>> I can't see how this possibly could be a PEBCAK situation, though I'd
>>>> be grateful just to figure this out.
>>>>
>>>> How the heck can the data be disappearing like this?!
>>>>
>>>> I realise this probably isn't a Debugger problem and I really should
>>>> open a new thread, but Debugger sure isn't helping, in any case. That,
>>>> and the repeated writes to the log make me wonder. But, all the same,
>>>> with no Debugger calls, the data still goes bye-bye.
>>>>
>>>> HELP!
>>>>
>>>> On Mon, Jan 12, 2009 at 1:35 AM, brian <[email protected]> wrote:
>>>> > More on this: I put this in the controller:
>>>>
>>>> > function beforeFilter()
>>>> > {
>>>> > die(debug($this->data));
>>>> > }
>>>>
>>>> > So, when I submitted the form, all the data was right where it should
>>>> > be. (Obviously, I commented it to get the form to display). So, its
>>>> > disappearing act comes somewhere between beforeFilter() and add().
>>>> > I've been trying to hunt down the precise order of operations but have
>>>> > come up empty-handed. I know that I saw it somewhere once (it'd be
>>>> > nice if this was included in the Cookbook's "A Typical CakePHP
>>>> > Request" page). Is there anything between beforeFilter() and the
>>>> > controller's action??
>>>>
>>>> > Before doing this, btw, there was no beforeFilter(). I've commented
>>>> > AppController::beforeFilter(). I commented the $components array.
>>>> > There's nothing in the model (nor AppModel) that would screw with the
>>>> > data.
>>>>
>>>> > This was working earlier. Well, it was broken (it's early going) but I
>>>> > could debugger::log($this->data) just fine before. I must have done
>>>> > *something* to screw this up but, after staring at it for a couple of
>>>> > hours now, I'm absolutely fresh out of ideas.
>>>>
>>>> > On Sun, Jan 11, 2009 at 11:40 PM, brian <[email protected]> wrote:
>>>> >> I'm trying to debug a problem with one of my controllers where
>>>> >> $this->data is (almost) empty (more on that in a sec) and so tossed a
>>>> >> bunch of Debugger::log statements in the action. When I checked the
>>>> >> debug.log I found that the entries are being repeated.
>>>>
>>>> >> The action starts out like this. I put several debugger statements in
>>>> >> because I was trying to figure out what was happening to $this->data.
>>>>
>>>> >> public function add($media_type_slug = null)
>>>> >> {
>>>> >> $this->set('user_id', $this->Session->read('User.id'));
>>>>
>>>> >> debugger::log('controller -- first');
>>>> >> debugger::log($this->data);
>>>> >> ...
>>>> >> // more stuff, and several other Debugger::log() statements
>>>>
>>>> >> debug.log:
>>>>
>>>> >> 2009-01-11 23:17:17 Debug: "controller -- first"
>>>> >> 2009-01-11 23:17:17 Debug: null
>>>> >> 2009-01-11 23:17:19 Debug: "controller -- first"
>>>> >> 2009-01-11 23:17:19 Debug: null
>>>> >> 2009-01-11 23:17:21 Debug: "controller -- first"
>>>> >> 2009-01-11 23:17:21 Debug: null
>>>> >> 2009-01-11 23:17:50 Debug: "controller -- first"
>>>> >> 2009-01-11 23:17:50 Debug: array(
>>>> >> "Record" => array(),
>>>> >> "Discipline" => array()
>>>> >> )
>>>> >> 2009-01-11 23:17:50 Debug: "controller -- second"
>>>> >> 2009-01-11 23:17:50 Debug: array(
>>>> >> "Record" => array(),
>>>> >> "Discipline" => array()
>>>> >> )
>>>> >> 2009-01-11 23:17:50 Debug: "controller -- third"
>>>> >> 2009-01-11 23:17:50 Debug: array(
>>>> >> "Record" => array(),
>>>> >> "Discipline" => array()
>>>> >> )
>>>>
>>>> >> The first 3 occur the first time I hit the action. $this->data is
>>>> >> properly empty. What's weird, though, is that Debugger places 3
>>>> >> entries, each 2 seconds apart, in the log.
>>>>
>>>> >> Now, when I submit the form at 23:17:50, I don't see that first one
>>>> >> repeated. So, what's up with that? It can't be that Cake is running
>>>> >> through the method 3 times the first time, can it? Because the other
>>>> >> Debugger stateents are all inside an if(empty($this->data)) block.
>>>>
>>>> >> Anyway, besides all of that, as you can see, when the form is
>>>> >> submitted, I'm only seeing the names of the 2 models used in the form,
>>>> >> but no data at all. Anyone have any ideas on that? I'm well and truly
>>>> >> stumped!
>>>>
>>>> >> The form is nothing special and looks like:
>>>>
>>>> >> echo $form->create('Record', array('action' => 'add', 'type' =>
>>>> >> 'file'));
>>>> >> echo $form->hidden('Record.user_id', array('value' => $user_id));
>>>> >> echo $form->hidden('Record.media_type_id', array('value' =>
>>>> >> $media_type['MediaType']['id']));
>>>> >> echo $form->hidden('Record.media_type_slug', array('value' =>
>>>> >> $media_type['MediaType']['slug']));
>>>> >> ...
>>>>
>>>> >> echo $form->end('send it');
>>> >>>
>>>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---