Skip to content

Commit

Permalink
Fix handling of HistoryRecord string truncation in UTF-8 contexts (CF…
Browse files Browse the repository at this point in the history
…M-76)
  • Loading branch information
Benn Oshrin committed Apr 18, 2025
1 parent 1b04a06 commit 15d8606
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/src/Model/Table/HistoryRecordsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ public function beforeMarshal(EventInterface $event, \ArrayObject $data, \ArrayO
$coId = null;

if(!empty($data['person_id'])) {
$coId = $this->People->findCoForRecord($data['person_id']);
$coId = $this->People->findCoForRecord((int)$data['person_id']);
} elseif(!empty($data['group_id'])) {
$coId = $this->Groups->findCoForRecord($data['group_id']);
$coId = $this->Groups->findCoForRecord((int)$data['group_id']);
}

if($coId) {
Expand All @@ -159,7 +159,7 @@ public function beforeMarshal(EventInterface $event, \ArrayObject $data, \ArrayO
// Truncate the comment to fit the column width
$column = $this->getSchema()->getColumn('comment');

$data['comment'] = substr($data['comment'], 0, $column['length']);
$data['comment'] = mb_substr($data['comment'], 0, $column['length']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/JobHistoryRecordsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function beforeMarshal(EventInterface $event, \ArrayObject $data, \ArrayO
// Truncate the comment to fit the column width
$column = $this->getSchema()->getColumn('comment');

$data['comment'] = substr($data['comment'], 0, $column['length']);
$data['comment'] = mb_substr($data['comment'], 0, $column['length']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/PetitionHistoryRecordsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function beforeMarshal(EventInterface $event, \ArrayObject $data, \ArrayO
// Truncate the comment to fit the column width
$column = $this->getSchema()->getColumn('comment');

$data['comment'] = substr($data['comment'], 0, $column['length']);
$data['comment'] = mb_substr($data['comment'], 0, $column['length']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/Model/Table/ProvisioningHistoryRecordsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function beforeMarshal(EventInterface $event, \ArrayObject $data, \ArrayO
// Truncate the comment to fit the column width
$column = $this->getSchema()->getColumn('comment');

$data['comment'] = substr($data['comment'], 0, $column['length']);
$data['comment'] = mb_substr($data['comment'], 0, $column['length']);
}
}

Expand Down

0 comments on commit 15d8606

Please sign in to comment.