Tuesday, March 30, 2010

shell missing view

Cake 1.2.5

I received the following error msg from a cron job:

-- snip --
PHP Warning: extract(): First argument should be an array in /usr/lib/
php/cake_1.2.5/cake/console/error.php on line 149
PHP Notice: Undefined variable: file in /usr/lib/php/cake_1.2.5/cake/
console/error.php on line 150
PHP Notice: Undefined variable: action in /usr/lib/php/cake_1.2.5/
cake/console/error.php on line 150
PHP Notice: Undefined variable: className in /usr/lib/php/cake_1.2.5/
cake/console/error.php on line 150
Error: Missing View '' for '' in ''
-- snip --

The cron job is called this way:

/var/www/vhosts/THE_DOMAIN/httpdocs/app/vendors/cakeshell membership -
cli /usr/bin -console /usr/lib/php/cake/cake/console/cake -app /var/
www/vhosts/THE_DOMAIN/httpdocs/app


The problem is, I can't figure out what view it's looking for. The
script, membership.php, has all its logic in main(), which uses the
Queue plugin[1] to set up some email jobs. That is handled by my
SwiftMailer task, which works fine. I call Queue like this:

$this->Queue->load(
'swiftmailer',
array(
'settings' => array(
'view' => 'member_expiry_notice',
'subject' => 'the subject line',
'from' => array(EMAIL_NO_REPLY, 'the email name'),
'to' => $member['Member']['email']
),
'vars' => array('member' => $member)
)
);

This very same logic is used elsewhere and works fine. The view param
here shouldn't have anything to do with this error because the code
isn't running right away (it's going into the queue). It seems to me
that this particular shell is what Cake wants a view for, but that
doesn't make any sense to me. Shells have views? Did I miss something?
Do I need to set $autoRender to false? I can't find any info on this.

One idea I have is that the shell has a Controller member var:


class MembershipShell extends Shell
{
private $Controller;
private $Member;

function startup()
{
App::import('Model', 'Member');
$this->Member =& new Member;
}

/**
* Fetch all members whose expiration is in some number of days and
* inform them of same.
*
* @param void
* @return void
* @access public
*/
public function main()
{
$this->Controller =& new Controller();
$this->Queue =& new QueueComponent(null);
$this->Queue->initialize($this->Controller);
...

So, maybe I need to do $this->Controller->autoRender = false?


Aside from the missing view, I'm confused as to why $params was empty
in the call to missingView() (the line 149 from above). Anyone have
any ideas?

[1] http://bakery.cakephp.org/articles/view/cakephp-simple-queue-plugin

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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 For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments: