Skip to content

Commit

Permalink
TW20610099 Allow fetching all existing history for new inactive boards
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlkin committed Jan 2, 2024
1 parent 3ce8738 commit ff297bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions classes/board.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ public static function board_get(int $boardid, int $ownerid = 0): array {
*
* @param int $boardid
* @param int $ownerid
* @param int $since
* @param ?int $since
* @return array
*/
public static function board_history(int $boardid, int $ownerid, int $since): array {
public static function board_history(int $boardid, int $ownerid, ?int $since): array {
global $DB;

static::require_capability_for_board_view($boardid);
Expand All @@ -402,8 +402,13 @@ public static function board_history(int $boardid, int $ownerid, int $since): ar

static::clear_history();

$condition = "boardid=:boardid AND id > :since";
$params = array('boardid' => $boardid, 'since' => $since);
$condition = "boardid = :boardid";
$params = array('boardid' => $boardid);

if ($since !== null) {
$condition .= " AND id > :since";
$params['since'] = $since;
}
if (!empty($groupid)) {
$condition .= " AND groupid=:groupid";
$params['groupid'] = $groupid;
Expand Down
4 changes: 2 additions & 2 deletions external.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public static function board_history_parameters(): external_function_parameters
* Function board_history,
* @param int $id
* @param int $ownerid
* @param int $since
* @param ?int $since
* @return array
*/
public static function board_history(int $id, int $ownerid, int $since): array {
public static function board_history(int $id, int $ownerid, ?int $since): array {
// Validate recieved parameters.
$params = self::validate_parameters(self::board_history_parameters(), [
'id' => $id,
Expand Down

0 comments on commit ff297bb

Please sign in to comment.