keitex
keitex

Reputation: 15

PHP Code upgrade from 5.2 to 5.4

I have an old website that was written in PHP 5.2 but after upgrading PHP version, this has stopped working now.

This is the error I get:

PHP Fatal error:  Call-time pass-by-reference has been removed in /var/www/vhosts/crm/httpdocs/libs/formval.class.php on line 212, referer: http://crm/admin/index.php

Code from formval.class.php

            // Are there any functions to run?
        if ($functions != '') {

            // Put the functions into an array.
            $functionArray = explode(',', $functions);

            // Loop through and run the functions.
            for ($i = 0; $i < sizeof($functionArray); $i++) {

                $functionName = $functionArray[$i];

                switch ($functionName) {

                    case 'isNumber':
                        $callFunction = $this->isNumber($data, &$errorMsg);
                        break;

                    case 'isNumberND':
                        $callFunction = $this->isNumberND($data, &$errorMsg);
                        break;

                    case 'isNotZero':
                        $callFunction = $this->isNotZero($data, &$errorMsg);
                        break;

                    case 'isValidEmail':
                        $callFunction = $this->isValidEmail($data, &$errorMsg);
                        break;

                    case 'isValidDate':
                        $callFunction = $this->isValidDate($data, &$errorMsg);
                        break;

                    case 'isValidPassword':
                        $callFunction = $this->isValidPassword($data, &$errorMsg);
                        break;

                    default:
                        $callFunction = TRUE;

                }

This is line 212:

$callFunction = $this->isNumber($data, &$errorMsg);

Because this runs on Plesk 11.5, it does not let me install 5.2 with apache module, only CGI or FastCGI but neither make this site run. Any ideas?

Upvotes: 0

Views: 1084

Answers (1)

Kei
Kei

Reputation: 771

The problem is you can't call by reference, use

$callFunction = $this->isNumber($data, $errorMsg);

instead of

$callFunction = $this->isNumber($data, &$errorMsg);

Also you'll have to change the isNumber function declaration from

public function isNumber($data, $errorMsg)

to

public function isNumber($data, &$errorMsg)

Upvotes: 3

Related Questions