Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mantis 19178 - In php 7.2 the each() function is deprecated #290

Merged
merged 1 commit into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions public_html/lists/admin/actions/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
$row_delim = "\n";

if (is_array($_SESSION['export']['cols'])) {
while (list($key, $val) = each($DBstruct['user'])) {
foreach ($DBstruct['user'] as $key => $val) {
if (in_array($key, $_SESSION['export']['cols'])) {
if (strpos($val[1], 'sys') === false) {
fwrite($exportfile, $val[1].$col_delim);
Expand Down Expand Up @@ -168,11 +168,11 @@
}
++$done;
reset($_SESSION['export']['cols']);
while (list($key, $val) = each($_SESSION['export']['cols'])) {
foreach ($_SESSION['export']['cols'] as $key => $val) {
fwrite($exportfile, strtr($user[$val], $col_delim, ',').$col_delim);
}
reset($attributes);
while (list($key, $val) = each($attributes)) {
foreach ($attributes as $key => $val) {
$value = UserAttributeValue($user['id'], $val['id']);
fwrite($exportfile, quoteEnclosed($value, $col_delim, $row_delim).$col_delim);
}
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/actions/import1.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}
}

while (list($email, $data) = each($user_list)) {
foreach ($user_list as $email => $data) {
//# a lot of spreadsheet include those annoying quotes
$email = str_replace('"', '', $email);
set_time_limit(60);
Expand Down
6 changes: 3 additions & 3 deletions public_html/lists/admin/actions/import2.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
$user['systemvalues'] = $system_values;
reset($_SESSION['import_attribute']);
$replace = array();
while (list($key, $val) = each($_SESSION['import_attribute'])) {
foreach ($_SESSION['import_attribute'] as $key => $val) {
if (!empty($values[$val['index']])) {
$user[$val['index']] = addslashes($values[$val['index']]);
$replace[$key] = addslashes($values[$val['index']]);
Expand Down Expand Up @@ -437,7 +437,7 @@
reset($_SESSION['lists']);
$addition = 0;
$listoflists = '';
while (list($key, $listid) = each($_SESSION['lists'])) {
foreach ($_SESSION['lists'] as $key => $listid) {
$query = 'replace INTO '.$tables['listuser']." (userid,listid,entered) values($userid,$listid,now())";
$result = Sql_query($query, 1);
// if the affected rows is 2, the user was already subscribed
Expand Down Expand Up @@ -475,7 +475,7 @@
//add this user to the groups identified
reset($groups);
$groupaddition = 0;
while (list($key, $groupid) = each($groups)) {
foreach ($groups as $key => $groupid) {
if ($groupid) {
$query = sprintf('replace INTO user_group (userid,groupid,type) values(%d,%d,%d)', $userid,
$groupid, $_SESSION['grouptype']);
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/addprefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

include 'structure.php';

while (list($table, $value) = each($DBstruct)) {
foreach ($DBstruct as $table => $value) {
if ($table != $tables[$table]) {
Sql_Verbose_Query("drop table if exists $tables[$table]", 0);
Sql_Verbose_Query("alter table $table rename $tables[$table]", 0);
Expand Down
6 changes: 3 additions & 3 deletions public_html/lists/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
if ($id) {
echo '<div class="actionresult">';
reset($struct);
while (list($key, $val) = each($struct)) {
foreach ($struct as $key => $val) {
$a = $b = '';
if (strstr($val[1], ':')) {
list($a, $b) = explode(':', $val[1]);
Expand All @@ -100,7 +100,7 @@
// Sql_Query("update {$tables["admin"]} set password = \"".sql_escape($_POST['password'])."\" where id = $id");
}
if (isset($_POST['attribute']) && is_array($_POST['attribute'])) {
while (list($key, $val) = each($_POST['attribute'])) {
foreach ($_POST['attribute'] as $key => $val) {
Sql_Query(sprintf('replace into %s (adminid,adminattributeid,value)
values(%d,%d,"%s")', $tables['admin_attribute'], $id, $key, addslashes($val)));
}
Expand Down Expand Up @@ -165,7 +165,7 @@
}

reset($struct);
while (list($key, $val) = each($struct)) {
foreach ($struct as $key => $val) {
$a = $b = '';
if (empty($data[$key])) {
$data[$key] = '';
Expand Down
6 changes: 3 additions & 3 deletions public_html/lists/admin/adminattributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
echo '<script language="Javascript" type="text/javascript"> document.write(progressmeter); start();</script>';
}
flush();
while (list($id, $val) = each($_POST['name'])) {
foreach ($_POST['name'] as $id => $val) {
if (!$id && isset($_POST['name'][0]) && $_POST['name'][0] != '') {
// it is a new one
$lc_name = substr(preg_replace("/\W/", '', strtolower($_POST['name'][0])), 0, 10);
Expand Down Expand Up @@ -59,7 +59,7 @@
}
}
if (isset($_POST['delete'])) {
while (list($id, $val) = each($_POST['delete'])) {
foreach ($_POST['delete'] as $id => $val) {
$res = Sql_Query("select tablename,type from {$tables['adminattribute']} where id = $id");
$row = Sql_Fetch_Row($res);
if ($row[1] != 'hidden' && $row[1] != 'textline') {
Expand Down Expand Up @@ -135,7 +135,7 @@
<td colspan="2"><select name="type[0]">
<?php
$types = array('textline', 'hidden'); //'radio','select','checkbox',
while (list($key, $val) = each($types)) {
foreach ($types as $key => $val) {
printf('<option value="%s" %s>%s</option>', $val, '', $val);
}
?>
Expand Down
4 changes: 2 additions & 2 deletions public_html/lists/admin/attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
echo '<div class="panel"><div class="header"></div><div class="content">';
if (isset($_POST['action'])) {
if (isset($_POST['name'])) {
while (list($id, $val) = each($_POST['name'])) {
foreach ($_POST['name'] as $id => $val) {
if (!$id && isset($_POST['name'][0]) && $_POST['name'][0] != '') {
// it is a new one
$lc_name = getNewAttributeTablename($_POST['name'][0]);
Expand Down Expand Up @@ -173,7 +173,7 @@
} elseif (isset($_POST['tagaction']) && is_array($_POST['tag'])) {
ksort($_POST['tag']);
if (isset($_POST['tagaction']['delete'])) {
while (list($k, $id) = each($_POST['tag'])) {
foreach ($_POST['tag'] as $k => $id) {
// check for dependencies
$id = sprintf('%d', $id);
if ($formtable_exists) {
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/class.image.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class imageUpload
$result = array();
$req = Sql_Query(sprintf('select * from image where id = %d', $fielddata[data]));
$att = Sql_Fetch_Array($req);
while (list($key, $val) = each($att)) {
foreach ($att as $key => $val) {
$result[$fielddata[name] . "." . $key] = $val;
}
return $result;
Expand Down
8 changes: 4 additions & 4 deletions public_html/lists/admin/connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ function Error($msg, $documentationURL = '')
++$GLOBALS['mail_error_count'];
if (is_array($_POST) && count($_POST)) {
$GLOBALS['mail_error'] .= "\nPost vars:\n";
while (list($key, $val) = each($_POST)) {
foreach ($_POST as $key => $val) {
if ($key != 'password') {
if (is_array($val)) {
$GLOBALS['mail_error'] .= $key.'='.serialize($val)."\n";
Expand Down Expand Up @@ -1788,7 +1788,7 @@ function delimited($data)
{
$delimitedData = '';
reset($data);
while (list($key, $val) = each($data)) {
foreach ($data as $key => $val) {
$delimitedData .= $key.'KEYVALSEP'.$val.'ITEMSEP';
}
$length = strlen($delimitedData);
Expand Down Expand Up @@ -2044,7 +2044,7 @@ function phplist_shutdown()
.$GLOBALS['mail_error'];
$message .= "\n==== debugging information\n\nSERVER Vars\n";
if (is_array($_SERVER)) {
while (list($key, $val) = each($_SERVER)) {
foreach ($_SERVER as $key => $val) {
if (stripos($key, 'password') === false) {
$message .= $key.'='.serialize($val)."\n";
}
Expand Down Expand Up @@ -2171,7 +2171,7 @@ function printarray($array)
if (!is_array($array)) {
return;
}
while (list($key, $value) = each($array)) {
foreach ($array as $key => $value) {
if (is_array($value)) {
echo $key.'(array):<blockquote>';
printarray($value); //recursief!!
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/date.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function showInput($name, $fielddata, $value, $document_id = 0)
</select>
<select name="' .$name.'[month]">';
reset($this->months);
while (list($key, $val) = each($this->months)) {
foreach ($this->months as $key => $val) {
$sel = '';
if ($key == $month) {
$sel = 'selected="selected"';
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/dbcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

$ls = new WebblerListing(s('Database structure'));
$ls->setElementHeading(s('Table'));
while (list($table, $tablename) = each($GLOBALS['tables'])) {
foreach ($GLOBALS['tables'] as $table => $tablename) {
$createlink = '';
$indexes = $uniques = $engine = $category = '';

Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/defaultconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ function getConfig($item)
}
} else {
reset($default_config);
while (list($item, $values) = each($default_config)) {
foreach ($default_config as $item => $values) {
$val = getConfig($item);
saveConfig($item, $values[0], 0);
}
Expand Down
4 changes: 2 additions & 2 deletions public_html/lists/admin/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function readentry($file)

if (!empty($_POST['selected']) && is_array($_POST['selected'])) {
$selected = $_POST['selected'];
while (list($key, $val) = each($selected)) {
foreach ($selected as $key => $val) {
$entry = readentry("data/$val");
list($name, $desc) = explode(':', $entry);
echo '<br/><br/>'.$GLOBALS['I18N']->get('Loading')." $desc<br/>\n";
Expand Down Expand Up @@ -87,7 +87,7 @@ function readentry($file)
<?php echo formStart(' class="defaultsAdd"') ?>
<?php
reset($attributes);
while (list($key, $attribute) = each($attributes)) {
foreach ($attributes as $key => $attribute) {
if (strstr($key, ':')) {
list($name, $desc) = explode(':', $key);
if ($name && $desc) {
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/editattributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
} else {
$listorder = $maxitem[0] + 1; // One more than the maximum
}
while (list($key, $val) = each($items)) {
foreach ($items as $key => $val) {
$val = clean($val);
if ($val != '') {
$query = sprintf('insert into %s (name,listorder) values("%s","%s")', $table, $val, $listorder);
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@

<?php
$cols = array();
while (list($key, $val) = each($DBstruct['user'])) {
foreach ($DBstruct['user'] as $key => $val) {
if (strpos($val[1], 'sys') === false) {
printf("\n".'<br/><input type="checkbox" name="cols[]" value="%s" checked="checked" /> %s ', $key, $val[1]);
} elseif (preg_match('/sysexp:(.*)/', $val[1], $regs)) {
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/import1.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<p><strong>'.$GLOBALS['I18N']->get('Test output:').'</strong></p>
<hr/>';
$i = 1;
while (list($email, $data) = each($user_list)) {
foreach ($user_list as $email => $data) {
$email = trim($email);
if (strlen($email) > 4) {
echo "<b>$email</b><br/>";
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/import2.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@
$user['systemvalues'] = $system_values;
reset($_SESSION['import_attribute']);
$replace = array();
while (list($key, $val) = each($_SESSION['import_attribute'])) {
foreach ($_SESSION['import_attribute'] as $key => $val) {
if (!empty($values[$val['index']])) {
$user[$val['index']] = addslashes($values[$val['index']]);
$replace[$key] = addslashes($values[$val['index']]);
Expand Down
6 changes: 3 additions & 3 deletions public_html/lists/admin/import3.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ function getBestVersion($emails)
while (count($folderdone) < count($folders) && $level < 10) {
reset($folders);
asort($folders);
while (list($key, $val) = each($folders)) {
foreach ($folders as $key => $val) {
$delim = $val->delimiter;
$name = str_replace('{'.$server.'}INBOX', '', imap_utf7_decode($val->name));
$parent = mailBoxParent($name, $delim, $level);
Expand Down Expand Up @@ -361,7 +361,7 @@ function getBestVersion($emails)
echo '<p class="submit"><input type="submit" value="'.$GLOBALS['I18N']->get('Process Selected Folders').'"></p></form>';
} else {
$all_emails = array();
while (list($key, $folder) = each($_POST['checkfolder'])) {
foreach ($_POST['checkfolder'] as $key => $folder) {
echo '<br/>';
flush();

Expand Down Expand Up @@ -485,7 +485,7 @@ function getBestVersion($emails)
reset($lists);
$addition = 0;
$listoflists = '';
while (list($key, $listid) = each($lists)) {
foreach ($lists as $key => $listid) {
$query = 'replace INTO '.$tables['listuser']." (userid,listid,entered) values($userid,$listid,now())";
$result = Sql_query($query);
// if the affected rows is 2, the user was already subscribed
Expand Down
4 changes: 2 additions & 2 deletions public_html/lists/admin/importadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
if ($test_import) {
echo $GLOBALS['I18N']->get('Test output: If the output looks ok, go Back to resubmit for real').'<br/><br/>';
$i = 1;
while (list($email, $data) = each($user_list)) {
foreach ($user_list as $email => $data) {
$email = trim($email);
if (strlen($email) > 4) {
echo "<br/><b>$email</b><br/>";
Expand Down Expand Up @@ -190,7 +190,7 @@
$some = 0;

if (is_array($user_list)) {
while (list($email, $data) = each($user_list)) {
foreach ($user_list as $email => $data) {
if (strlen($email) > 4) {
$loginname = $data['loginname'];
if (!$loginname && $email) {
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/inc/importlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function clearImport()
//# identify system values from the database structure
$system_attributes = array();
reset($DBstruct['user']);
while (list($key, $val) = each($DBstruct['user'])) {
foreach ($DBstruct['user'] as $key => $val) {
if (strpos($val[1], 'sys') === false && is_array($val)) {
$system_attributes[strtolower($key)] = $val[1]; //# allow columns like "htmlemail" and "foreignkey"
$system_attributes_nicename[strtolower($val[1])] = $key; //# allow columns like "Send this user HTML emails" and "Foreign Key"
Expand Down
6 changes: 3 additions & 3 deletions public_html/lists/admin/inc/userlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ function saveUserAttribute($userid, $attid, $data)
function saveUserByID($userid, $data)
{
dbg("Saving user by id $userid");
while (list($key, $val) = each($data)) {
foreach ($data as $key => $val) {
if (preg_match("/^attribute(\d+)/", $key, $regs)) {
$attid = $regs[1];
} else {
Expand All @@ -1268,7 +1268,7 @@ function saveUser($loginname, $data)
$id_req = Sql_Fetch_Row_Query("select id from user where email = \"$loginname\"");
if ($id_req[0]) {
$userid = $id_req[0];
while (list($key, $val) = each($data)) {
foreach ($data as $key => $val) {
if (preg_match("/^attribute(\d+)/", $key, $regs)) {
$attid = $regs[1];
}
Expand Down Expand Up @@ -1386,7 +1386,7 @@ function saveUserData($username, $fields)

dbg('Checking required fields');
reset($required_fields);
while (list($index, $field) = each($required_fields)) {
foreach ($required_fields as $index => $field) {
$type = $fields[$field]['type'];
// dbg("$field of type $type");
if ($type != 'userfield' && $type != '') { //## @@@ need to check why type is not set
Expand Down
8 changes: 4 additions & 4 deletions public_html/lists/admin/initialise.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function output($message)
$force = !empty($_GET['force']) && $_GET['force'] == 'yes';

if ($force) {
while (list($table, $val) = each($DBstruct)) {
foreach ($DBstruct as $table => $val) {
if ($table == 'attribute') {
$req = Sql_Query("select tablename from {$tables['attribute']}");
while ($row = Sql_Fetch_Row($req)) {
Expand Down Expand Up @@ -89,7 +89,7 @@ function output($message)
//var_dump($GLOBALS['plugins']);exit;

output('<h3>'.s('Creating tables')."</h3><br />");
while (list($table, $val) = each($DBstruct)) {
foreach ($DBstruct as $table => $val) {
if ($force) {
if ($table == 'attribute') {
$req = Sql_Query("select tablename from {$tables['attribute']}");
Expand All @@ -100,7 +100,7 @@ function output($message)
Sql_query("drop table if exists $tables[$table]");
}
$query = "CREATE TABLE $tables[$table] (\n";
while (list($column, $struct) = each($DBstruct[$table])) {
foreach ($DBstruct[$table] as $column => $struct) {
if (preg_match('/index_\d+/', $column)) {
$query .= 'index '.$struct[0].',';
} elseif (preg_match('/unique_\d+/', $column)) {
Expand Down Expand Up @@ -150,7 +150,7 @@ function output($message)
$adminid = Sql_Insert_Id();
*/
} elseif ($table == 'task') {
while (list($type, $pages) = each($system_pages)) {
foreach ($system_pages as $type => $pages) {
foreach ($pages as $page => $access_level) {
Sql_Query(sprintf('replace into %s (page,type) values("%s","%s")',
$tables['task'], $page, $type));
Expand Down
2 changes: 1 addition & 1 deletion public_html/lists/admin/mysqli.inc
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ function createTable($table)
function Sql_create_Table($table, $structure)
{
$query = "CREATE TABLE $table (\n";
while (list($column, $val) = each($structure)) {
foreach ($structure as $column => $val) {
if (preg_match('/index_\d+/', $column)) {
$query .= "index " . $structure[$column][0] . ",";
} elseif (preg_match('/unique_\d+/', $column)) {
Expand Down
Loading