Skip to content

Conversation

@phil-davis
Copy link
Contributor

@phil-davis phil-davis commented Jul 20, 2021

Description

PHP 7.4.21 checks open_basedir settings more exactly. Calls to file_exists can
emit log messages like "file_exists(): open_basedir restriction in effect" that
were not emitted by PHP 7.4.20.

This change fixes an incorrect file_exists check. The open_basedir message will
no longer be emitted in this case.

The PHP 7.4.21 changelog https://www.php.net/ChangeLog-7.php has a fix https://bugs.php.net/bug.php?id=76359
The code of that is https://github.com/php/php-src/pull/7024/files

But I don't see exactly how that change is causing open_basedir to start complaining now.

Related Issue

OP has confirmed that fix works for them: #39034 (comment)

How Has This Been Tested?

CI

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

Copy link
Contributor

@JammingBen JammingBen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me as \OC_App::getAppPath($app) . '/appinfo/routes.php' never evaluated to false.

@jvillafanez
Copy link
Member

Well, concatenating false with a string is something we should avoid anyway.

$routingFiles = [];
$appPath = \OC_App::getAppPath($app);
if ($appPath !== false) {
  if (\file_exists("{$appPath}/appinfo/routes.php")) {
    $routingFiles = [$app => $file];
  }
}

It seems better.

@phil-davis
Copy link
Contributor Author

phil-davis commented Jul 20, 2021

It seems better.

Yes, regardless of the "strange different behavior" of PHP 7.4.21 that caused this to be noticed, we should fix it anyway. The existing code was silly/wrong.

@phil-davis
Copy link
Contributor Author

I have looked through all the calls to OC_App::getAppPath. Most of them already have checks for return value of false. I added similar checks where they were missing.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

28.6% 28.6% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants