PHP Fatal error Uncaught Error: Call to a member function getMetaTitle() on null in - magento-1.9

I'm getting the following error but it says it in Magento core. I was wondering how to debug this because I'm sure there is nothing wrong in Magentos core.
Here is the error:
30-Apr-2018 18:05:23 UTC] PHP Fatal error: Uncaught Error: Call to a member function getMetaTitle() on null in /home/example/public_html/app/code/core/Mage/Catalog/Block/Product/View.php:18
Stack trace:
#0 /home/example/public_html/app/code/core/Mage/Core/Block/Abstract.php(139): Mage_Catalog_Block_Product_View->_prepareLayout()
#1 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(322): Mage_Core_Block_Abstract->setLayout(Object(Inchoo_PHP7_Model_Layout))
#2 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(332): Mage_Core_Model_Layout->createBlock('review/product_...', 'product.info')
#3 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(147): Mage_Core_Model_Layout->addBlock('review/product_...', 'product.info')
#4 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(119): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#5 /home/example/public_html/app/co in /home/example/public_html/app/code/core/Mage/Catalog/Block/Product/View.php on line 18
Here is /home/angelsforeveryon/public_html/app/code/core/Mage/Catalog/Block/Product/View.php:18
protected function _prepareLayout()
{
$this->getLayout()->createBlock('catalog/breadcrumbs');
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
$product = $this->getProduct();
line 18 here --> $title = $product->getMetaTitle();
if ($title) {
$headBlock->setTitle($title);
}
$keyword = $product->getMetaKeyword();
$currentCategory = Mage::registry('current_category');
if ($keyword) {
$headBlock->setKeywords($keyword);
} elseif ($currentCategory) {
$headBlock->setKeywords($product->getName());
}
$description = $product->getMetaDescription();
if ($description) {
$headBlock->setDescription( ($description) );
} else {
$headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255));
}
if ($this->helper('catalog/product')->canUseCanonicalTag()) {
$params = array('_ignore_category' => true);
$headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params));
}
}
return parent::_prepareLayout();
}
Thanks

it looks like your product is null, you need make sure this function work well
$product = $this->getProduct();

Related

ErrorException : Undefined offset: 0 in laravel 8

This is the line am getting error.
$Notify = $this->value('NOTIFY')[0][0]['value1'];
where value is another function as
public function value($type)
{
$arrs = DB::table('notice')->where('code', $type)
->where('flg', '0')
->get();
$arr=array();
foreach ($arrs as $one) {
$arr[]=array('code'=>$one->code,'value1'=>$one->txt);
}
return array($arr);
}
how I can get value1 ?

Got an error in `php artisan migrate` in Laravel

I always use Laravel project since Laravel 4 up to 7. But this is my first time encountering and error when I migrate my database in freshly download Laravel. This is the error when I migrate:
$e = $event->getThrowable();
if (!$event->hasResponse()) {
$this->finishRequest($request, $type);
throw $e;
}
$response = $event->getResponse();
// the developer asked for a specific status code
if (!$event->isAllowingCustomResponseCode() && !$response->isClientError() && !$response->isServerError() && !$response->isRedirect()) {
// ensure that we actually have an error response
if ($e instanceof HttpExceptionInterface) {
// keep the HTTP status code and headers
$response->setStatusCode($e->getStatusCode());
$response->headers->add($e->getHeaders());
} else {
$response->setStatusCode(500);
}
}
try {
return $this->filterResponse($response, $request, $type);
} catch (\Exception $e) {
return $response;
}
}
/**
* Returns a human-readable string for the specified variable.
*/
private function varToString($var): string
{
if (\is_object($var)) {
return sprintf('an object of type %s', \get_class($var));
}
if (\is_array($var)) {
$a = [];
foreach ($var as $k => $v) {
$a[] = sprintf('%s => ...', $k);
}
return sprintf('an array ([%s])', mb_substr(implode(', ', $a), 0, 255));
}
if (\is_resource($var)) {
return sprintf('a resource (%s)', get_resource_type($var));
}
if (null === $var) {
return 'null';
}
if (false === $var) {
return 'a boolean value (false)';
}
if (true === $var) {
return 'a boolean value (true)';
}
if (\is_string($var)) {
return sprintf('a string ("%s%s")', mb_substr($var, 0, 255), mb_strlen($var) > 255 ? '...' : '');
}
if (is_numeric($var)) {
return sprintf('a number (%s)', (string) $var);
}
return (string) $var;
}
}
Error
Stack trace:
#0 D:\Supporting Enterprises\Projects\Laravel Projects\SuperpagesAPI\artisan(18): require()
#1 {main}
thrown in D:\Supporting Enterprises\Projects\Laravel Projects\SuperpagesAPI\vendor\autoload.php on line 7
Fatal error: Uncaught Error: Class 'ComposerAutoloaderInitbe984857c53a573c5f216d0eb36fe0e7' not found in D:\Supporting Enterprises\Projects\Laravel Projects\SuperpagesAPI\vendor\autoload.php:7
Stack trace:
#0 D:\Supporting Enterprises\Projects\Laravel Projects\SuperpagesAPI\artisan(18): require()
#1 {main}
thrown in D:\Supporting Enterprises\Projects\Laravel Projects\SuperpagesAPI\vendor\autoload.php on line 7
Before this happen I start IIS from the IIS Manager. I don't know if this will effect. I turn it on because I run a C# web application on my end.
It looks like this is composer problem. Just try to run this bash script:
composer dump-autoload

Severity: Notice Message: Trying to get property of non-object

I am receiving an error when attempting to pull several rows of data from my MySQL database and display their content on my web page. Since I am very new to Code Igniter, i am not sure how to fix this error:
Severity: Notice
Message: Trying to get property of non-object
Here is the code associated with the error.
Model:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class news_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
function get_news()
{
$query = $this->db->query("SELECT * FROM news WHERE active = 1");
if ($query->num_rows() > 0)
{
foreach($query->result() AS $row)
{
$array[] = get_object_vars($row);
}
return $array;
}
}
}?>
Controller:
<?php
class profile extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper(array('url','html'));
$this->load->library('session');
$this->load->database();
$this->load->model('user_model');
$this->load->model('news_model');
}
function index()
{
$details = $this->user_model->get_user_by_id($this->session->userdata('uid'));
$data['uname'] = $details[0]->fname . " " . $details[0]->lname;
$data['uemail'] = $details[0]->email;
$data['ustorenumber'] = $details[0]-> storenumber;
$data['urank'] = $details[0]-> rank;
$data['news'] = $this->news_model->get_news();
$this->load->view('profile_view', $data);//Error reported on this line.
}
}
View:
<?php
foreach($news AS $row) {
echo '<p>' . $row->content . '</p>';//Error reported on this line
}
?>
Full Error:
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: views/profile_view.php
Line Number: 82
Backtrace:
File: C:\xampp\htdocs\cig\application\views\profile_view.php
Line: 82
Function: _error_handler
File: C:\xampp\htdocs\cig\application\controllers\profile.php
Line: 22
Function: view
File: C:\xampp\htdocs\cig\index.php
Line: 315
Function: require_once
In model return result in object format.Like this..
function get_news()
{
$query = $this->db->query("SELECT * FROM news WHERE active = 1");
if ($query->num_rows() > 0)
{
return $query->result();//returns result in object format
}
}
OR
IN view: use $row['content'] insetad of $row->content;
<?php
foreach($news AS $row) {
echo '<p>' . $row['content']. '</p>';//Error reported on this line
}
?>

PHP Fatal Error – yii\base\ErrorException

I have uploaded my site to fpt and I can't fix that error. Please help me.
The error is:
PHP Fatal Error – yii\base\ErrorException
Call to undefined function yii\web\json_encode()
Error is on the line $hash = md5(json_encode($this->rules));
The code is:
public function init()
{
parent::init();
if (!$this->enablePrettyUrl || empty($this->rules)) {
return;
}
if (is_string($this->cache)) {
$this->cache = Yii::$app->get($this->cache, false);
}
if ($this->cache instanceof Cache) {
$cacheKey = $this->cacheKey;
$hash = md5(json_encode($this->rules));
if (($data = $this->cache->get($cacheKey)) !== false && isset($data[1]) && $data[1] === $hash) {
$this->rules = $data[0];
} else {
$this->rules = $this->buildRules($this->rules);
$this->cache->set($cacheKey, [$this->rules, $hash]);
}
} else {
$this->rules = $this->buildRules($this->rules);
}
}

Fatal error: Cannot re-assign auto-global variable _POST when I am installing wordpress theme

Fatal error: Cannot re-assign auto-global variable _POST when I am installing wordpress theme
PHP Version 5.4.41
Getting following error : -
Fatal error: Cannot re-assign auto-global variable _POST in /public_html/linuxnlinux.com/wp-content/themes/Answers_v1.2/Answers/library/functions/custom_functions.php on line 1360
Code at line 1360 is : -
}
function get_user_name($uid)
{
global $wpdb;
return $wpdb->get_var("select display_name from $wpdb->users where ID=\"$uid\"");
}
function veryfy_login_and_proced($_POST,$redirecturl = '') // 1360 line
{
$secure_cookie = '';
if ( !empty($_POST['log']) && !force_ssl_admin() ) {
$user_name = sanitize_user($_POST['log']);
if ( $user = get_userdatabylogin($user_name) ) {
if ( get_user_option('use_ssl', $user->ID) ) {
$secure_cookie = true;
force_ssl_admin(true);
}
}
}
Superglobals are not allowed to be used as parameters to a function since PHP 5.4
http://php.net/manual/en/language.variables.superglobals.php#112184
So your function needs to look like this:
function veryfy_login_and_proced() // 1360 line
You can then pass your parameters inside the function.
Hope that helps.