Skip to content

Commit a8420b7

Browse files
committed
add suggested fix from copilot
1 parent 2c7002d commit a8420b7

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

.github/workflows/test-random-execution.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,6 @@ jobs:
177177
extensions: gd, curl, iconv, json, mbstring, openssl, sodium
178178
coverage: none
179179

180-
- name: Get composer cache directory
181-
id: composer-cache
182-
run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
183-
184-
- name: Cache composer dependencies
185-
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
186-
with:
187-
path: ${{ steps.composer-cache.outputs.COMPOSER_CACHE_FILES_DIR }}
188-
key: PHP_${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}
189-
restore-keys: |
190-
PHP_${{ matrix.php-version }}-
191-
192180
- name: Install project dependencies
193181
run: |
194182
composer config --global github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}

system/Autoloader/Autoloader.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Kint\Kint;
2626
use Kint\Renderer\CliRenderer;
2727
use Kint\Renderer\RichRenderer;
28+
use Throwable;
2829

2930
/**
3031
* An autoloader that uses both PSR4 autoloading, and traditional classmaps.
@@ -155,16 +156,24 @@ private function loadComposerAutoloader(Modules $modules): void
155156
define('VENDORPATH', dirname($this->composerPath) . DIRECTORY_SEPARATOR);
156157
}
157158

158-
/** @var ClassLoader $composer */
159-
$composer = include $this->composerPath;
159+
try {
160+
/** @var ClassLoader $composer */
161+
$composer = include $this->composerPath;
160162

161-
// Should we load through Composer's namespaces, also?
162-
if ($modules->discoverInComposer) {
163-
$composerPackages = $modules->composerPackages;
164-
$this->loadComposerNamespaces($composer, $composerPackages ?? []);
165-
}
163+
// Should we load through Composer's namespaces, also?
164+
if ($modules->discoverInComposer) {
165+
$composerPackages = $modules->composerPackages;
166+
$this->loadComposerNamespaces($composer, $composerPackages ?? []);
167+
}
166168

167-
unset($composer);
169+
unset($composer);
170+
} catch (ConfigException $e) {
171+
// Re-throw configuration exceptions
172+
throw $e;
173+
} catch (Throwable) {
174+
// If Composer fails to load for other reasons, continue
175+
// The SPL autoloader will still work for CodeIgniter's own classes
176+
}
168177
}
169178

170179
/**

0 commit comments

Comments
 (0)