xref: /PHP-7.4/ext/standard/tests/file/bug75679.phpt (revision 26dfce7f)
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==DONE==
28--CLEAN--
29<?php
30$d = __DIR__;
31$Files2Report =
32 [
33  str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_259_characters_long_', 100, '_') . '/', 1), 259, '_') => [],
34  str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_260_characters_long_', 100, '_') . '/', 1), 260, '_') => [],
35  str_pad ($d . '/' . str_repeat (str_pad ('bug75679_path_261_characters_long_', 100, '_') . '/', 1), 261, '_') => [],
36 ];
37foreach ($Files2Report as $file => &$Report)
38{
39	if (is_file($file)) {
40		unlink($file);
41	}
42
43	$d1 = dirname($file);
44	while ($d1 != $d) {
45		rmdir($d1);
46		$d1 = dirname($d1);
47	}
48}
49?>
50--EXPECT--
51Array
52(
53    [strlen] => 259
54    [result] => ok
55)
56Array
57(
58    [strlen] => 260
59    [result] => ok
60)
61Array
62(
63    [strlen] => 261
64    [result] => ok
65)
66==DONE==
67