Ignore:
Timestamp:
Oct 19, 2013, 7:43:04 PM (11 years ago)
Author:
mistic100
Message:

remove all array_push (50% slower than []) + some changes missing for feature:2978

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/site_update.php

    r23430 r25018  
    200200  if (isset($_POST['cat']))
    201201  {
    202     array_push($fs_fulldirs, $basedir);
     202    $fs_fulldirs[] = $basedir;
    203203  }
    204204  // If $_POST['subcats-included'] != 1 ("Search in sub-albums" is unchecked)
     
    254254      }
    255255
    256       array_push($inserts, $insert);
    257       array_push(
    258         $infos,
    259         array(
     256      $inserts[] = $insert;
     257      $infos[] = array(
    260258          'path' => $fulldir,
    261259          'info' => l10n('added')
     
    278276    else
    279277    {
    280       array_push(
    281         $errors,
    282         array(
    283           'path' => $fulldir,
    284           'type' => 'PWG-UPDATE-1'
    285           )
     278      $errors[] = array(
     279        'path' => $fulldir,
     280        'type' => 'PWG-UPDATE-1'
    286281        );
    287282    }
     
    327322              $granted_grps[$row['cat_id']]=array();
    328323            }
     324            // TODO: explanaition
    329325            array_push(
    330326              $granted_grps,
     
    350346              $granted_users[$row['cat_id']]=array();
    351347            }
     348            // TODO: explanaition
    352349            array_push(
    353350              $granted_users,
     
    373370              foreach ($granted_grps[$parent_id] as $granted_grp)
    374371              {
    375                 array_push(
    376                   $insert_granted_grps,
    377                   array(
    378                     'group_id' => $granted_grp,
    379                     'cat_id' => $ids
    380                   )
    381                 );
     372                $insert_granted_grps[] = array(
     373                  'group_id' => $granted_grp,
     374                  'cat_id' => $ids
     375                  );
    382376              }
    383377            }
     
    386380              foreach ($granted_users[$parent_id] as $granted_user)
    387381              {
    388                 array_push(
    389                   $insert_granted_users,
    390                   array(
    391                     'user_id' => $granted_user,
    392                     'cat_id' => $ids
    393                   )
    394                 );
     382                $insert_granted_users[] = array(
     383                  'user_id' => $granted_user,
     384                  'cat_id' => $ids
     385                  );
    395386              }
    396387            }
    397388            foreach (get_admins() as $granted_user)
    398389            {
    399               array_push(
    400                 $insert_granted_users,
    401                 array(
    402                   'user_id' => $granted_user,
    403                   'cat_id' => $ids
    404                 )
    405               );
     390              $insert_granted_users[] = array(
     391                'user_id' => $granted_user,
     392                'cat_id' => $ids
     393                );
    406394            }
    407395          }
     
    421409
    422410  // to delete categories
    423   $to_delete = array(); $to_delete_derivative_dirs = array();
     411  $to_delete = array();
     412  $to_delete_derivative_dirs = array();
     413 
    424414  foreach (array_diff(array_keys($db_fulldirs), $fs_fulldirs) as $fulldir)
    425415  {
    426     array_push($to_delete, $db_fulldirs[$fulldir]);
     416    $to_delete[] = $db_fulldirs[$fulldir];
    427417    unset($db_fulldirs[$fulldir]);
    428     array_push($infos, array('path' => $fulldir,
    429                              'info' => l10n('deleted')));
     418   
     419    $infos[] = array(
     420      'path' => $fulldir,
     421      'info' => l10n('deleted')
     422      );
     423     
    430424    if (substr_compare($fulldir, '../', 0, 3)==0)
    431425    {
     
    434428    $to_delete_derivative_dirs[] = PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR.$fulldir;
    435429  }
     430 
    436431  if (count($to_delete) > 0)
    437432  {
     
    506501    if (!preg_match($conf['sync_chars_regex'], $filename))
    507502    {
    508       array_push(
    509         $errors,
    510         array(
    511           'path' => $path,
    512           'type' => 'PWG-UPDATE-1'
    513           )
     503      $errors[] = array(
     504        'path' => $path,
     505        'type' => 'PWG-UPDATE-1'
    514506        );
    515507
     
    533525    }
    534526
    535     array_push(
    536       $inserts,
    537       $insert
     527    $inserts[] = $insert;
     528
     529    $insert_links[] = array(
     530      'image_id'    => $insert['id'],
     531      'category_id' => $insert['storage_category_id'],
    538532      );
    539533
    540     array_push(
    541       $insert_links,
    542       array(
    543         'image_id'    => $insert['id'],
    544         'category_id' => $insert['storage_category_id'],
    545         )
    546       );
    547 
    548     array_push(
    549       $infos,
    550       array(
    551         'path' => $insert['path'],
    552         'info' => l10n('added')
    553         )
     534    $infos[] = array(
     535      'path' => $insert['path'],
     536      'info' => l10n('added')
    554537      );
    555538
     
    588571  foreach (array_diff($db_elements, array_keys($fs)) as $path)
    589572  {
    590     array_push($to_delete_elements, array_search($path, $db_elements));
    591     array_push($infos, array('path' => $path,
    592                              'info' => l10n('deleted')));
     573    $to_delete_elements[] = array_search($path, $db_elements);
     574    $infos[] = array(
     575      'path' => $path,
     576      'info' => l10n('deleted')
     577      );
    593578  }
    594579  if (count($to_delete_elements) > 0)
     
    659644
    660645      $data['id']=$id;
    661       array_push($datas, $data);
     646      $datas[] = $data;
    662647    } // end foreach file
    663648
     
    740725      $data['date_metadata_update'] = CURRENT_DATE;
    741726      $data['id']=$id;
    742       array_push($datas, $data);
     727      $datas[] = $data;
    743728
    744729      foreach (array('keywords', 'tags') as $key)
     
    753738          foreach (explode(',', $data[$key]) as $tag_name)
    754739          {
    755             array_push(
    756               $tags_of[$id],
    757               tag_id_from_tag_name($tag_name)
    758               );
     740            $tags_of[$id][] = tag_id_from_tag_name($tag_name);
    759741          }
    760742        }
     
    763745    else
    764746    {
    765       array_push($errors, array('path' => $element_infos['path'], 'type' => 'PWG-ERROR-NO-FS'));
     747      $errors[] = array(
     748        'path' => $element_infos['path'],
     749        'type' => 'PWG-ERROR-NO-FS'
     750        );
    766751    }
    767752  }
Note: See TracChangeset for help on using the changeset viewer.