Fatal error: Call to a member function setQuote() on boolean in /home/thetiresquire/public_html/app/code/core/Mage/Sales/Model/Quote.php on line 745 - function

Please help me to resolve the error am getting on home page.
MY CART :
0 item(s) -
Fatal error: Call to a member function setQuote() on boolean in /home/thetiresquire/public_html/app/code/core/Mage/Sales/Model/Quote.php on line 745
Here is the code where it is pointing to is
public function getItemsCollection($useCache = true)
{
if ($this->hasItemsCollection()) {
return $this->getData('items_collection');
}
if (is_null($this->_items)) {
$this->_items = Mage::getModel('sales/quote_item')->getCollection();
$this->_items->setQuote($this);
}
return $this->_items;
}
The error is pointing to line $this->_items->setQuote($this);
I have cleared the cache and flushed the cache from admin
Please help am new to magento.
Thanks,
Shabana

Related

Invalid Configuration – yii\base\InvalidConfigException In yii2

I'm getting error in yii2 Invalid Configuration – yii\base\InvalidConfigException
Error :
Invalid Configuration – yii\base\InvalidConfigException
The directory does not exist:
1. in /home/dobuyme/public_html/vendor/yiisoft/yii2/web/AssetManager.phpat line 239
230231232233234235236237238239240241242243244245246247248 public function checkBasePathPermission()
{
// if the check is been done already, skip further checks
if ($this->_isBasePathPermissionChecked) {
return;
}
if (!is_dir($this->basePath)) {
echo $this->basePath;
throw new InvalidConfigException("The directory does not exist: {$this->basePath}");
}
if (!is_writable($this->basePath)) {
throw new InvalidConfigException("The directory is not writable by the Web process: {$this->basePath}");
}
$this->_isBasePathPermissionChecked = true;
}
How i can solve this issue?
it shows The directory does not exist:

After upgrading php version All Errors Are Now "An Internal Server Error Occurred" in cake php

i am using cake php 3. Some days ago I have updated php version from 5.6 to 7.1.17 . Now if there is any error happen in my apps it show An Internal Server Error Occurred". I can see error log in my error.log file like this [Error] Call to a member function user() on boolean
Request URL: /robots.txt
Here is how my user() function called. It was working fine with php 5.6..
public function beforeRender(Event $event)
{
if($this->Auth->user()){
$this->set('loggedIn', true);
}
else{
$this->set('loggedIn',false);
}
}
This is how I solved the problem. Added this line $this->loadComponent('Auth'); in the beforeRender function. I got this solution from
Fatal error: Call to a member function user() on boolean

How pass body variable as a parameter to custom Exception

I'm struggling to understand how passing a variable stored in the body as a parameter of throwException.
This is my code:
.when(simple("${body[errorCode]} contains '101'"))
.throwException(new IllegalArgumentException(
"Action not allowed- Error code:" + ${body[errorCode]))
.otherwise()
When I run the application the message passed to ErrorHandling is
'Action not allowed- Error code:${body[errorCode]', no replacing for errorCode variable.
Any suggestions? Tnks.
So you are using the Simple language in Java but you have some syntax issues. Nothing major. Your do not complete the delimiter of the Simple expression. Also you dont have to concatenate the string.
Change the code:
.throwException(new IllegalArgumentException("Action not allowed- Error code:" + ${body[errorCode]))
To:
.throwException(new IllegalArgumentException("Action not allowed- Error code: ${body[errorCode]}"))
I am on the buss and using my phone so can't check if the code runs but it should point you in the right direction.
#Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
#Override
public void configure() throws Exception {
from("direct:start")
.to("mock:start")
**.throwException(IllegalArgumentException.class, "Darn ${body} is invalid")**
.to("mock:result");
}
};
}
See the unit tests of camel-core for an example
https://github.com/apache/camel/blob/master/camel-core/src/test/java/org/apache/camel/processor/ThrowExceptionMessageTest.java

How to catch the 404 error with cakephp 3 in a productive environment

I want to catch all 404 errors (controller not found) in my new cake app. But I don't have a clue how.
Is there any configuration for that? Or must I catch the thrown error by myself? If so, where?
Here is one approach, that could work. Define you own error handler, that extends default ErrorHandler
<?php
// Custom Handler - goes in src/Error/AppError.php
namespace App\Error;
use Cake\Routing\Exception\MissingControllerException;
use Cake\Error\ErrorHandler;
class AppError extends ErrorHandler
{
public function _displayException($exception)
{
if ($exception instanceof MissingControllerException) {
// Here handle MissingControllerException by yourself
} else {
parent::_displayException($exception);
}
}
}
Then register this handler as default.
// Register handler in config/bootstrap.php
use App\Error\AppError;
$errorHandler = new AppError();
$errorHandler->register();
http://book.cakephp.org/3.0/en/development/errors.html

Fatal error: Can't use function return value in write context SOMETIMES

I get so annoyed when I transfer websites from one machine to another and I get a bunch of errors, such as this case. But this one made it to my curiosity and this is why I'm asking a question. I have the following code:
namsepace MF;
class Box {
private static $dumpYard = array();
public static function get($name) {
return self::$dumpYard[$name];
}
public static function set($name, $value, $overwrite=false) {
if($overwrite || !isset(self::$dumpYard[$name])){
self::$dumpYard[$name] = $value;
}else{
if(DEBUG_MODE){
echo('Value for "'.$name.'" already set in box, can\'t overwrite');
}
}
}
}
So when my application gets to the following line on my LOCAL testing server:
if(!empty(\MF\Box::get('requestsSpam'))){
throw new \Exception('Please don\'t spam');
}
I get a Fatal error: Can't use function return value in write context. However this code does not throw an error on the actual hosting server of my website. How come is that?
empty() works only with a variable. It should be:
$result = \MF\Box::get('requestsSpam');
if(!empty($result)){
throw new \Exception('Please don\'t spam');
}
Why? empty() is a language construct and not a function. It will work only with declared variables, that's just how it is designed, no magic.