ActionScheduler_ScheduleDeserializer::scan_object_graph │ private │ WC 1.0

Walk the parsed graph once, recording unexpected (placeholder) classes and guarding traversal.

Objects whose class was outside the safe set are __PHP_Incomplete_Class placeholders; their original names are collected into $this->potential_offenders (the root is excluded — it is tracked separately as $this->outer_class). Real objects are trusted and only recursed into so a placeholder nested inside one is still found. A tampered blob can decode (via r:/R: references) into a self-referential or extremely deep graph, so visited objects are tracked to short-circuit cycles and shared references, and recursion depth is capped.

Метод класса: ActionScheduler_ScheduleDeserializer{}

Хуков нет.

Возвращает

bool. True if the value was fully walked; false if it was too deep to vet safely.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->scan_object_graph( $value, $is_root, $depth ): bool;
$value(разное) (обязательный)
The value to walk (object, array, or scalar).
$is_root(true|false) (обязательный)
Whether $value is the outermost object (excluded from $this->potential_offenders).
$depth(int) (обязательный)
Current recursion depth.

Код ActionScheduler_ScheduleDeserializer::scan_object_graph() WC 11.2.2

private function scan_object_graph( $value, bool $is_root, int $depth ): bool {
	if ( $depth > self::MAX_GRAPH_DEPTH ) {
		return false;
	}

	if ( is_object( $value ) ) {
		$object_id = spl_object_id( $value );
		if ( isset( $this->seen[ $object_id ] ) ) {
			return true; // Already walked (cycle or shared reference); nothing new to collect.
		}
		$this->seen[ $object_id ] = true;

		$is_placeholder = $value instanceof __PHP_Incomplete_Class;
		if ( $is_placeholder && ! $is_root ) {
			$this->potential_offenders[] = $this->class_name_of( $value );
		}

		foreach ( (array) $value as $key => $child ) {
			if ( $is_placeholder && '__PHP_Incomplete_Class_Name' === $key ) {
				continue;
			}
			if ( ! $this->scan_object_graph( $child, false, $depth + 1 ) ) {
				return false;
			}
		}

		return true;
	}

	if ( is_array( $value ) ) {
		foreach ( $value as $child ) {
			if ( ! $this->scan_object_graph( $child, false, $depth + 1 ) ) {
				return false;
			}
		}
	}

	return true;
}