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

I created a ZF application using 1.10 to deploy to an RHEL server in an enterprise client with PHP 5.1.6. He will not work.

I am googled and now understand that this is a version of PHP. I did not understand that ZF has a minimum requirement for PHP 5.2.4, and calls to HeadLink seem to cause the fatal error "Calling the 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 will not update its PHP; I do not want to rewrite the application without ZF, and I would prefer not to downgrade ZF to an earlier version.

Is there any patch I can use to add ksort () in ZF 1.10 to get around this? There may be other problems, but now I'm stuck.

Any advice is welcome

Many thanks

Yang

EDIT: As I said in the comment below, I expect that many people will achieve this earlier and will continue to do so, as RHEL5 will become the standard in the corporate environment for a good time. I was hoping that the link to the existing solution would rather have to be developed from scratch.

UPDATE: I used the patch related to the accepted answer and it fixed the problem for me.

This is the addition of the following public method in Zend / View / Helper / Placeholder / Container / Abstract.php

  /** * Sort the array by key * * @return array */ public function ksort() { $items = $this->getArrayCopy(); return ksort($items); } 

One problem remains; PHP notification caused by string conversion in Zend_View_Helper_Doctype. Comparing this function with similar ones above and below, it seems to be a bug 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); } 

Correcting the library itself was the last thing I usually did, but in this case it saved me from the place. We will make the patch a version in the repo and documented for future developers.

+4
source share
2 answers

I had the same problem today. I found a solution in this post.

Add the following snippet to /Zend/View/Helper/Placeholder/Container/Abstract.php:

 /** * Sort the array by key * * @return array */ public function ksort() { $items = $this->getArrayCopy(); return ksort($items); } 
+6
source

I assume that you can change the inheritance of Zend_View_Helper_Placeholder_Container or Zend_View_Helper_Placeholder_Container_Abstract to provide your own implementation of ArrayObject::ksort . Sort of:

 class CompatibilityArrayObject extends ArrayObject { public function ksort () { // here be dragons } } abstract class Zend_View_Helper_Placeholder_Container_Abstract extends CompatibilityArrayObject { ... } 

You do not know how many more problems there are. If the request specifies PHP 5.2.4, this is what you should run.

+2
source

All Articles