Jump to content
Latest News: (loading..)
jerone

PHP 7.2 each() function deprecated

Recommended Posts

When you are upgrading OsCommerce to be compatible in +PHP7.2 versions, here is a pattern on how to update while = each() loops to foreach, which is said to be like 10 times faster, too!

Case 1: Missing $value

reset($array);
while (list($key, ) = each($array)) {

Update to:

foreach(array_keys($array) as $key) {

Case 2: Missing $key

reset($array);
while (list(, $value) = each($array)) {

Update to:

foreach($array as $value) {

Case 3: Not missing anything

reset($array);
while (list($key, $value) = each($array)) {

Update to:

foreach($array as $key => $value) {

Share this post


Link to post
Share on other sites

Have done a quick search, also found;

function unserialize($broken) {
      for(reset($broken);$kv=each($broken);) {

Pretty sure this function can be entirely removed from the three files it is in.  
Comments anyone ?

and

        while ($tables = tep_db_fetch_array($tables_query)) {
          list(,$table) = each($tables);

TO

        while ($tables = tep_db_fetch_array($tables_query)) {
          $table = reset($tables);

 

Edited by burt

This is a signature that appears on all my posts.  
IF YOU MAKE A POST REQUESTING HELP...please state the exact version
of osCommerce that you are using. THANKS

 
Get the latest current code (community-supported responsive 2.3.4.1BS Edge) here

 

Share this post


Link to post
Share on other sites

I did inform long time ago here:

Thank you @jerone for the infos how to change. I did a different changing, but your changes are much more efective.

What happens in /admin/backup.php with

while (list($kname, $info) = each($index)) {

and

while (list(,$i) = each($table_list)) {

 

@burt i did remove this function. Everything works fine. No problem at all.

function unserialize($broken) {
      for(reset($broken);$kv=each($broken);) {

 


  • The clever one learn from everything and from everybody
  • The normal one learn from his experience
  • The silly one knows everything better

[socrates, 412 before Christ]

Computers help us with the problems we wouldn't have without them!
99.9% of the bugs sit in front of the computer!
My programmed add-ons: WDW EasyTabs 1.0.3, WDW Facebook Like 1.0.0

if(isset($this) || !isset($this)){ // that's the question...

 

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

×