Skip to content

Commit 3773ba4

Browse files
committed
Compatibility patch.
Changelog excerpt: - Addressed a potential compatibility problem with some specific kinds of symlinked installations.
1 parent 6e35902 commit 3773ba4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
77
### v3.0.1
88

99
[2020.07.31; Maikuolan]: Improved the way that the (generated by ...) notice, displayed at the footer of HTML pages, is rendered.
10+
11+
[2020.08.05; Maikuolan]: Addressed a potential compatibility problem with some specific kinds of symlinked installations.

src/Loader.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: The loader (last modified: 2020.07.20).
11+
* This file: The loader (last modified: 2020.08.05).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -213,9 +213,20 @@ public function __construct(
213213
$VendorPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor';
214214
}
215215

216-
/** Generate exception if the vendor directory doesn't exist or isn't readable. */
216+
/** The specified vendor directory doesn't exist or isn't readable. */
217217
if (!is_dir($VendorPath) || !is_readable($VendorPath)) {
218-
throw new \Exception('Vendor directory is undefined or unreadable.');
218+
if (isset($_SERVER['DOCUMENT_ROOT'], $_SERVER['SCRIPT_NAME'])) {
219+
/** Safeguard for symlinked installations. */
220+
$VendorPath = $this->buildPath(dirname($_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']) . DIRECTORY_SEPARATOR . 'vendor', false);
221+
222+
/** Eep.. Still not working. Generate exception. */
223+
if (!is_dir($VendorPath) || !is_readable($VendorPath)) {
224+
throw new \Exception('Vendor directory is undefined or unreadable.');
225+
}
226+
} else {
227+
/** Further safeguards not possible. Generate exception. */
228+
throw new \Exception('Vendor directory is undefined or unreadable.');
229+
}
219230
}
220231

221232
/** Prepare the phpMussel version identifier. */

0 commit comments

Comments
 (0)