MDL-81327 core: Remove unnecessary table filter

The \Traversable interface does not define the `valid` method.
Furthermore, the `valid` method actually checks that there is a _next_
value, which requires the value already be fetched and waiting. This is
not the case for all Iterators. For example the CallbackFilterIterator
does not load the initial value until it is requested.

It is completely unnecessary to do this check anyway as an invalid
Iterator will just not return any values.
This commit is contained in:
Andrew Nicols
2024-04-09 11:00:33 +02:00
committed by Laurent David
parent c0038b965e
commit 7e5b98ea3e
+3 -6
View File
@@ -2048,6 +2048,8 @@ class table_sql extends flexible_table {
}
/**
* Build the table from the fetched data.
*
* Take the data returned from the db_query and go through all the rows
* processing each col using either col_{columnname} method or other_cols
* method or if other_cols returns NULL then put the data straight into the
@@ -2056,18 +2058,13 @@ class table_sql extends flexible_table {
* After calling this function, don't forget to call close_recordset.
*/
public function build_table() {
if ($this->rawdata instanceof \Traversable && !$this->rawdata->valid()) {
return;
}
if (!$this->rawdata) {
return;
}
foreach ($this->rawdata as $row) {
$formattedrow = $this->format_row($row);
$this->add_data_keyed($formattedrow,
$this->get_row_class($row));
$this->add_data_keyed($formattedrow, $this->get_row_class($row));
}
}