I added some Articles in an array. This works fine, but if I check the page with the MiniCart Module I get the right output at the first call. Then I refresh the page an get an Error 500. Only since PHP 7.1
<?php
namespace NeosCommerce\Cart\Controller;
/*
* This file is part of the NeosCommerce.Cart package.
*/
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
/**
* @Flow\Scope("session")
*/
class CartController extends ActionController
{
/**
* @var array
*/
protected $items = array();
/**
* @Flow\Inject
* @var \NeosCommerce\Cart\Domain\Repository\CartRepository
*/
protected $cartRepository;
/**
* @param integer $title
* @return void
* @Flow\Session(autoStart = TRUE)
*/
public function addtoAction($title) {
$cart = $this->items;
$article = array();
$article[] = array("title"=>$articleTitle);
$this->redirectToUri('/');
}
/**
* @return void
*/
public function miniCartAction() {
$cart = $this->items;
if ($cart==false) {
$sum = "";
$sum = intval($sum);
foreach ($cart as $dat) {
$quantity = intval($dat["quantity"]);
$sum += $quantity;
}
$this->view->assign('itemscount', $sum);
$this->view->assign('items', $cart);
} else {
$this->view->assign('itemscount', '0');
$this->view->assign('items', '0');
}
}
}
Okay, I have found this in the error.log but I do not understand it. Can you help me?
[Fri Jul 14 07:16:54.157005 2017] [:error] [pid 12681] [client 80.123.79.100:57957] FastCGI: server “/usr/lib/cgi-bin/php71-fcgi-www” stderr: PHP message: PHP Fatal error: TYPO3Fluid\Fluid\View\AbstractTemplateView::getCurrentParsedTemplate(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition “Cart_action_miniCart_3debb049a1d40f09835559fe0b2308f9599a9c2b” of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /var/www/Neos3dev/Packages/Libraries/typo3fluid/fluid/src/View/AbstractTemplateView.php on line 364, referer: http://mydomain.com/de/mini-warenkorb.html
What you definitely do there is mix variable types. your items variable is either an array or a string with 0 in it. You should adjust that, asme for itemscount. Also how can $cart ever be false?
Thx Christian, I’ve fixed this. But it does not work. I think, it is an issue with PHP 7.1. It works with PHP 7.0
The line in the apache error log:
FastCGI: server “/usr/lib/cgi-bin/php71-fcgi-www” stderr: PHP message: PHP Fatal error: TYPO3Fluid\Fluid\View\AbstractTemplateView::getCurrentParsedTemplate(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition “Cart_action_miniCart_7a047694d155e6a53865076308e9879f5492a491” of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /var/www/Neos3dev/Packages/Libraries/typo3fluid/fluid/src/View/AbstractTemplateView.php on line 364, referer: http://my.subdomain.com/de/mini-warenkorb.html
It was not the solution. After the restart it worked. But after a short time it does not work anymore. I just added a <strong> tag in the template and get a 500 error again
OPCache is disabled
I don’t understand this, but this Code is in use in an old “TYPO3” Neos and it works.
First I think PHP 7.1 makes problems, but I have the same php.ini settings as in PHP 5. I have no idea anymore.