CoedIgniter: Call to a member function contents() on a non-object
I recently upgraded my 2.x CodeIgniter app to the RC of 3.0. Everything is
running fine on my local machine.
But when I throw it up on a remote server when I try to call:
$this -> cart -> contents();
I get this error:
PHP Fatal error: Call to a member function contents() on a non-object in ...
If I
var_dump($this->cart)
on my local machine I get the expected cart object returned, but the same
returns
NULL
when run on my remote server.
I also have a extension class for cart, which is just this:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Cart extends CI_Cart
{
function __construct()
{
parent::__construct();
$this->product_name_rules = '\d\D';
$this->product_id_rules = '\d\D';
}
}
If I delete the MY_Cart.php file (above code) from my libraries folder I
will get the same Call to member function contents() on a non-object that
I do on my remote server. Why would removing my own cart extension cause
the cart object to cease to exist?
Any insight as to what might be causing this behavior, I've tried asking
on the CodeIgniter forums with no luck.
Both my local machine and remote server are running PHP 5.4.17.
Here is a stack trace:
"…bss_web/public/development.bluesea.com/public/application/controllers/
cart.php (32) in Cart::add called at ? (?)"
//increment quantity by 1 if PN is already in cart
$qty = 1;
$items = $this->cart->contents(); //line 32
foreach ($items as $key => $item) {
if ($item['id'] == $pid) {
$qty = $item['qty'] + 1;
}
}
…home/bss_web/public/development.bluesea.com/public/system/core/
CodeIgniter.php (356)
/*
* ------------------------------------------------------
* Call the requested method
* ------------------------------------------------------
*/
call_user_func_array(array(&$CI, $method), $params); // Line 356
…e_once called at /home/bss_web/public/development.bluesea.com/public/
index.php (312)
/*
* --------------------------------------------------------------------
* LOAD THE BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*/
require_once BASEPATH.'core/CodeIgniter.php'; //line 312
No comments:
Post a Comment