- if ( $result && !isset( $result->b_namespace ) ) {
- $dbr = wfGetDB( DB_REPLICA );
- $qi = $this->reallyGetQueryInfo(
- $result->namespace,
- $result->title
- );
- $res = $dbr->select(
- $qi['tables'],
- $qi['fields'],
- $qi['conds'],
- __METHOD__
- );
-
- if ( $res ) {
- $result = $dbr->fetchObject( $res );
+ $deep = false;
+ if ( $result ) {
+ if ( isset( $result->b_namespace ) ) {
+ $deep = $result;
+ } else {
+ $dbr = wfGetDB( DB_REPLICA );
+ $qi = $this->reallyGetQueryInfo(
+ $result->namespace,
+ $result->title
+ );
+ $res = $dbr->select(
+ $qi['tables'],
+ $qi['fields'],
+ $qi['conds'],
+ __METHOD__
+ );
+
+ if ( $res ) {
+ $deep = $dbr->fetchObject( $res ) ?: false;
+ }