After updating the PHP to 8, I changed the create_function for the anonymous function. And after the last update, I get a new error:
Fatal error: Uncaught Error: Class "'..'" not found in /var/www/vhosts/cbc-legal.com/httpdocs/wp-includes/class-wp-widget-factory.php:62
the 62 line is the last one from that piece:
public function register( $widget ) {
if ( $widget instanceof WP_Widget ) {
$this->widgets[ spl_object_hash( $widget ) ] = $widget;
}
else {
$this->widgets[ $widget ] = new $widget();
The last update was in the following piece of code and "'..'" in error relates to ("'.$widget.'"):
public static function registerWidget($widget){
add_action('widgets_init', function() {
global $widgetName; return register_widget("'.$widgetName.'"); });
I've tried to delete "'..'" and the error was changed to
Class name must be a valid object or a string
Please, help me to figure it out :D
EDIT
Thank you for your comments :D Sorry for the messy question. It's not my code, and I'm just learning :D
Changed code for that:
public static function registerWidget($widget){
add_action('widgets_init', function() {
global $widget; return register_widget($widget);
});
And I get a new error:
Uncaught Error: Class name must be a valid object or a string in /var/www/vhosts/cbc-legal.com/httpdocs/wp-includes/class-wp-widget-factory.php:62
Related
I am calling function form library in codeigniter and it's giving me below error
PHP Fatal error: Cannot access property started with '\0' in /system/core/Exceptions.php on line 85
Code:
$this->load->library('test_library');
TEST_LIBRARY::first();
Class file:
class TEST_LIBRARY
{
public function first(){
return "here";
}
}
However, when I call the function using this method $this->test_library->first(); it's working fine.
It was working both ways before not sure what's going on. There is no other log messages in error.log file. How can I debug further and fix this issue?
Function first is not static but you called as if it is. Change test_libaray.php to :
class TEST_LIBRARY {
public function __construct() {}
public function first() {
return "here"; // i suggest to use __METHOD__ or __LINE__ instead
}
}
And then try:
$test_library = new TEST_LIBRARY();
$test_libaray->first();
instead of:
TEST_LIBRARY::first();
Or you can just change first static.
Its my first try with Magento.
I get this Error Message:
Fatal error: Call to a member function append() on a non-object in /var/customers/webs/magento/magento/app/code/core/Mage/Install/controllers/WizardController.php on line 77
Maybe someone have an Idee or can help me with my Problem?
Now the whole Code from Line 68 - 79:
protected function _prepareLayout()
{
$this->loadLayout('install_wizard');
$step = $this->_getWizard()->getStepByRequest($this->getRequest());
if ($step) {
$step->setActive(true);
}
$leftBlock = $this->getLayout()->createBlock('install/state', 'install.state');
$this->getLayout()->getBlock('left')->append($leftBlock);
return $this;
}
Its the orginal code i haven´t edit anything
$this->getLayout()->getBlock('left')
should return a block class or NULL.
If it returned a block class then :
abstract class Mage_Core_Block_Abstract extends Varien_Object
has function
append($leftBlock);
This means that your $this->getLayout()->getBlock('left')
is not return a block instance.
Why not do a mage log of what $this->getLayout()->getBlock('left')
returns and confirm.
I have a problem with overrided functions of Yii. I am trying to override findByAttributes functions in Yii, but it returns this error:
PHP Fatal error: Class declarations may not be nested in /var/www/html/yii14/framework/collections/CListIterator.php on line 20
My codes of overrided function is like as following:
private function findByAttributes($attributes, $condition='', $params=array())
{
foreach($attributes as $attribute=>$value)
{
if($attribute === 'user_email') {
$attributes[$attribute] = md5('üyegirişyaptı'.$value);
}
}
return parent::findByAttributes($attributes, $condition, $params);
}
What is wrong in here?
I don't think the error is in the piece of code you provided.
Questions:
should findByAttributes be private ?
do you have a stacktrace for us ?
On a sidenote: I don't think you have to loop the array
if(array_key_exists('user_email', $attributes))
{
$attributes['user_email'] = md5('üyegirişyaptı'.$value);
}
I have a problem in Yii framework, I want to call a controller's action in the layout/main.php page which is belong to the siteController, I did this:
$a = UsersController::actionRequestAlert($s);
then I got this error:
Non-static method UsersController::actionRequestAlert() should not be called statically, assuming $this from incompatible context
so how can I solve this problem?
ok,
now I want to create a widget, here is the steps I made:
created folder 'widgets' in folder 'protected'.
created folder 'views' in folder 'widgets'.
added this in config/main.php : 'application.widgets.*'
this is the code of widgets/Alert.php :
class AlertWidget extends CWidget
{
public $alert = null;
private $_data = null;
public function init()
{
$s = Yii::app()->session['userId'];
$r = Requests::model()->findAll('idUser='.$s.' and confirm =0 and unconfirm=0 and cancel=0');
$i=0;
foreach($r as $x)
$i++;
if($i<=0)
$alert=null;
else
$alert="(".$i.")";
$this->_data = new CActiveDataProvider($alert);
}
public function run()
{
$this->render('alert', ['data' => $this->_data]);
}
}
this is the code of widgets/views/alert.php:
echo $data;
this is the code to how I use the widget in a view:
$this->widget('application.widgets.Alert');
finally I got these errors:
( ! ) SCREAM: Error suppression ignored for
( ! ) Fatal error: Cannot redeclare class AlertWidget in C:\wamp\www\mediastore\protected\widgets\Alert.php on line 27
About first question:
You must define method actionRequestAlert() as static
public static actionRequestAlert() {}
I don't know why, but PHP triggers a Fatal Error because a Class Method doesn't exist.
But it clearly exists!
left.phtml:
<?php
$block = Block::getBlock('core/sidebar_modules');
foreach($block->getSidebar('left') AS $key => $value)
{
$_block = explode('_',$value->getName());
if(isset($_block[1]))
{
$_block[1] .= '_widget';
}
$loadBlock = Block::getBlock(implode('/',$_block)); // returns instance of Visio_Blog_Block_Recent_Widget
Debug::var_dump($loadBlock);
/*
returns:
object(Visio_Blog_Block_Recent_Widget)#33 (0) {
}
*/
echo $loadBlock->widgetContent();
/*
returns:
Fatal error: Call to a member function widgetContent() on a non-object in E:\docroot\vhosts\zend.local.host\htdocs\app\design\default\templates\left.phtml on line 13
*/
Debug::print_r(get_class_methods($loadBlock));
/*
returns:
Array
(
[0] => __construct
[1] => widgetContent
)
*/
}
?>
Widget.php (Visio_Blog_Block_Recent_Widget)
Class Visio_Blog_Block_Recent_Widget
{
public function __construct()
{
return $this;
}
public function widgetContent()
{
return 'content';
}
}
I have no clue why this happens?
Is it possible that this is an Error off my View Class while implementing nested view Templates.
I built the framework from scratch.
from the error it looks like that $loadBlock does not contain an instance of Visio_Blog_Block_Recent_Widget or any class, for that matter.
So the problem is around assigning.