Jump to content
Jack_mcs

Database Optimizer

Recommended Posts

@ce7For the first one, at the location shown,  change

            case TEXT_DO_OPTIMIZE:       $config['optimize']      = DATABASE_OPTIMIZER_OPTIMIZE;      $optionSelected = true; break;

to

            case TEXT_DO_OPTIMIZE:       $config['optimize']      = DATABASE_OPTIMIZER_PERIOD;      $optionSelected = true; break;

For the second one, change

    $mainDate = tep_db_fetch_array($query, MYSQL_ASSOC);

to

    $mainDate = tep_db_fetch_array($query);

For the third one, change

case 'Opt C': continue; //skip customers with orders

to

case 'Opt C': continue 2; //skip customers with orders

 

Share this post


Link to post
Share on other sites

A new version has been uploaded with these changes:

  • Changed call to defined location in database_optimizer.php. Found by @raiwa.
  • Fixed some compatibility issues with php 7.3.
  • Added a version for Phoenix.
  • Removed the calls to load the filename and database files in the After 2.3 version.
  • Replaced mysql_error with mysqli_error for php 7 compatibility. Found by @Demitry.
  • Updated the included Version Checker file that works with the new apps section.

 

 

Share this post


Link to post
Share on other sites

@Jack_mcs

hi Jack,

I updated all the files for the new 1.8 version of this addon and ran it for the first time last night.

One of the errors I got was for the tep_draw_bootstrap_button() function for that Update button.

I have BS Edge and since there is nothing in the package for any osC versions older than Flatline (Frozen), I had to apply the changes for that version to BS Edge.

However, in doing so, I noticed that Flatline does not have the tep_draw_bootstrap_button() function defined either. I got this function from Zombified Phoenix and the Update button now displays & works as it should.

The other issue was a PHP warning I got regarding a non-numeric value related to the following file and line. The database optimization summary is also listed below.

database-optimizer-warning.thumb.png.3aa38ba5fbb332a64c6c5c6c61604da1.png

database-optimizer-details.png.9476dda9021aec4d972aa7eedfc9ca2a.png

 

I looked up that line and here it is.

$dateOrder = date("Y-m-d", time() - ($config['orphan_orders'] * 86400));

So, three issues:

1)  There is no package solution for any osC versions older than Flatline (Frozen)

2)  The tep_draw_bootstrap_button() function does not exist in Flatline for the Update button, which is in the admin/database_optimizer.php file

3)  The calculation for $dateOrder variable in admin/includes/modules/database_optimizer_common.php on line 165 is producing a PHP warning of a non-numeric value

 

I should also mention that I have not made any adjustments to the default setting in the configuration part of this addon.


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

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

Share this post


Link to post
Share on other sites
Posted (edited)
5 hours ago, Demitry said:

1)  There is no package solution for any osC versions older than Flatline (Frozen)

2)  The tep_draw_bootstrap_button() function does not exist in Flatline for the Update button, which is in the admin/database_optimizer.php file

 

3)  The calculation for $dateOrder variable in admin/includes/modules/database_optimizer_common.php on line 165 is producing a PHP warning of a non-numeric value

1) There is a version for "Before 2.3". I don't recall I updated it for this version. Probably not. With Phoenix becoming more and more popular and with it changing often, managing multiple versions is just not possible any longer, at least for me. If you need an addon to work for older versions, you can 

  • Use an older version. This is not a good idea since you will lose fixes and improvements.
  • Convert the code to work with an older version.
  • Pay someone to do the conversion.

2) This got through because of lack of time for testing older versions. To fix it, you can replace 

                 <td align="center">
                 <?php echo tep_draw_bootstrap_button(IMAGE_UPDATE, 'fas fa-save', null, 'primary', null, 'btn-success btn-block btn-lg'); ?>
                 </td>

with

                 <td align="center"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE);?></td>

3) I'm not able to reproduce this but in searching for it, it seems to be a bug in php 7.1 and, maybe 7.2. I'm running 7.3 so it seems they fixed that problem. Applying the change below should prevent it but since I can't see the warning, I can't be sure. Change this line

$dateOrder = date("Y-m-d", time() - ($config['orphan_orders'] * 86400));

to

$dateOrder = date("Y-m-d", time() - (int)($config['orphan_orders'] * 86400));

 

Edited by Jack_mcs

Share this post


Link to post
Share on other sites
Quote

1) There is a version for "Before 2.3"

This is not in that package for version 1.8 ...and I have BS Edge as I originally stated, which is after version 2.3.4. The oldest version in that package is Flatline.

For number two, I had made the fix as I stated, in my post above. I was just letting you know about this as a potential issue for others updating to this latest version because without that PHP function defined, you get a PHP Fatal Error.

As for number three, thank you for the fix. I have not applied it yet, but will, and I'll test it afterwards. I am on PHP7.2 at this time, so this might be the cause of this PHP warning.

Thank you for your reply.


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
9 minutes ago, Demitry said:

This is not in that package for version 1.8 ...and I have BS Edge as I originally stated, which is after version 2.3.4. The oldest version in that package is Flatline.

The package I have here, which is what I uploaded, has these directories in it:

Before_2.3
Frozen
Phoenix

That covers all versions of oscommerce though, as mentioned, they may not all be current.

Share this post


Link to post
Share on other sites
Posted (edited)
Quote

Before_2.3

Sorry Jack,.. my mistake on that point. I had to look at the package again to see this. I skipped over that folder because I have BS Edge, which is after version 2.3

UPDATE: I ran a test database optimization after making that change you mentioned and there was no PHP warning. So, it works! Thanks.

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
Posted (edited)

Just an addition/addendum to my previous comment.

Although there is a folder in the package for osC versions Before_2.3, ..there is a large gap from version 2.2 to the Flatline version, including osC versions 2.3, 2.4, BS Edge, Gold, and everything in between.

This is no longer an issue for me, but it could be for anyone else who has an osC version that is part of that gap.

 

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
10 hours ago, Demitry said:

This is no longer an issue for me, but it could be for anyone else who has an osC version that is part of that gap.

That is the situation with all addons. Most of the new ones for Phoenix don't even have a Frozen version, much less pre-Frozen versions. I've always tried to include versions for all shops in my addons but that is going away. Even now, I don't have the time to test Frozen versions and may stop supporting all pre-Phoenix versions. I offer paid support for them but trying to code for all shops in the free versions just takes too much time.

Share this post


Link to post
Share on other sites
Posted (edited)
Quote

... but trying to code for all shops in the free versions just takes too much time.

I totally understand! I have a bunch of addons that I don't care to dedicate time to for a completely dead software. Cheers for doing this update! I appreciate it.

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

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

×