1

I have a big web application that worked in PHP 5.3.2 with Zend FrameWork, and was migrated to a new server with PHP 5.4.2. Most of it still works, but there is a small part (let's call it the "import") that gives an error:

Declaration of RptSchdlMdfctnBO::getWorkFlowData() should be compatible with WorkFlowBaseBO::getWorkFlowData($Id), file /www/vrs/vrs/application/models/wrkflows/RptSchdlMdfctnBO.php, line79

What happens is that there is this class RptSchdlMdfctnBO, with an empty method getWorkFlowData($Id), which is redefined in many places with the same arguments. But in the import part, this method is redefined with two arguments, and then it is always called with two arguments; apparently, this is not accepted in PHP 5.4.2. I tried to change the definition of the method to accept a second, optional argument but this did not change anything:

public function getWorkFlowData($Id,$Flags=0)

Two questions: 1) Can you please link me to a place where this behaviour change in PHP is explained? 2) What is the least dangerous workaround for getting the import function to work?

raina77ow
  • 103,633
  • 15
  • 192
  • 229
carlo.borreo
  • 1,344
  • 2
  • 18
  • 35

1 Answers1

1

I'd suggest adding a new method to the class, for example getWorkFlowDataWithFlags($id, $flags) and refactor the functionality from getWorkFlowData into it, and change that getWorkFlowData simply calls getWorkFlowDataWithFlags with the default flag of 0

Jani Hartikainen
  • 42,745
  • 10
  • 68
  • 86
  • Nice answer to 2) No idea about 1) I guess... :-? – Álvaro González Dec 07 '12 at 12:07
  • @ÁlvaroG.Vicario I think the case with the error could be that PHP 5.4 enables E_STRICT error messages by default, wherein your old installation didn't (guessing here). 5.3 has also given warnings for incompatible signatures, could be it was bumped to an actual error as well in 5.4 – Jani Hartikainen Dec 07 '12 at 13:20
  • I actually added the new method, like you recommended, and changed the calls using two parameters to refer to getWorkFlowDataWithFlags. It worked great, thanks. – carlo.borreo Dec 07 '12 at 14:53