r46530 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46529‎ | r46530 | r46531 >
Date:11:22, 29 January 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
Fixed selection of offset parameter in queries
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Query.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Query.php
@@ -16,11 +16,11 @@
1717 */
1818
1919 /**
20 - * Representation of queries in SMW, each consisting of a query
21 - * description and various parameters. Some settings might also lead to
 20+ * Representation of queries in SMW, each consisting of a query
 21+ * description and various parameters. Some settings might also lead to
2222 * changes in the query description.
2323 *
24 - * Most additional query parameters (limit, sort, ascending, ...) are
 24+ * Most additional query parameters (limit, sort, ascending, ...) are
2525 * interpreted as in SMWRequestOptions (though the latter contains some
2626 * additional settings).
2727 * @ingroup SMWQuery
@@ -118,13 +118,17 @@
119119 }
120120
121121 /**
122 - * Set an offset for the returned query results. The current limit is taken into
123 - * account such that the offset cannot be so large that no results are can ever
124 - * be returned at all.
 122+ * Set an offset for the returned query results. No offset beyond the maximal query
 123+ * limit will be set, and the current query limit might be reduced in order to ensure
 124+ * that no results beyond the maximal limit are returned.
125125 * The function returns the chosen offset.
 126+ * @todo The function should be extended to take into account whether or not we
 127+ * are in inline mode (not critical, since offsets are usually not applicable inline).
126128 */
127129 public function setOffset($offset) {
128 - $this->m_offset = min($this->m_limit - 1, $offset); //select integer between 0 and current limit -1;
 130+ global $smwgQMaxLimit;
 131+ $this->m_offset = min($smwgQMaxLimit, $offset); //select integer between 0 and maximal limit;
 132+ $this->m_limit = min($smwgQMaxLimit - $this->m_offset, $this->m_limit); // note that limit might become 0 here
129133 return $this->m_offset;
130134 }
131135

Status & tagging log