| Project: | Better Formats |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
On a form with a few different textareas that contained input formats, I found that Better Formats is causing duplicate queries per page load. The problem is caused by Better Formats' call to _filter_tips(), which arguably it shouldn't be calling anyway.
_filter_tips() contains the following code:
<?php
function _filter_tips($format, $long = FALSE) {
if ($format == -1) {
$formats = filter_formats();
}
else {
$formats = array(db_fetch_object(db_query("SELECT * FROM {filter_formats} WHERE format = %d", $format)));
}
?>Since Better Formats passes in a $format ID, it does a SQL query per format, even though all the filter formats have already been loaded and staticly cached in filter_formats(). Clearly this is rather poor programing on the core side, but it would be appropriate for Better Formats to make it's own version of _filter_tips() in which it can produce the same output without any additional queries by passing in the format rather than needing to pull it from the database.