Very simple. Cleans the element-by-element array shifting done in path_admin_overview (path.admin.inc):
if ($multilanguage) {
$header[3] = $header[2];
$header[2] = array('data' => t('Language'), 'field' => 'language');
}
...
if ($multilanguage) {
$row[4] = $row[3];
$row[3] = $row[2];
$row[2] = module_invoke('locale', 'language_name', $data->language);
}
... with the wonderful PHP function array_splice, which can insert a new element in an array using array_splice($array, $offset, 0, $new_data):
if ($multilanguage) {
array_splice($header, 2, 0, array(array('data' => t('Language'), 'field' => 'language')));
}
...
if ($multilanguage) {
array_splice($row, 2, 0, module_invoke('locale', 'language_name', $data->language));
}
Patched and ran the path tests with 100% pass (102 passes).
Comments
Comment #1
Anonymous (not verified) commentedSimple patch. Do you have performance results?
Comment #2
dave reidIf anything, this will result in a very small increase in performance since we'd be using the native PHP function for this purpose. Main purpose of this patch was to simplify the code. I'll try and do some testing today.
Comment #3
dave reidAlright. Finally figured out how to get ab to test the admin/build/path page and not get 403 errors. Run on 2GHz Intel P4, 2000 users, 50 nodes (couldn't get devel_generate 7.x to use batch correctly) with path aliases and translation enabled. Before patch:
After patch:
Net result, very small increase in performance, but an increase nonetheless.
Comment #4
Anonymous (not verified) commentedComment #5
dries commentedThanks for the little gem, and the performance testing. I've committed it to CVS HEAD.
Unfortunately, neither the new or the old code is tested: http://acquia.com/files/test-results/modules_path_path.admin.inc.html. As such, I'm marking this 'code needs work' so we can follow-up with some tests.
Thanks Dave.
Comment #6
dries commentedComment #7
dave reidIdeas if this should be integrated as a new test in path.test or part of the existing path admin test?
Comment #8
dave reidActually here's a much better way to do this without doing any array manipulation.
Comment #9
aaronbaumanLooks like #8 has been committed, so this should go back to needs work per comment #5.
Comment #10
dave reidAdding tag