Dompdf library Incompatibility with PHP version 8.1.2 on CodeIgniter 3.1.13 - php

I tried to convert my CodeIgniter 3 file to pdf with this Dompdf library: https://github.com/iamfiscus/Codeigniter-DOMPDF
Got few errors but already fixed it from this github source: https://github.com/dompdf/dompdf/tree/981c1b977fbc78eeb5bc6f1e4cc3ae217b6a65d2/src/Frame
Yet there's still one error message that says like this:
A PHP Error was encountered
Severity: Compile Error
Message: Could not check compatibility between FrameList::getIterator(): FrameListIterator and IteratorAggregate::getIterator(): Traversable, because class FrameListIterator is not available
Filename: include/frame.cls.php
Line Number: 850
Backtrace:
Here's my source code in frame.cls.php within Dompdf library (line 833-854):
class FrameList implements IteratorAggregate {
/**
* #var Frame
*/
protected $_frame;
/**
* #param Frame $frame
*/
function __construct($frame)
{
$this->_frame = $frame;
}
/**
* #return FrameListIterator
*/
// code below is line 850:
function getIterator(): FrameListIterator
{
return new FrameListIterator($this->_frame);
}
}
Is there any way I can fix this without updating/changing the dompdf version? cause I'm a beginner coder, yet it's hard for me to resolve a library problem.
N.B: I'm manually put the library in my codeigniter, not using composer.
I already tried to find solution from many websites and video tutorials, but it's not working for me. So, I'm really hoping that anyone can get me a solution for the frame.cls.php file.

Related

Fatal error: Can not redeclare WP_Post_Type show_in_rest

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.

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.

Vim for PHP development: PHP document, manual, completion for builtin function

I have configured my vim to work with PHP, but there's some problems I could not resolve after searching on Google:
First, about PHP Documentor, I have found php-doc vim plugins, but I could not use it in my code, it just shows me a doc block without anything.
Example:
public function set($key, $value)
{
}
when I tried to run php-doc (through my configured hotkey: c-p)
/**
*
**/
public function set($key, $value)
{
}
I expected some thing like this:
/**
*
*
* #param unknown Some thing about parameter
* #param unknown Some thing about parameter
* #return void
**/
public function set($key, $value)
{
}
Second, I generated some tags (using ctags) for developing Zend Framework with vim, but after that I don't have any completion for php builtin function (use omni with phpcomplete vim plugins,: http://www.vim.org/scripts/script.php?script_id=3171 I have changed my syntax to 5.3 used PHP syntax (php.vim: http://www.vim.org/scripts/script.php?script_id=2874)
Third, I want my vim php have suggestion for a buitin function or a function with document, when I type a function, it could have a suggestion for the which parameter needs to supplied, what do the functions act? Like this in python: http://blog.dispatched.ch/wp-content/uploads/2009/05/omnicompletion.png
How could I configured vim to fulfill these needs, anyone could help me?
(1) I have not looked at the vim-doc plugins, but for proof of concept, see the ClassHeader function and autocommands in foo.vim: http://www.vim.org/scripts/script.php?script_id=72
(2, 3) I get completion for built-in functions and for anything found in a tags file using the syntax and ftplugin files that come with the standard distribution. Even though I am still using vim 7.3, my syntax file is more recent than the one you mention. If there is more than one match, then the function signature is shown in a preview window; do you want more than that for a suggestion? See, for example, the screenshot at https://drupal.org/project/vimrc .

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

Running Zend Framework on PHP 5.1.6 - patch or fix for ksort()?

I've built a ZF app using 1.10 for deployment on RHEL server in a corporate client, which has PHP 5.1.6. It won't run.
I googled and now realise it's the version of PHP. I didn't realise ZF had a minimum requirement for PHP 5.2.4, and calls to HeadLink seem to be causing fatal error "Call to undefined method Zend_View_Helper_Placeholder_Container::ksort()":
PHP Fatal error: Call to undefined method Zend_View_Helper_Placeholder_Container::ksort() in /library/ Zend/View/Helper/HeadLink.php on line 321
The client won't upgrade their PHP; I don't want to rewrite the app without ZF, and I'd rather not downgrade ZF to a grossly earlier version.
Is there some patch I can use to add ksort() to ZF 1.10 to get around this? There may be other problems, but this is where I'm stuck right now.
Any advice welcome
Many thanks
Ian
EDIT: As I say in a comment below, I expect many people have hit this before and will keep on doing so as RHEL5 will be a standard in corporate environments for a good time to come. I was hoping for a link to an existing solution rather having to devise one from scratch.
UPDATE: I used the patch linked to in the accepted answer and it fixed the problem for me.
This is adding the following public method to Zend/View/Helper/Placeholder/Container/Abstract.php
/**
* Sort the array by key
*
* #return array
*/
public function ksort()
{
$items = $this->getArrayCopy();
return ksort($items);
}
There was one remaining issue; a PHP notice caused by a string conversion in Zend_View_Helper_Doctype. Comparing this function to similar ones above and below, this seems to be an error in the library
public function isHtml5() {
return (stristr($this->doctype(), '<!DOCTYPE html>') ? true : false);
}
Changed to:
public function isHtml5() {
return (stristr($this->getDoctype(), '<!DOCTYPE html>') ? true : false);
}
Patching the library itself was the last thing I would normally do, but in this case it got me out of a spot. We'll make sure the patch is versioned in the repo and documented obviously for future developers.
I had the same issue today.
I found solution in this blog post.
Add the following snippet in /Zend/View/Helper/Placeholder/Container/Abstract.php:
/**
* Sort the array by key
*
* #return array
*/
public function ksort()
{
$items = $this->getArrayCopy();
return ksort($items);
}
I suppose you could change the inheritance of Zend_View_Helper_Placeholder_Container or Zend_View_Helper_Placeholder_Container_Abstract to supply your own implementation of ArrayObject::ksort. Something like:
class CompatibilityArrayObject extends ArrayObject {
public function ksort () {
// here be dragons
}
}
abstract class Zend_View_Helper_Placeholder_Container_Abstract
extends CompatibilityArrayObject {
...
}
You don't know how many more problems there are though. If the requirement says PHP 5.2.4, that's what you should run it on.

Categories