Ticket #36199: 36199-copyarray.patch
File 36199-copyarray.patch, 5.2 KB (added by , 9 years ago) |
---|
-
src/wp-includes/plugin.php
209 209 } 210 210 211 211 if ( !isset($wp_filter[$tag]) ) { 212 if ( isset($wp_filter['all']) ) 212 if ( isset($wp_filter['all']) ) { 213 213 array_pop($wp_current_filter); 214 } 214 215 return $value; 215 216 } 216 217 217 if ( !isset($wp_filter['all']) ) 218 if ( !isset($wp_filter['all']) ) { 218 219 $wp_current_filter[] = $tag; 220 } 219 221 220 222 // Sort. 221 223 if ( !isset( $merged_filters[ $tag ] ) ) { … … 223 225 $merged_filters[ $tag ] = true; 224 226 } 225 227 226 reset( $wp_filter[ $tag ] ); 228 // Copy for iteration 229 $hooks = $wp_filter[ $tag ]; 227 230 228 if ( empty($args) ) 231 reset( $hooks ); 232 233 if ( empty($args) ) { 229 234 $args = func_get_args(); 235 } 230 236 231 237 do { 232 foreach ( (array) current($ wp_filter[$tag]) as $the_ )238 foreach ( (array) current($hooks) as $the_ ) { 233 239 if ( !is_null($the_['function']) ){ 234 240 $args[1] = $value; 235 241 $value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); 236 242 } 243 } 237 244 238 } while ( next($ wp_filter[$tag]) !== false );245 } while ( next($hooks) !== false ); 239 246 240 247 array_pop( $wp_current_filter ); 241 248 … … 269 276 } 270 277 271 278 if ( !isset($wp_filter[$tag]) ) { 272 if ( isset($wp_filter['all']) ) 279 if ( isset($wp_filter['all']) ) { 273 280 array_pop($wp_current_filter); 281 } 274 282 return $args[0]; 275 283 } 276 284 277 if ( !isset($wp_filter['all']) ) 285 if ( !isset($wp_filter['all']) ) { 278 286 $wp_current_filter[] = $tag; 287 } 279 288 280 289 // Sort 281 290 if ( !isset( $merged_filters[ $tag ] ) ) { … … 283 292 $merged_filters[ $tag ] = true; 284 293 } 285 294 286 reset( $wp_filter[ $tag ] ); 295 // Copy for iteration 296 $hooks = $wp_filter[ $tag ]; 287 297 298 reset( $hooks ); 299 288 300 do { 289 foreach ( (array) current($ wp_filter[$tag]) as $the_ )290 if ( !is_null($the_['function']) ) 301 foreach ( (array) current($hooks) as $the_ ) { 302 if ( !is_null($the_['function']) ) { 291 303 $args[0] = call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 304 } 305 } 306 } while ( next($hooks) !== false ); 292 307 293 } while ( next($wp_filter[$tag]) !== false );294 295 308 array_pop( $wp_current_filter ); 296 309 297 310 return $args[0]; … … 482 495 function do_action($tag, $arg = '') { 483 496 global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; 484 497 485 if ( ! isset($wp_actions[$tag]) ) 498 if ( ! isset($wp_actions[$tag]) ) { 486 499 $wp_actions[$tag] = 1; 487 else500 } else { 488 501 ++$wp_actions[$tag]; 502 } 489 503 490 504 // Do 'all' actions first 491 505 if ( isset($wp_filter['all']) ) { … … 495 509 } 496 510 497 511 if ( !isset($wp_filter[$tag]) ) { 498 if ( isset($wp_filter['all']) ) 512 if ( isset($wp_filter['all']) ) { 499 513 array_pop($wp_current_filter); 514 } 500 515 return; 501 516 } 502 517 503 if ( !isset($wp_filter['all']) ) 518 if ( !isset($wp_filter['all']) ) { 504 519 $wp_current_filter[] = $tag; 520 } 505 521 506 522 $args = array(); 507 if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)523 if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) { // array(&$this) 508 524 $args[] =& $arg[0]; 509 else525 } else { 510 526 $args[] = $arg; 511 for ( $a = 2, $num = func_num_args(); $a < $num; $a++ ) 527 } 528 529 for ( $a = 2, $num = func_num_args(); $a < $num; $a++ ) { 512 530 $args[] = func_get_arg($a); 531 } 513 532 514 533 // Sort 515 534 if ( !isset( $merged_filters[ $tag ] ) ) { … … 517 536 $merged_filters[ $tag ] = true; 518 537 } 519 538 520 reset( $wp_filter[ $tag ] ); 539 // Copy for iteration 540 $hooks = $wp_filter[ $tag ]; 521 541 542 reset( $hooks ); 543 522 544 do { 523 foreach ( (array) current($ wp_filter[$tag]) as $the_ )524 if ( !is_null($the_['function']) ) 545 foreach ( (array) current($hooks) as $the_ ) { 546 if ( !is_null($the_['function']) ) { 525 547 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 548 } 549 } 550 } while ( next($hooks) !== false ); 526 551 527 } while ( next($wp_filter[$tag]) !== false );528 529 552 array_pop($wp_current_filter); 530 553 } 531 554 … … 566 589 function do_action_ref_array($tag, $args) { 567 590 global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter; 568 591 569 if ( ! isset($wp_actions[$tag]) ) 592 if ( ! isset($wp_actions[$tag]) ) { 570 593 $wp_actions[$tag] = 1; 571 else594 } else { 572 595 ++$wp_actions[$tag]; 596 } 573 597 574 598 // Do 'all' actions first 575 599 if ( isset($wp_filter['all']) ) { … … 579 603 } 580 604 581 605 if ( !isset($wp_filter[$tag]) ) { 582 if ( isset($wp_filter['all']) ) 606 if ( isset($wp_filter['all']) ) { 583 607 array_pop($wp_current_filter); 608 } 584 609 return; 585 610 } 586 611 587 if ( !isset($wp_filter['all']) ) 612 if ( !isset($wp_filter['all']) ) { 588 613 $wp_current_filter[] = $tag; 614 } 589 615 590 616 // Sort 591 617 if ( !isset( $merged_filters[ $tag ] ) ) { … … 593 619 $merged_filters[ $tag ] = true; 594 620 } 595 621 596 reset( $wp_filter[ $tag ] ); 622 // Copy for iteration 623 $hooks = $wp_filter[ $tag ]; 597 624 625 reset( $hooks ); 626 598 627 do { 599 foreach ( (array) current($ wp_filter[$tag]) as $the_ )600 if ( !is_null($the_['function']) ) 628 foreach ( (array) current($hooks) as $the_ ) { 629 if ( !is_null($the_['function']) ) { 601 630 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 631 } 632 } 633 } while ( next($hooks) !== false ); 602 634 603 } while ( next($wp_filter[$tag]) !== false );604 605 635 array_pop($wp_current_filter); 606 636 } 607 637