⚲
Project
General
Profile
Sign in
Home
Projects
Help
Search
:
TYPO3 Core
All Projects
TYPO3 Core
Overview
Activity
Roadmap
Issues
Repository
Download (1.5 KB)
Task #52668
» chmodTest.php
Michiel Roos
, 2014-01-13 10:51
<?php
/**
* Here's a little test to figure out how PHP handles this whole chmod
* situation. We try both string values and plain int values to set the
* access controls.
*
* It turns out that mkdir does not respect the sticky bit. An extra chmod is
* needed to add it. Not even ignoring the umask helps. Is this a PHP bug?
*/
$testPath
=
'/Users/michiel/wb/WebRoot/6.2.master.workbench.local/fileadmin/test/'
;
$tests
=
array
(
'string'
=>
array
(
'file'
=>
octdec
(
'0664'
),
'directory'
=>
octdec
(
'02775'
)
),
'integer'
=>
array
(
'file'
=>
0664
,
'directory'
=>
02775
)
);
$expected
=
array
(
'file'
=>
'100664'
,
'directory'
=>
'42775'
);
var_dump
(
$tests
);
foreach
(
$tests
as
$type
=>
$testData
)
{
echo
'<h3>'
.
$type
.
' Mode test</h3><br/>'
;
foreach
(
$testData
as
$nodeType
=>
$mode
)
{
echo
'Mode test using '
.
$nodeType
.
'. Outcome should be '
.
$expected
[
$nodeType
]
.
'<br/>'
;
if
(
$nodeType
===
'file'
)
{
echo
'Plain chmod.<br/>'
;
$nodename
=
$testPath
.
$type
.
'-'
.
$nodeType
.
'-plain.txt'
;
file_put_contents
(
$nodename
,
'lala'
);
chmod
(
$nodename
,
$mode
);
var_dump
(
decoct
(
fileperms
(
$nodename
)));
}
else
{
echo
'Plain mkdir.<br/>'
;
$nodename
=
$testPath
.
$type
.
'-'
.
$nodeType
.
'-plain'
;
mkdir
(
$nodename
,
$mode
);
var_dump
(
decoct
(
fileperms
(
$nodename
)));
echo
'Using mkdir and extra chmod.<br/>'
;
$nodename
=
$testPath
.
$type
.
'-'
.
$nodeType
.
'-extra-chmod'
;
mkdir
(
$nodename
,
$mode
);
chmod
(
$nodename
,
$mode
);
var_dump
(
decoct
(
fileperms
(
$nodename
)));
}
}
}
« Previous
1
2
Next »
(2-2/2)
Loading...