Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5952009
SqliteUtils.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
SqliteUtils.php
View Options
<?php
namespace
MediaWiki\Installer\Task
;
use
MediaWiki\Status\Status
;
/**
* @internal For use by the installer
*/
class
SqliteUtils
{
/**
* Check if the data directory is writable or can be created
* @param string $dir Path to the data directory
* @return Status Return fatal Status if $dir un-writable or no permission to create a directory
*/
public
function
checkDataDir
(
$dir
):
Status
{
if
(
is_dir
(
$dir
)
)
{
if
(
!
is_readable
(
$dir
)
||
!
is_writable
(
$dir
)
)
{
return
Status
::
newFatal
(
'config-sqlite-dir-unwritable'
,
$dir
);
}
}
elseif
(
!
is_writable
(
dirname
(
$dir
)
)
)
{
// Check the parent directory if $dir not exists
$webserverGroup
=
$this
->
maybeGetWebserverPrimaryGroup
();
if
(
$webserverGroup
!==
null
)
{
return
Status
::
newFatal
(
'config-sqlite-parent-unwritable-group'
,
$dir
,
dirname
(
$dir
),
basename
(
$dir
),
$webserverGroup
);
}
return
Status
::
newFatal
(
'config-sqlite-parent-unwritable-nogroup'
,
$dir
,
dirname
(
$dir
),
basename
(
$dir
)
);
}
return
Status
::
newGood
();
}
/**
* On POSIX systems return the primary group of the webserver we're running under.
* On other systems just returns null.
*
* @return string|null
*/
private
function
maybeGetWebserverPrimaryGroup
()
{
if
(
!
function_exists
(
'posix_getegid'
)
||
!
function_exists
(
'posix_getpwuid'
)
)
{
# I don't know this, this isn't UNIX.
return
null
;
}
# posix_getegid() *not* getmygid() because we want the group of the webserver,
# not whoever owns the current script.
$gid
=
posix_getegid
();
return
posix_getpwuid
(
$gid
)[
'name'
]
??
null
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 3 2026, 01:11 (4 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
30/db/d508376dbc0b8cf26b5cf5a65ca3
Default Alt Text
SqliteUtils.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment