Changeset 47359
- Timestamp:
- 02/25/2020 01:40:52 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class.wp-dependencies.php
r47170 r47359 75 75 */ 76 76 public $group = 0; 77 78 /** 79 * Cached lookup array of flattened queued items and dependencies. 80 * 81 * @since 5.4.0 82 * @var array 83 */ 84 private $all_queued_deps; 77 85 78 86 /** … … 303 311 foreach ( (array) $handles as $handle ) { 304 312 $handle = explode( '?', $handle ); 305 if ( ! in_array( $handle[0], $this->queue ) && isset( $this->registered[ $handle[0] ] ) ) { 313 314 if ( ! in_array( $handle[0], $this->queue, true ) && isset( $this->registered[ $handle[0] ] ) ) { 306 315 $this->queue[] = $handle[0]; 316 317 // Reset all dependencies so they must be recalculated in recurse_deps(). 318 $this->all_queued_deps = null; 319 307 320 if ( isset( $handle[1] ) ) { 308 321 $this->args[ $handle[0] ] = $handle[1]; … … 326 339 foreach ( (array) $handles as $handle ) { 327 340 $handle = explode( '?', $handle ); 328 $key = array_search( $handle[0], $this->queue ); 341 $key = array_search( $handle[0], $this->queue, true ); 342 329 343 if ( false !== $key ) { 344 // Reset all dependencies so they must be recalculated in recurse_deps(). 345 $this->all_queued_deps = null; 346 330 347 unset( $this->queue[ $key ] ); 331 348 unset( $this->args[ $handle[0] ] ); … … 335 352 336 353 /** 337 * Recursively search the passed dependency tree for $handle 354 * Recursively search the passed dependency tree for $handle. 338 355 * 339 356 * @since 4.0.0 … … 344 361 */ 345 362 protected function recurse_deps( $queue, $handle ) { 346 foreach ( $queue as $queued ) { 347 if ( ! isset( $this->registered[ $queued ] ) ) { 348 continue; 349 } 350 351 if ( in_array( $handle, $this->registered[ $queued ]->deps ) ) { 352 return true; 353 } elseif ( $this->recurse_deps( $this->registered[ $queued ]->deps, $handle ) ) { 354 return true; 355 } 356 } 357 358 return false; 363 if ( isset( $this->all_queued_deps ) ) { 364 return isset( $this->all_queued_deps[ $handle ] ); 365 } 366 367 $all_deps = array_fill_keys( $queue, true ); 368 $queues = array(); 369 $done = array(); 370 371 while ( $queue ) { 372 foreach ( $queue as $queued ) { 373 if ( ! isset( $done[ $queued ] ) && isset( $this->registered[ $queued ] ) ) { 374 $deps = $this->registered[ $queued ]->deps; 375 if ( $deps ) { 376 $all_deps += array_fill_keys( $deps, true ); 377 array_push( $queues, $deps ); 378 } 379 $done[ $queued ] = true; 380 } 381 } 382 $queue = array_pop( $queues ); 383 } 384 385 $this->all_queued_deps = $all_deps; 386 387 return isset( $this->all_queued_deps[ $handle ] ); 359 388 } 360 389 … … 380 409 case 'enqueued': 381 410 case 'queue': 382 if ( in_array( $handle, $this->queue ) ) {411 if ( in_array( $handle, $this->queue, true ) ) { 383 412 return true; 384 413 } … … 387 416 case 'to_do': 388 417 case 'to_print': // Back compat. 389 return in_array( $handle, $this->to_do );418 return in_array( $handle, $this->to_do, true ); 390 419 391 420 case 'done': 392 421 case 'printed': // Back compat. 393 return in_array( $handle, $this->done );422 return in_array( $handle, $this->done, true ); 394 423 } 395 424 return false;
Note: See TracChangeset
for help on using the changeset viewer.