Skip to content

SplFileInfo empty getBasename with more than on slash after PHP 8.1.1 #11338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
deniskulygin opened this issue May 29, 2023 · 1 comment · Fixed by ThePHPF/thephp.foundation#90

Comments

@deniskulygin
Copy link

Description

The following code:

<?php

$file = new \SplFileInfo('/dir/anotherdir/basedir//');
var_dump($file->getBasename());

https://3v4l.org/vAh4f#v8.1.0

Resulted in this output:

string(0) ""

But I expected this output instead:

string(7) "basedir"

Before PHP 8.1.1 you got basename even with 2 slashes.

PHP Version

8.1.1

Operating System

No response

@nielsdos
Copy link
Member

nielsdos commented May 29, 2023

I think it's coming up with the empty string because it thinks the file path is between the two slashes...
I'll run a bisect.
EDIT: first bad commit is 13e4ce3

@nielsdos nielsdos self-assigned this May 29, 2023
nielsdos added a commit to nielsdos/php-src that referenced this issue May 29, 2023
nielsdos added a commit to nielsdos/php-src that referenced this issue May 29, 2023
nielsdos added a commit that referenced this issue May 30, 2023
* PHP-8.1:
  Fix DOMElement::append() and DOMElement::prepend() hierarchy checks
  Fix spec compliance error for DOMDocument::getElementsByTagNameNS
  Fix GH-11336: php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked
  Fix GH-11338: SplFileInfo empty getBasename with more than one slash
nielsdos added a commit that referenced this issue May 30, 2023
* PHP-8.2:
  Fix DOMElement::append() and DOMElement::prepend() hierarchy checks
  Fix spec compliance error for DOMDocument::getElementsByTagNameNS
  Fix GH-11336: php still tries to unlock the shared memory ZendSem with opcache.file_cache_only=1 but it was never locked
  Fix GH-11338: SplFileInfo empty getBasename with more than one slash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants