diff --git a/lib/dml/pgsql_native_moodle_database.php b/lib/dml/pgsql_native_moodle_database.php index 98becbc6289..67f213cd5be 100644 --- a/lib/dml/pgsql_native_moodle_database.php +++ b/lib/dml/pgsql_native_moodle_database.php @@ -653,7 +653,7 @@ class pgsql_native_moodle_database extends moodle_database { $id = reset($row); if ($blobs) { foreach ($blobs as $blob) { - $row[$blob] = pg_unescape_bytea($row[$blob]); + $row[$blob] = $row[$blob] !== null ? pg_unescape_bytea($row[$blob]) : null; } } if (isset($return[$id])) { diff --git a/lib/dml/pgsql_native_moodle_recordset.php b/lib/dml/pgsql_native_moodle_recordset.php index 525a48c916a..41093740e0c 100644 --- a/lib/dml/pgsql_native_moodle_recordset.php +++ b/lib/dml/pgsql_native_moodle_recordset.php @@ -62,7 +62,7 @@ class pgsql_native_moodle_recordset extends moodle_recordset { if ($this->blobs) { foreach ($this->blobs as $blob) { - $row[$blob] = pg_unescape_bytea($row[$blob]); + $row[$blob] = $row[$blob] !== null ? pg_unescape_bytea($row[$blob]) : null; } }