Skip to content

Commit

Permalink
remove all array_push (50% slower than []) + some changes missing for…
Browse files Browse the repository at this point in the history
… feature:2978

git-svn-id: http://piwigo.org/svn/trunk@25018 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
mistic100 committed Oct 19, 2013
1 parent 35ff1b7 commit ae70727
Show file tree
Hide file tree
Showing 89 changed files with 700 additions and 1,084 deletions.
8 changes: 1 addition & 7 deletions admin/album_notification.php
Expand Up @@ -113,13 +113,7 @@
;';
list($group_name) = pwg_db_fetch_row(pwg_query($query));

array_push(
$page['infos'],
l10n(
'An information email was sent to group "%s"',
$group_name
)
);
$page['infos'][] = l10n('An information email was sent to group "%s"', $group_name);
}

// +-----------------------------------------------------------------------+
Expand Down
56 changes: 14 additions & 42 deletions admin/batch_manager.php
Expand Up @@ -177,10 +177,7 @@
FROM '.CADDIE_TABLE.'
WHERE user_id = '.$user['id'].'
;';
array_push(
$filter_sets,
array_from_query($query, 'element_id')
);
$filter_sets[] = array_from_query($query, 'element_id');

break;

Expand All @@ -190,10 +187,7 @@
FROM '.FAVORITES_TABLE.'
WHERE user_id = '.$user['id'].'
;';
array_push(
$filter_sets,
array_from_query($query, 'image_id')
);
$filter_sets[] = array_from_query($query, 'image_id');

break;

Expand All @@ -210,10 +204,7 @@
FROM '.IMAGES_TABLE.'
WHERE date_available BETWEEN '.pwg_db_get_recent_period_expression(1, $row['date']).' AND \''.$row['date'].'\'
;';
array_push(
$filter_sets,
array_from_query($query, 'id')
);
$filter_sets[] = array_from_query($query, 'id');
}

break;
Expand Down Expand Up @@ -242,10 +233,7 @@
$linked_to_virtual = array_from_query($query, 'image_id');
}

array_push(
$filter_sets,
array_diff($all_elements, $linked_to_virtual)
);
$filter_sets[] = array_diff($all_elements, $linked_to_virtual);

break;

Expand All @@ -257,10 +245,7 @@
LEFT JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id
WHERE category_id is null
;';
array_push(
$filter_sets,
array_from_query($query, 'id')
);
$filter_sets[] = array_from_query($query, 'id');

break;

Expand All @@ -272,10 +257,7 @@
LEFT JOIN '.IMAGE_TAG_TABLE.' ON id = image_id
WHERE tag_id is null
;';
array_push(
$filter_sets,
array_from_query($query, 'id')
);
$filter_sets[] = array_from_query($query, 'id');

break;

Expand All @@ -297,11 +279,7 @@
FROM '.IMAGES_TABLE.'
WHERE file IN (\''.implode("','", $duplicate_files).'\')
;';

array_push(
$filter_sets,
array_from_query($query, 'id')
);
$filter_sets[] = array_from_query($query, 'id');

break;

Expand Down Expand Up @@ -337,10 +315,7 @@
FROM '.IMAGE_CATEGORY_TABLE.'
WHERE category_id IN ('.implode(',', $categories).')
;';
array_push(
$filter_sets,
array_from_query($query, 'image_id')
);
$filter_sets[] = array_from_query($query, 'image_id');
}

if (isset($_SESSION['bulk_manager_filter']['level']))
Expand All @@ -362,15 +337,12 @@

if (!empty($_SESSION['bulk_manager_filter']['tags']))
{
array_push(
$filter_sets,
get_image_ids_for_tags(
$_SESSION['bulk_manager_filter']['tags'],
$_SESSION['bulk_manager_filter']['tag_mode'],
null,
null,
false // we don't apply permissions in administration screens
)
$filter_sets[] = get_image_ids_for_tags(
$_SESSION['bulk_manager_filter']['tags'],
$_SESSION['bulk_manager_filter']['tag_mode'],
null,
null,
false // we don't apply permissions in administration screens
);
}

Expand Down
78 changes: 28 additions & 50 deletions admin/batch_manager_global.php
Expand Up @@ -82,7 +82,7 @@
// photo in the selection
if (count($collection) == 0)
{
array_push($page['errors'], l10n('Select at least one photo'));
$page['errors'][] = l10n('Select at least one photo');
}

$action = $_POST['selectAction'];
Expand All @@ -105,7 +105,7 @@
{
if (empty($_POST['add_tags']))
{
array_push($page['errors'], l10n('Select at least one tag'));
$page['errors'][] = l10n('Select at least one tag');
}
else
{
Expand Down Expand Up @@ -133,7 +133,7 @@
}
else
{
array_push($page['errors'], l10n('Select at least one tag'));
$page['errors'][] = l10n('Select at least one tag');
}
}

Expand Down Expand Up @@ -241,12 +241,9 @@
$datas = array();
foreach ($collection as $image_id)
{
array_push(
$datas,
array(
'id' => $image_id,
'author' => $_POST['author']
)
$datas[] = array(
'id' => $image_id,
'author' => $_POST['author']
);
}

Expand All @@ -268,12 +265,9 @@
$datas = array();
foreach ($collection as $image_id)
{
array_push(
$datas,
array(
'id' => $image_id,
'name' => $_POST['title']
)
$datas[] = array(
'id' => $image_id,
'name' => $_POST['title']
);
}

Expand Down Expand Up @@ -302,12 +296,9 @@
$datas = array();
foreach ($collection as $image_id)
{
array_push(
$datas,
array(
'id' => $image_id,
'date_creation' => $date_creation
)
$datas[] = array(
'id' => $image_id,
'date_creation' => $date_creation
);
}

Expand All @@ -324,12 +315,9 @@
$datas = array();
foreach ($collection as $image_id)
{
array_push(
$datas,
array(
'id' => $image_id,
'level' => $_POST['level']
)
$datas[] = array(
'id' => $image_id,
'level' => $_POST['level']
);
}

Expand Down Expand Up @@ -362,40 +350,30 @@
$deleted_count = delete_elements($collection, true);
if ($deleted_count > 0)
{
$_SESSION['page_infos'] = array(
sprintf(
l10n_dec(
'%d photo was deleted',
'%d photos were deleted',
$deleted_count
),
$deleted_count
)
$_SESSION['page_infos'][] = l10n_dec(
'%d photo was deleted', '%d photos were deleted',
$deleted_count
);

$redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
redirect($redirect_url);
}
else
{
array_push($page['errors'], l10n('No photo can be deleted'));
$page['errors'][] = l10n('No photo can be deleted');
}
}
else
{
array_push($page['errors'], l10n('You need to confirm deletion'));
$page['errors'][] = l10n('You need to confirm deletion');
}
}

// synchronize metadata
if ('metadata' == $action)
{
sync_metadata($collection);

array_push(
$page['infos'],
l10n('Metadata synchronized from file')
);
$page['infos'][] = l10n('Metadata synchronized from file');
}

if ('delete_derivatives' == $action)
Expand All @@ -415,11 +393,13 @@
if ('generate_derivatives' == $action)
{
if ($_POST['regenerateSuccess'] != '0')
array_push($page['infos'], l10n('%s photos have been regenerated', $_POST['regenerateSuccess']));

{
$page['infos'][] = l10n('%s photos have been regenerated', $_POST['regenerateSuccess']);
}
if ($_POST['regenerateError'] != '0')
array_push($page['warnings'], l10n('%s photos can not be regenerated', $_POST['regenerateError']));

{
$page['warnings'][] = l10n('%s photos can not be regenerated', $_POST['regenerateError']);
}
}

trigger_action('element_set_global_action', $action, $collection);
Expand All @@ -444,9 +424,7 @@

if ($conf['enable_synchronization'])
{
array_push($prefilters,
array('ID' => 'no_virtual_album', 'NAME' => l10n('With no virtual album'))
);
$prefilters[] = array('ID' => 'no_virtual_album', 'NAME' => l10n('With no virtual album'));
}

$prefilters = trigger_event('get_batch_manager_prefilters', $prefilters);
Expand Down
6 changes: 3 additions & 3 deletions admin/batch_manager_unit.php
Expand Up @@ -103,7 +103,7 @@
$data['date_creation'] = $row['date_creation'];
}

array_push($datas, $data);
$datas[] = $data;

// tags management
$tag_ids = array();
Expand All @@ -123,7 +123,7 @@
$datas
);

array_push($page['infos'], l10n('Photo informations updated'));
$page['infos'][] = l10n('Photo informations updated');
}

// +-----------------------------------------------------------------------+
Expand Down Expand Up @@ -232,7 +232,7 @@

while ($row = pwg_db_fetch_assoc($result))
{
array_push($element_ids, $row['id']);
$element_ids[] = $row['id'];

$src_image = new SrcImage($row);

Expand Down
30 changes: 9 additions & 21 deletions admin/cat_list.php
Expand Up @@ -78,7 +78,7 @@ function save_categories_order($categories)
$current_rank++;
}

array_push($datas, array('id' => $id, 'rank' => $current_rank));
$datas[] = array('id' => $id, 'rank' => $current_rank);
}
$fields = array('primary' => array('id'), 'update' => array('rank'));
mass_updates(CATEGORIES_TABLE, $fields, $datas);
Expand Down Expand Up @@ -133,11 +133,11 @@ function save_categories_order($categories)

if (isset($output_create['error']))
{
array_push($page['errors'], $output_create['error']);
$page['errors'][] = $output_create['error'];
}
else
{
array_push($page['infos'], $output_create['info']);
$page['infos'][] = $output_create['info'];
}
}
// save manual category ordering
Expand All @@ -146,10 +146,7 @@ function save_categories_order($categories)
asort($_POST['catOrd'], SORT_NUMERIC);
save_categories_order(array_keys($_POST['catOrd']));

array_push(
$page['infos'],
l10n('Album manual order was saved')
);
$page['infos'][] = l10n('Album manual order was saved');
}
else if (isset($_POST['submitAutoOrder']))
{
Expand Down Expand Up @@ -178,17 +175,11 @@ function save_categories_order($categories)
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
array_push(
$categories,
array(
'id' => $row['id'],
'id_uppercat' => $row['id_uppercat'],
)
);
array_push(
$names,
$row['name']
$categories[] = array(
'id' => $row['id'],
'id_uppercat' => $row['id_uppercat'],
);
$names[] = $row['name'];
}

array_multisort(
Expand All @@ -199,10 +190,7 @@ function save_categories_order($categories)
);
save_categories_order($categories);

array_push(
$page['infos'],
l10n('Albums automatically sorted')
);
$page['infos'][] = l10n('Albums automatically sorted');
}

// +-----------------------------------------------------------------------+
Expand Down

0 comments on commit ae70727

Please sign in to comment.