Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if classes are already loaded before attempting to autoload them. #442

Merged
merged 4 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: check if classes are loaded by a different autoloader
justlevine committed Aug 2, 2024
commit 0ff5d315c58581274e21ccb3381dc669fe1d2856
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.**
6 changes: 6 additions & 0 deletions src/Autoloader.php
Original file line number Diff line number Diff line change
@@ -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 );