Changeset 7711 for sites/trunk/browsehappy.com/public_html/functions.php
- Timestamp:
- 10/01/2018 08:29:33 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/browsehappy.com/public_html/functions.php
r7710 r7711 84 84 } 85 85 86 function browsehappy_fetch_version( $browser, $normalize = true ) {86 function browsehappy_fetch_version( $browser, $normalize = true, $rank = true ) { 87 87 88 88 $fragment = browsehappy_get_browser_data( $browser )->wikidata; … … 100 100 } 101 101 102 $rank_type = $rank ? 'PreferredRank' : 'NormalRank'; 103 $limit = $rank ? 'LIMIT 1' : ''; 104 102 105 // See https://github.com/WordPress/browsehappy/issues/37 103 106 $query = " … … 105 108 wd:{$fragment} p:P348 [ 106 109 ps:P348 ?version; 107 wikibase:rank wikibase: PreferredRank110 wikibase:rank wikibase:{$rank_type} 108 111 ]. 109 112 } 110 LIMIT 1113 {$limit} 111 114 "; 112 115 … … 128 131 empty( $data ) || 129 132 empty( $data->results ) || 130 ! is_array( $data->results->bindings ) || 133 ! is_array( $data->results->bindings ) 134 ) { 135 return false; 136 } 137 138 if ( 131 139 empty( $data->results->bindings[0] ) || 132 140 empty( $data->results->bindings[0]->version ) || 133 141 empty( $data->results->bindings[0]->version->value ) 134 142 ) { 135 return false; 143 if ( $rank ) { 144 return browsehappy_fetch_version( $browser, $normalize, false ); 145 } else { 146 return false; 147 } 148 } 149 150 if ( ! $rank ) { 151 usort( $data->results->bindings, function( $a, $b ) { 152 return strcmp( $b->version->value, $a->version->value ); 153 } ); 136 154 } 137 155
Note: See TracChangeset
for help on using the changeset viewer.