Jump to content
Teaman55

PHP 8.0 Upgrade to boxes.php class

Recommended Posts

PHP 8.0 requires that any classes that use the class name as a function name for the constructor function be changed to use  __construct() instead. This is an issue for the class boxes.php where the constructors may also be called directly from other classes. Has anyone worked out a solution for this class?

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Thanks for the response.

7.x announced that using matching function names as constructors would be removed as of 8.0.  They still work in 7.x versions as is.

 class tableBox {
    var $table_border = '2px solid #ccc;';
    var $table_width = '100%';
    var $table_cellspacing = '0';
    var $table_cellpadding = '0';
    var $table_parameters = '';
    var $table_row_parameters = 'style="vertical-align: middle;"';
    var $table_data_parameters = '';
    var $table_top_space = ''; // added AF 22APR05

// class constructor
    function tableBox($contents, $direct_output = false) {
      $tableBox_string = '<table style="border: ' . tep_output_string($this->table_border) . ' width: ' . tep_output_string($this->table_width) . '; border-spacing: ' . tep_output_string($this->table_cellspacing) . '; padding: ' . tep_output_string($this->table_cellpadding) . ';"';
      if (tep_not_null($this->table_parameters)) $tableBox_string .= ' ' . $this->table_parameters;
      $tableBox_string .= '>' . "\n";  etc.

Every extension of tableBox in boxes.php calls $this->tableBox().  So if it is really the constructor also, as marked in the code above, seems like every version  2.x.x, and probably some later versions, are headed for a breakdown when PHP is upgraded to 8.0.

I haven't figured out why boxes.php is built like this, unless it is just to create all the extensions on startup.. In every other class, the matching function name could be changed to __construct without a problem.  Can't believe I'm the first person to notice this problem.

Share this post


Link to post
Share on other sites

I ran into this issue today while updating to PHP 8. Did you ever find a solution?


The water in a vessel is sparkling; the water in the sea is dark. The small truth has words which are clear; the great truth has great silence.

- Rabindranath Tagore

Share this post


Link to post
Share on other sites
  class tableBox {
    var $table_border = '0';
    var $table_width = '100%';
    var $table_cellspacing = '0';
    var $table_cellpadding = '2';
    var $table_parameters = '';
    var $table_row_parameters = '';
    var $table_data_parameters = '';

// class constructor
    function __construct($contents, $direct_output = false) {

 

Share this post


Link to post
Share on other sites

My osC version does not have this boxes.php class file. However, I believe you have to make that function __construct change to each of the class XXXXX extends tableBox, function XXXXX in that file.

 

 

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&amp;geo=US&amp;q=oscommerce

Share this post


Link to post
Share on other sites
13 hours ago, ruden said:

I have been using your vanilla code as a guide to update my shop to PHP 8. It has been very helpful but I see you have removed the boxes. I would like to keep them. Might you have a includes/classes/boxes.php file that is PHP 8 compatible so I can compare with my file?


The water in a vessel is sparkling; the water in the sea is dark. The small truth has words which are clear; the great truth has great silence.

- Rabindranath Tagore

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×