xref: /PHP-8.2/ext/standard/tests/file/bug75679.phpt (revision a555cc0b)
1--TEST--
2Bug #75679 Path 260 character problem
3--FILE--
4<?php
5$d = __DIR__;
6$Files2Report =
7 [
8  str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_259_characters_long_', 100, '_') . '/', 1), 259, '_') => [],
9  str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_260_characters_long_', 100, '_') . '/', 1), 260, '_') => [],
10  str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_261_characters_long_', 100, '_') . '/', 1), 261, '_') => [],
11 ];
12foreach ($Files2Report as $file => &$Report)
13 {
14  $Report = ['strlen' => strlen ($file), 'result' => 'nok'];
15
16  if (! is_dir (dirname ($file))) mkdir (dirname ($file), 0777, true);
17  if (copy (__FILE__, $file) && is_file ($file))
18   {
19    $Report['result'] = 'ok';
20   }
21
22  print_r ($Report);
23 }
24
25
26?>
27--CLEAN--
28<?php
29$d = __DIR__;
30$Files2Report =
31 [
32  str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_259_characters_long_', 100, '_') . '/', 1), 259, '_') => [],
33  str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_260_characters_long_', 100, '_') . '/', 1), 260, '_') => [],
34  str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_261_characters_long_', 100, '_') . '/', 1), 261, '_') => [],
35 ];
36foreach ($Files2Report as $file => &$Report)
37{
38	if (is_file($file)) {
39		unlink($file);
40	}
41
42	$d1 = dirname($file);
43	while ($d1 != $d) {
44		rmdir($d1);
45		$d1 = dirname($d1);
46	}
47}
48?>
49--EXPECT--
50Array
51(
52    [strlen] => 259
53    [result] => ok
54)
55Array
56(
57    [strlen] => 260
58    [result] => ok
59)
60Array
61(
62    [strlen] => 261
63    [result] => ok
64)
65