}
}
+ /**
+ * Like addWhereFld for an integer list of IDs
+ * @since 1.33
+ * @param string $table Table name
+ * @param string $field Field name
+ * @param int[] $ids IDs
+ * @return int Count of IDs actually included
+ */
+ protected function addWhereIDsFld( $table, $field, $ids ) {
+ // Use count() to its full documented capabilities to simultaneously
+ // test for null, empty array or empty countable object
+ if ( count( $ids ) ) {
+ $ids = $this->filterIDs( [ [ $table, $field ] ], $ids );
+
+ if ( !count( $ids ) ) {
+ // Return nothing, no IDs are valid
+ $this->where[] = '0 = 1';
+ } else {
+ $this->where[$field] = $ids;
+ }
+ }
+ return count( $ids );
+ }
+
/**
* Add a WHERE clause corresponding to a range, and an ORDER BY
* clause to sort in the right direction
* Add an option such as LIMIT or USE INDEX. If an option was set
* before, the old value will be overwritten
* @param string $name Option name
- * @param string|string[] $value Option value
+ * @param string|string[]|null $value Option value
*/
protected function addOption( $name, $value = null ) {
if ( is_null( $value ) ) {
}
/**
- * @param string $query
- * @param string $protocol
+ * @deprecated since 1.33, use LinkFilter::getQueryConditions() instead
+ * @param string|null $query
+ * @param string|null $protocol
* @return null|string
*/
public function prepareUrlQuerySearchString( $query = null, $protocol = null ) {
+ wfDeprecated( __METHOD__, '1.33' );
$db = $this->getDB();
- if ( !is_null( $query ) || $query != '' ) {
+ if ( $query !== null && $query !== '' ) {
if ( is_null( $protocol ) ) {
$protocol = 'http://';
}
* @return void
*/
public function showHiddenUsersAddBlockInfo( $showBlockInfo ) {
+ $db = $this->getDB();
+
$this->addTables( 'ipblocks' );
$this->addJoinConds( [
- 'ipblocks' => [ 'LEFT JOIN', 'ipb_user=user_id' ],
+ 'ipblocks' => [ 'LEFT JOIN', [
+ 'ipb_user=user_id',
+ 'ipb_expiry > ' . $db->addQuotes( $db->timestamp() ),
+ ] ],
] );
$this->addFields( 'ipb_deleted' );
* Same as addPageSubItems(), but one element of $data at a time
* @param int $pageId Page ID
* @param array $item Data array à la ApiResult
- * @param string $elemname XML element name. If null, getModuleName()
+ * @param string|null $elemname XML element name. If null, getModuleName()
* is used
* @return bool Whether the element fit in the result
*/