Skip to content

Commit

Permalink
Avoid trying to copy indices when copying a message. (phpList#174)
Browse files Browse the repository at this point in the history
Explicitly set the finishsending date when copying a message.
  • Loading branch information
bramley authored and samtuke committed Nov 21, 2017
1 parent 9aed65a commit b6390fc
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions public_html/lists/admin/connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -1870,14 +1870,15 @@ function repeatMessage($msgid)
return;
}

// Do not copy columns that use default values or are explicitly set
// Do not copy columns that use default values or are explicitly set, or indices
$columnsToCopy = array_diff(
array_keys($DBstruct['message']),
array(
'id', 'entered', 'modified', 'embargo', 'status', 'sent', 'processed', 'astext', 'ashtml',
'astextandhtml', 'aspdf', 'astextandpdf', 'viewed', 'bouncecount', 'sendstart', 'uuid',
)
);
$columnsToCopy = preg_grep('/^index_/', $columnsToCopy, PREG_GREP_INVERT);

foreach ($columnsToCopy as $column) {
Sql_Query(sprintf('update %s set %s = "%s" where id = %d',
Expand All @@ -1891,11 +1892,11 @@ function repeatMessage($msgid)
$newid
));

// copy rows in messagedata
// copy rows in messagedata except those that are explicitly set
$req = Sql_Query(sprintf(
"SELECT *
FROM %s
WHERE id = %d AND name NOT IN ('id')",
WHERE id = %d AND name NOT IN ('id', 'embargo', 'finishsending')",
$GLOBALS['tables']['messagedata'], $msgid
));
while ($row = Sql_Fetch_Array($req)) {
Expand All @@ -1907,6 +1908,16 @@ function repeatMessage($msgid)
unset($e['second']);
setMessageData($newid, 'embargo', $e);

$finishSending = time() + DEFAULT_MESSAGEAGE;
$finish = array(
'year' => date('Y', $finishSending),
'month' => date('m', $finishSending),
'day' => date('d', $finishSending),
'hour' => date('H', $finishSending),
'minute' => date('i', $finishSending),
);
setMessageData($newid, 'finishsending', $finish);

// lists
$req = Sql_Query(sprintf('select listid from %s where messageid = %d', $GLOBALS['tables']['listmessage'], $msgid));
while ($row = Sql_Fetch_Row($req)) {
Expand Down

0 comments on commit b6390fc

Please sign in to comment.