Getting an error

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
musicweb
New php-forum User
New php-forum User
Posts: 2
Joined: Mon May 24, 2021 2:18 pm

Mon May 24, 2021 2:25 pm

I'm getting an error when executing my payment processor.

Code: Select all

PHP Fatal error:  Uncaught Error: Call to undefined method EPH_disc_bulk_cash::_abort()
This is the code in my php file:

Code: Select all

      if(!ShopDB::query($sql)){
         return self::_abort("Couldn't execute user query");
	  }
Error log says _abort is undefined method.
_abort function does not exist anywhere in my code.
It was working a while back with php5, but now we have php7.

Should we change all these _abort references to "return" or "die" or ?
simonbrahan
php-forum Fan User
php-forum Fan User
Posts: 137
Joined: Mon Jun 08, 2020 2:00 am
Contact:

Mon May 24, 2021 11:25 pm

You could just implement and "_abort" function; you just need to understand what its purpose was. If it was supposed to log an error then end the script that's pretty easy to do.
musicweb
New php-forum User
New php-forum User
Posts: 2
Joined: Mon May 24, 2021 2:18 pm

Thu May 27, 2021 2:49 am

Come to find out that it was missing default values in our Mysql database.
After fixing, the errors went away...
Another thing...
We ran php7mar and in the report it shows the following as "critical" , "variableInterpolation"

Code: Select all

      $tmp = ShopDB::query("select config_field, config_value from configuration");
      while ($row = ShopDB::fetch_row($tmp)) {
        //  echo $row[1][1];
        if (($row[1][1]==':') or ($row[1][1]==';')) {
          $row[1] = unserialize($row[1]);
        }

        if (!is_null( $row[1])) {
          $this->$row[0] =  $row[1];
          $data[$row[0]]  =  $row[1];
        }
      }
The line with $this->$row[0] = $row[1]; shows in the report.
Our site loads and works fine. Is this something to worry about?
simonbrahan
php-forum Fan User
php-forum Fan User
Posts: 137
Joined: Mon Jun 08, 2020 2:00 am
Contact:

Thu May 27, 2021 4:46 am

PHP 7 is stricter in how it parses code using variable variable names. As mentioned, this is a critical problem that will break your code in PHP 7.

Code: Select all

// code:
$this->$row[0]

// old meaning:
$this->{$row[0]}

// new meaning:
($this->$row)[0]
Add curly brackets to change your line to:

Code: Select all

$this->{$row[0]} = $row[1]
and you'll be away.
Post Reply