Skip to content

Commit

Permalink
DEBUG; WILL BE REBASED10
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Feb 21, 2018
1 parent 79856bc commit 439a233
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
11 changes: 0 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ matrix:
include:
- php: "5.3"
env: WP_VERSION=latest DEV_LIB_SKIP=phpcs
- php: "5.3"
env: WP_VERSION=4.7 DEV_LIB_SKIP=phpcs
- php: "5.4"
env: WP_VERSION=latest
- php: "5.4"
env: WP_VERSION=4.7
- php: "7.0"
env: WP_VERSION=latest
- php: "7.0"
env: WP_VERSION=4.7
# 7.1 / latest already included above as first build.
- php: "7.1"
env: WP_VERSION=4.7

Expand Down
50 changes: 31 additions & 19 deletions includes/utils/class-amp-validation-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,20 @@ public static function callback_wrappers() {
if ( ! self::do_validate_front_end() ) {
return;
}
$iterations = 0;
foreach ( $wp_filter as $filter_tag => $wp_hook ) {
if ( 'query' === $filter_tag ) {
continue;
}
foreach ( $wp_hook->callbacks as $priority => $callbacks ) {
$iterations++;
$hook_callbacks = $wp_hook->callbacks;
foreach ( $hook_callbacks as $priority => $callbacks ) {
$iterations++;
foreach ( $callbacks as $callback ) {
$iterations++;
if ( $iterations > 10000 ) {
die( 'TOO MANY ITERATIONS!!' );
}
$function = $callback['function'];
$plugin = self::get_plugin( $function );
if ( isset( $plugin ) ) {
Expand All @@ -319,29 +327,33 @@ public static function callback_wrappers() {
* @return string|null $plugin The plugin to which the callback belongs, or null.
*/
public static function get_plugin( $callback ) {
if ( is_string( $callback ) && is_callable( $callback ) ) {
// The $callback is a function or static method.
$exploded_callback = explode( '::', $callback );
if ( count( $exploded_callback ) > 1 ) {
$reflection = new ReflectionClass( $exploded_callback[0] );
} else {
try {
if ( is_string( $callback ) && is_callable( $callback ) ) {
// The $callback is a function or static method.
$exploded_callback = explode( '::', $callback );
if ( count( $exploded_callback ) > 1 ) {
$reflection = new ReflectionClass( $exploded_callback[0] );
} else {
$reflection = new ReflectionFunction( $callback );
}
} elseif ( is_array( $callback ) && isset( $callback[0], $callback[1] ) && method_exists( $callback[0], $callback[1] ) ) {
// The $callback is a method.
$reflection = new ReflectionClass( $callback[0] );
} elseif ( is_object( $callback ) && ( 'Closure' === get_class( $callback ) ) ) {
$reflection = new ReflectionFunction( $callback );
}
} elseif ( is_array( $callback ) && isset( $callback[0], $callback[1] ) && method_exists( $callback[0], $callback[1] ) ) {
// The $callback is a method.
$reflection = new ReflectionClass( $callback[0] );
} elseif ( is_object( $callback ) && ( 'Closure' === get_class( $callback ) ) ) {
$reflection = new ReflectionFunction( $callback );
}

$file = isset( $reflection ) ? $reflection->getFileName() : null;
if ( ! isset( $file ) ) {
$file = isset( $reflection ) ? $reflection->getFileName() : null;
if ( ! isset( $file ) ) {
return null;
}
$source_data = self::get_source( $file );
if ( 'plugins' === $source_data['type'] ) {
return $source_data['source'];
}
} catch ( Exception $e ) {
return null;
}
$source_data = self::get_source( $file );
if ( 'plugins' === $source_data['type'] ) {
return $source_data['source'];
}
return null;
}

Expand Down

0 comments on commit 439a233

Please sign in to comment.