Skip to content

Commit

Permalink
fix: check if classes are loaded by a different autoloader
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Aug 2, 2024
1 parent ef59846 commit 0ff5d31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

- fix: Check if classes are loaded by a different autoloader before attempting to autoload them.

## v0.13.0

**:warning: This release contains multiple breaking changes.**
Expand Down
6 changes: 6 additions & 0 deletions src/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ public static function autoload(): bool {
return true;
}

// If the autoloader has already been loaded, then return true.
if ( self::$is_loaded ) {
return self::$is_loaded;
}

// If the main class has already been loaded, then they must be using a different autoloader.
if ( class_exists( 'WPGraphQL\GF\GF' ) ) {
return true;
}

$autoloader = dirname( __DIR__ ) . '/vendor/autoload.php';
self::$is_loaded = self::require_autoloader( $autoloader );

Expand Down

0 comments on commit 0ff5d31

Please sign in to comment.