+ //TODO: Refactor out,duplicated from ApiQueryExtLinksUsage
+ if ( !is_null( $query ) || $query != '' ) {
+ if ( is_null( $protocol ) ) {
+ $protocol = 'http://';
+ }
+
+ $likeQuery = LinkFilter::makeLikeArray( $query, $protocol );
+ if ( !$likeQuery ) {
+ $this->dieUsage( 'Invalid query', 'bad_query' );
+ }
+
+ $likeQuery = LinkFilter::keepOneWildcard( $likeQuery );
+ $this->addWhere( 'el_index ' . $db->buildLike( $likeQuery ) );
+ } elseif ( !is_null( $protocol ) ) {
+ $this->addWhere( 'el_index ' . $db->buildLike( "$protocol", $db->anyString() ) );
+ }
+