Fatal error: Can not redeclare WP_Post_Type show_in_rest - php

I have a problem with a client's Wordpress, I can't fix it.
Fatal error: Can not redeclare WP_Post_Type :: $ show_in_rest in
/home/thesearchhouseco/public_html/buzios/wp-includes/class-wp-post-type.php
on line 348
I have already erased the lines as mentioned, however, it
still presents an error on another page.
You can see the error at: https://thesearchhouse.com.br/buzios/
File: class-wp-post-type.php
public $show_in_rest;
/** * The base path for this post type's REST API endpoints. *
* #since 4.7.4 * #access public * #var string|bool $rest_base */

It looks like there is a class WP_Post_Type with a variable $show_in_rest. If the class were being accessed by creating a new instance of the class, the variable would likely be editable. From the error, it looks like the variable is being accessed statically (note the ::), which means it's read-only.

Ok guys,
I solved the problem by updating manually the wordpress on my server.
I just downloaded the wordpress, and sent to the server.

Related

Warning: Class __PHP_Incomplete_Class has no unserializer

I fully converted my project from Symfony 3.3 to 6.1, it was an insane jump and I had to go through nearly the entire codebase. However, with all the great new additions to Symfony 6.1 (compared to 3.3) I'm happy that I spend the time doing it.
However, when I'm running it on my webserver, I get a warning; Warning: Class __PHP_Incomplete_Class has no unserializer. This does cause an Exception.
This warning is thrown when I try to 'unserialize' a property of an entity class. The database field is just a serialized stdClass basically. However, when I try unserializing it I get the error. The code is simply;
/**
* #return Cart
*/
public function getCart()
{
return unserialize($this->cart);
}
I have the feeling that when calling $this->cart after retrieving the entity from the database that its type is an incomplete class. However, I still need to unserialize it in order to use it. But the incomplete class type has no unserializer (also no serializer I assume). Do I need to 'cast' it in a way for it to work? (I tried some thing, but $this->cart is a string and $this->getCart() returns a Cart object).
EDIT:
I have found the resaon for the incorrect unserialization. My default namespace changed from AppBundle to App\Controller\AppBundle. However, my database contains the 'old' namespaces. What would be the best way to fix this?

Doxygen not recognize PHP Class in static array storage

In my PHP project im using a Class factory that stores the object instances inside an object member of a static class. This member is an array and if for example i gonne instance lib/log.php (class log {....) it will be accessed like
glob::$data["lib/log"]
Since im using this structure all over my project i want doxygen to recognize the calls for the call/caller graphs and for linking the functions. In my code i currently do like
glob::$data["lib/log"]->info("info to log.......");
Wich i realized wont be recognized by doxygen so i tried modify the code to structure like:
$libLog = glob::$data["lib/log"];
$libLog->info("info to log......");
And adding source comments to tell the code wich instances of classes im using here. I tried in both ways like
/* #var $libLog log */
same as
/* #var log $libLog */
since i found examples refering to both of that. None of them worked. The log class itself gets recognized and is inside the Class list so it can't be an recognation error.
If anyone has idea how i can make doxygen recognize those calls or a hint to another stack posting that solves this problem i would be really gratefull!

TYPO3 extension generate view error

I'm building my first TYPO3 extension, exactly I'm just trying to build the example that is on the TYPO3 page, see link. Looks like something in the controller goes wrong. I'm using the following code
class Tx_Mtclnt_Controller_AdsController
extends Tx_Extbase_MVC_Controller_ActionController {
public function listAction() {
$adsRepository = t3lib_div::makeInstance('Tx_Mtclnt_Domain_Repository_AdsRepository');
$ads = $adsRepository->findAll();
$this->view->assign('ads', $ads);
}
}
I'm getting the following error:
1: PHP Catchable Fatal Error: Argument 1 passed to TYPO3\CMS\Extbase\Persistence\Repository::__construct() must implement interface TYPO3\CMS\Extbase\Object\ObjectManagerInterface, none given, called in /home/mtclnt02/typo3_src-6.2.9/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 4431 and defined in /home/mtclnt02/typo3_src-6.2.9/typo3/sysext/extbase/Classes/Persistence/Repository.php line 75 (More information)
TYPO3\CMS\Core\Error\Exception thrown in file
/home/mtclnt02/typo3_src-6.2.9/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 101.
The error you get results from the repository, which you try to create. The class TYPO3\CMS\Extbase\Persistence\Repository has a constructor, which requires \TYPO3\CMS\Extbase\Object\ObjectManagerInterface as argument. Since you don't pass an objectManager class in your t3lib_div::makeInstance, the error is thrown. You can avoid this, by using dependeny injection like shown below.
/**
* #var Tx_Mtclnt_Domain_Repository_AdsRepository
* #inject
*/
protected $adsRepository;
public function listAction() {
$adsRepository = $this->adsRepository->findAll();
}
But I also see a general problem here, because the Extbase / Fluid book you refer to is outdated on some topics. From my point of view, the refered book is a quite useful resource if you want to understand the concept and architecture of an Extbase/Fluid extension, but not for code examples any more, since a lot of things have changed in TYPO3 since the book has been written.
If you want to start with TYPO3 extension development for TYPO3 6.2 or higher, I would suggest you install the extension extension builder and use it to create your first extension. The manual contains a short but helpful users manual, which guides you through the basics of creating a simple TYPO3 extension.
After you created your first extension with extension builder, you can go some steps further by adding functionality to the code created by extension builer.

Zend Framework 2 - Annotation forms and Doctrine2 - Catchable fatal error - ObjectManager

I'm using Zend, Doctrine2.1 and AnnotationForms.
My entity looks like this:
/**
* #ORM\Entity
* #ORM\Table(name="myentity")
* #Form\Name("myentity")
* #Form\Attributes({ "class": "form-horizontal" })
* #Form\Hydrator("\DoctrineModule\Stdlib\Hydrator\DoctrineObject")
*/
class MyEntity {
...
}
When using this DoctrineObject I get the following error:
Catchable fatal error: Argument 1 passed to DoctrineModule\Stdlib\Hydrator\DoctrineObject::__construct() must be an instance of Doctrine\Common\Persistence\ObjectManager, none given, called in C:\vendor\zendframework\zendframework\library\Zend\Form\Factory.php on line 566 and defined in C:\vendor\doctrine\doctrine-module\src\DoctrineModule\Stdlib\Hydrator\DoctrineObject.php on line 63
I cannot use Zend\Stdlib\Hydrator\ObjectProperty because then I get
Fatal error: Cannot access protected property
I'm quite lost. Anybody an idea what I can do to fix this issue?
I'm guessing that I need a __construct() function. But what do I put in there?
Someone may come up with a Annotation-only function, if that exists, meanwhile you can go this approach:
$form = //create the annotation form WITHOUT a hydrator
$objectManager = $serviceLocator->get('Doctrine\ORM\EntityManager');
$hydrator = new \DoctrineModule\Stdlib\Hydrator\DoctrineObject($objectManager);
$form->setHydrator($hydrator);
//continue in your controller
Had also problems with the annotation forms. My solution was a mindbreaker. Took me long time to find out.
My problem was in the first line of the annotation code.
/**
This line is normally used for commenting your annotation code, but allmost everybody leaves it empty. Normally no issues, but this is somehow causing problems in the form annotations. You should either add some comment, add a space, or move your first line of code up. So:
/** Some comment to make this annotation work
/** (<-- a space)
or start like this:
/** #ORM\Entity
Don't ask me why this is happening (some parsing error?). I found this on a post on GitHub where someone reported having similar issue (https://github.com/doctrine/common/issues/331). As I understood the bug is not a doctrine but a ZF2 issue and it has been reported.
Not sure this is your issue as well, but posting this was the least i could do...
Please have a look at this solution, it's preatty good

Fatal error: Cannot access protected property EE_Output::$parse_exec_vars in EE2

What does this error mean in 'expression engine 2'? I get it when I try to access
http://localhost/alias/blog/admin.php.
Fatal error: Cannot access protected property EE_Output::$parse_exec_vars in C:\web\blog\system\expressionengine\libraries\Core.php on line 423
If I comment out the line 423 it loads the control panel but none of the menu seems to work.
You are using class EE_Output and try to use the value of parse_exec_vars.
But, because this is a protected proterty, it can only be accessed in the EE_Output class itself and derived classes.
You have not show any code, so I cannot go into detail, but this should get you going.

Categories