From 66081c6692167f92413974dccc373cb636ed618f Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 22 Apr 2006 02:12:59 +0000 Subject: [PATCH] Database.php: * Proper handling of LIST_OR in makeList() LinkBatch.php: * Added isEmpty() and getSize() functions. Query.php: * Implemented double-redirects query (disabled until caching is done) * Implemented backlinks query. * Rewrote page info generator to allow both titles and pageIds to be specified. * Security check for read-access. * Output filtering prevents exposure of the internal data. * Added transactional consistency (not sure its needed here) --- includes/Database.php | 6 ++++-- includes/LinkBatch.php | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/includes/Database.php b/includes/Database.php index 2c45046e94..55d5f969bb 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1078,8 +1078,10 @@ class Database { /** * Makes a wfStrencoded list from an array - * $mode: LIST_COMMA - comma separated, no field names + * $mode: + * LIST_COMMA - comma separated, no field names * LIST_AND - ANDed WHERE clause (without the WHERE) + * LIST_OR - ORed WHERE clause (without the WHERE) * LIST_SET - comma separated with field names, like a SET clause * LIST_NAMES - comma separated field names */ @@ -1104,7 +1106,7 @@ class Database { } if ( ($mode == LIST_AND || $mode == LIST_OR) && is_numeric( $field ) ) { $list .= "($value)"; - } elseif ( $mode == LIST_AND && is_array ($value) ) { + } elseif ( ($mode == LIST_AND || $mode == LIST_OR) && is_array ($value) ) { $list .= $field." IN (".$this->makeList($value).") "; } else { if ( $mode == LIST_AND || $mode == LIST_OR || $mode == LIST_SET ) { diff --git a/includes/LinkBatch.php b/includes/LinkBatch.php index 8dfbc8211a..e0f0f6fd10 100644 --- a/includes/LinkBatch.php +++ b/includes/LinkBatch.php @@ -46,6 +46,20 @@ class LinkBatch { $this->data = $array; } + /** + * Returns true if no pages have been added, false otherwise. + */ + function isEmpty() { + return ($this->getSize() == 0); + } + + /** + * Returns the size of the batch. + */ + function getSize() { + return count( $this->data ); + } + /** * Do the query and add the results to the LinkCache object * Return an array mapping PDBK to ID @@ -100,7 +114,7 @@ class LinkBatch { $fname = 'LinkBatch::doQuery'; $namespaces = array(); - if ( !count( $this->data ) ) { + if ( $this->isEmpty() ) { return false; } wfProfileIn( $fname ); -- 2.20.1