Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6107886
TableStatsProvider.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
TableStatsProvider.php
View Options
<?php
namespace
MediaWiki\RecentChanges\ChangesListQuery
;
use
Wikimedia\Rdbms\IConnectionProvider
;
/**
* Cache and provide min/max ID and "size" (ID delta) of a table
*
* @since 1.45
*/
class
TableStatsProvider
{
private
?
int
$minId
;
private
?
int
$maxId
;
private
bool
$loaded
=
false
;
public
function
__construct
(
private
IConnectionProvider
$connectionProvider
,
private
string
$tableName
,
private
string
$idField
,
)
{
}
/**
* Estimate the number of rows in the table, using the difference of maximum
* and minimum primary keys.
*
* @return int
*/
public
function
getIdDelta
()
{
$this
->
loadStats
();
return
$this
->
maxId
===
null
?
0
:
$this
->
maxId
-
$this
->
minId
;
}
/**
* Get the minimum ID
*
* @return int|null
*/
public
function
getMinId
()
{
$this
->
loadStats
();
return
$this
->
minId
;
}
/**
* Get the maximum ID
*
* @return int|null
*/
public
function
getMaxId
()
{
$this
->
loadStats
();
return
$this
->
maxId
;
}
private
function
loadStats
()
{
if
(
$this
->
loaded
)
{
return
;
}
$this
->
loaded
=
true
;
$info
=
$this
->
connectionProvider
->
getReplicaDatabase
()
->
newSelectQueryBuilder
()
->
select
(
[
'min_id'
=>
"MIN({$this->idField})"
,
'max_id'
=>
"MAX({$this->idField})"
,
]
)
->
from
(
$this
->
tableName
)
->
caller
(
__METHOD__
)
->
fetchRow
();
if
(
$info
)
{
$this
->
minId
=
(
int
)
$info
->
min_id
;
$this
->
maxId
=
(
int
)
$info
->
max_id
;
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 6 2026, 15:06 (6 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
22/61/02cd13eaeeae228e1e03f74b0285
Default Alt Text
TableStatsProvider.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment