summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rpminfo.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/rpminfo.c b/rpminfo.c
index 88e58b9..3cc5f54 100644
--- a/rpminfo.c
+++ b/rpminfo.c
@@ -390,23 +390,25 @@ PHP_FUNCTION(rpmdbsearch)
rpmtsOpenDB(ts, O_RDONLY);
db = rpmtsGetRdb(ts);
if (useIndex) {
+ /* Simple criterion using index */
di = rpmdbInitIterator(db, crit, name, len);
} else {
/* query all packages */
di = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
+ /* add criterion */
+ if (di) {
+ if (rpmdbSetIteratorRE(di, crit, mode, name)) {
+ php_error_docref(NULL, E_WARNING, "Can't set filter");
+ rpmtsCloseDB(ts);
+ RETURN_FALSE;
+ }
+ }
}
if (!di) {
// Not found
rpmtsCloseDB(ts);
RETURN_FALSE;
}
- if (!useIndex) {
- if (rpmdbSetIteratorRE(di, crit, mode, name)) {
- php_error_docref(NULL, E_WARNING, "Can't set filter");
- rpmtsCloseDB(ts);
- RETURN_FALSE;
- }
- }
array_init(return_value);
while ((h = rpmdbNextIterator(di)) != NULL) {