Skip to content

Commit e886e66

Browse files
committed
Bug-fix.
Changelog excerpt: - buildPath could potentially trigger warnings when open_basedir is defined, causing logging, among various other internal file operations, to fail (related to PHP bug 69240); Fixed.
1 parent ebde70b commit e886e66

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Changelog.md

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

4545
[2021.03.11; Maikuolan]: Added some missing return type declarations.
46+
47+
[2021.04.19; Bug-fix; Maikuolan]: BuildPath could potentially trigger warnings when open_basedir is defined, causing logging, among various other internal file operations, to fail (related to PHP bug 69240); Fixed.

src/Loader.php

Lines changed: 12 additions & 4 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: 2021.03.11).
11+
* This file: The loader (last modified: 2021.04.19).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -737,14 +737,17 @@ public function pseudonymiseIP(string $IP): string
737737
*/
738738
public function buildPath(string $Path, bool $PointsToFile = true): string
739739
{
740-
/** Guard. */
741-
if (!$Path) {
740+
/** Input guard. */
741+
if (!strlen($Path)) {
742742
return '';
743743
}
744744

745745
/** Applies time/date replacements. */
746746
$Path = $this->timeFormat($this->Time, $Path);
747747

748+
/** We'll skip is_dir/mkdir calls if open_basedir is populated (to avoid PHP bug #69240). */
749+
$Restrictions = strlen(ini_get('open_basedir')) > 0;
750+
748751
/** Split path into steps. */
749752
$Steps = preg_split('~[\\\/]~', $Path, -1, PREG_SPLIT_NO_EMPTY);
750753

@@ -761,11 +764,16 @@ public function buildPath(string $Path, bool $PointsToFile = true): string
761764
if (preg_match('~^\.+$~', $Step)) {
762765
continue;
763766
}
764-
if (!is_dir($Rebuilt) && !mkdir($Rebuilt)) {
767+
if (!$Restrictions && !is_dir($Rebuilt) && !mkdir($Rebuilt)) {
765768
return '';
766769
}
767770
}
768771

772+
/** Ensure rebuilt is defined. */
773+
if (!isset($Rebuilt)) {
774+
$Rebuilt = '';
775+
}
776+
769777
/** Return an empty string if the final rebuilt path isn't writable. */
770778
if (!is_writable($Rebuilt)) {
771779
return '';

0 commit comments

Comments
 (0)