Skip to content

Commit 3e2993d

Browse files
committed
add suggested fix from copilot
1 parent 28d4f2e commit 3e2993d

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
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: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Kint\Kint;
2525
use Kint\Renderer\CliRenderer;
2626
use Kint\Renderer\RichRenderer;
27+
use Throwable;
2728

2829
/**
2930
* An autoloader that uses both PSR4 autoloading, and traditional classmaps.
@@ -146,16 +147,24 @@ private function loadComposerAutoloader(Modules $modules): void
146147
define('VENDORPATH', dirname($this->composerPath) . DIRECTORY_SEPARATOR);
147148
}
148149

149-
/** @var ClassLoader $composer */
150-
$composer = include $this->composerPath;
150+
try {
151+
/** @var ClassLoader $composer */
152+
$composer = include $this->composerPath;
151153

152-
// Should we load through Composer's namespaces, also?
153-
if ($modules->discoverInComposer) {
154-
$composerPackages = $modules->composerPackages;
155-
$this->loadComposerNamespaces($composer, $composerPackages ?? []);
156-
}
154+
// Should we load through Composer's namespaces, also?
155+
if ($modules->discoverInComposer) {
156+
$composerPackages = $modules->composerPackages;
157+
$this->loadComposerNamespaces($composer, $composerPackages ?? []);
158+
}
157159

158-
unset($composer);
160+
unset($composer);
161+
} catch (ConfigException $e) {
162+
// Re-throw configuration exceptions
163+
throw $e;
164+
} catch (Throwable) {
165+
// If Composer fails to load for other reasons, continue
166+
// The SPL autoloader will still work for CodeIgniter's own classes
167+
}
159168
}
160169

161170
/**
@@ -170,8 +179,8 @@ private function loadComposerAutoloader(Modules $modules): void
170179
*/
171180
public function register()
172181
{
173-
spl_autoload_register($this->loadClass(...), prepend: true);
174182
spl_autoload_register($this->loadClassmap(...), prepend: true);
183+
spl_autoload_register($this->loadClass(...), prepend: true);
175184

176185
foreach ($this->files as $file) {
177186
$this->includeFile($file);

0 commit comments

Comments
 (0)