Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6098500
BooleanFieldCondition.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
BooleanFieldCondition.php
View Options
<?php
namespace
MediaWiki\RecentChanges\ChangesListQuery
;
use
Wikimedia\Rdbms\IReadableDatabase
;
/**
* A filter module which builds conditions for a boolean field.
*
* @since 1.45
*/
class
BooleanFieldCondition
extends
ChangesListConditionBase
{
/**
* @param string $fieldName
*/
public
function
__construct
(
private
$fieldName
)
{
}
/** @inheritDoc */
public
function
validateValue
(
$value
)
{
if
(
$value
!==
null
&&
!
is_bool
(
$value
)
)
{
throw
new
\InvalidArgumentException
(
"value for {$this->fieldName} must be bool or null"
);
}
return
$value
??
true
;
}
/** @inheritDoc */
public
function
evaluate
(
$row
,
$value
):
bool
{
return
(
bool
)
$row
->{
$this
->
fieldName
}
===
$value
;
}
/** @inheritDoc */
protected
function
prepareCapture
(
IReadableDatabase
$dbr
,
QueryBackend
$query
)
{
$query
->
fields
(
$this
->
fieldName
);
}
/** @inheritDoc */
public
function
prepareConds
(
IReadableDatabase
$dbr
,
QueryBackend
$query
)
{
$set
=
$this
->
getEnumValues
(
[
false
,
true
]
);
if
(
$set
===
null
)
{
return
;
}
elseif
(
$set
===
[
true
]
)
{
$query
->
where
(
$dbr
->
expr
(
$this
->
fieldName
,
'='
,
1
)
);
}
elseif
(
$set
===
[
false
]
)
{
$query
->
where
(
$dbr
->
expr
(
$this
->
fieldName
,
'='
,
0
)
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 6 2026, 06:05 (8 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
14/63/413d9e76089bcf539fc9268fdf40
Default Alt Text
BooleanFieldCondition.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment