File SqlBagOStuff.php
has 1141 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Object caching using a SQL database.
*
* This program is free software; you can redistribute it and/or modify
SqlBagOStuff
has 56 functions (exceeds 20 allowed). Consider refactoring. Open
class SqlBagOStuff extends MediumSpecificBagOStuff {
/** @var callable|null Injected function which returns a LoadBalancer */
protected $loadBalancerCallback;
/** @var ILoadBalancer|null */
protected $loadBalancer;
Function deleteObjectsExpiringBefore
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function deleteObjectsExpiringBefore(
$timestamp,
callable $progress = null,
$limit = INF,
string $tag = null
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method deleteServerObjectsExpiringBefore
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function deleteServerObjectsExpiringBefore(
IDatabase $db,
$timestamp,
$limit,
&$keysDeletedCount = 0,
Function modifyTableSpecificBlobsForChangeTTL
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function modifyTableSpecificBlobsForChangeTTL(
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function deleteServerObjectsExpiringBefore
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private function deleteServerObjectsExpiringBefore(
IDatabase $db,
$timestamp,
$limit,
&$keysDeletedCount = 0,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method modifyTableSpecificBlobsForChangeTTL
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function modifyTableSpecificBlobsForChangeTTL(
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
Method fetchBlobs
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function fetchBlobs( array $keys, bool $getCasToken = false ) {
/** @noinspection PhpUnusedLocalVariableInspection */
$silenceScope = $this->silenceTransactionProfiler();
// Initialize order-preserved per-key results; set values for live keys below
Function fetchBlobs
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function fetchBlobs( array $keys, bool $getCasToken = false ) {
/** @noinspection PhpUnusedLocalVariableInspection */
$silenceScope = $this->silenceTransactionProfiler();
// Initialize order-preserved per-key results; set values for live keys below
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method modifyTableSpecificBlobsForCas
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function modifyTableSpecificBlobsForCas(
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
Method deleteObjectsExpiringBefore
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function deleteObjectsExpiringBefore(
$timestamp,
callable $progress = null,
$limit = INF,
string $tag = null
Function modifyBlobs
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function modifyBlobs(
callable $tableWriteCallback,
float $mtime,
array $argsByKey,
&$resByKey = []
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method modifyTableSpecificBlobsForIncrInit
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function modifyTableSpecificBlobsForIncrInit(
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
Method modifyBlobs
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function modifyBlobs(
callable $tableWriteCallback,
float $mtime,
array $argsByKey,
&$resByKey = []
Method modifyTableSpecificBlobsForAdd
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function modifyTableSpecificBlobsForAdd(
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
Method __construct
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( $params ) {
parent::__construct( $params );
if ( isset( $params['servers'] ) || isset( $params['server'] ) ) {
// Configuration uses a direct list of servers.
Method modifyTableSpecificBlobsForSet
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function modifyTableSpecificBlobsForSet(
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
Function modifyTableSpecificBlobsForIncrInit
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function modifyTableSpecificBlobsForIncrInit(
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function handleDBError
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function handleDBError( DBError $exception, $shardIndex ) {
if ( !$this->useLB && $exception instanceof DBConnectionError ) {
unset( $this->conns[$shardIndex] ); // bug T103435
$now = $this->getCurrentTime();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function modifyTableSpecificBlobsForCas
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function modifyTableSpecificBlobsForCas(
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __construct
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( $params ) {
parent::__construct( $params );
if ( isset( $params['servers'] ) || isset( $params['server'] ) ) {
// Configuration uses a direct list of servers.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method buildIncrUpsertSet
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
int $step,
int $init,
int $expiry,
string $mt,
Method buildUpsertRow
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
$key,
$serialValue,
int $expiry,
string $mt
Method modifyTableSpecificBlobsForAdd
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
array &$resByKey
Method modifyTableSpecificBlobsForIncrInitAsync
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
array &$resByKey
Method doCas
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function doCas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
Method doIncrWithInit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function doIncrWithInit( $key, $exptime, $step, $init, $flags ) {
Method modifyTableSpecificBlobsForIncrInit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
array &$resByKey
Method deleteServerObjectsExpiringBefore
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
$timestamp,
$limit,
&$keysDeletedCount = 0,
array $progress = null
Method modifyTableSpecificBlobsForDelete
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
array &$resByKey
Method modifyTableSpecificBlobsForChangeTTL
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
array &$resByKey
Method modifyTableSpecificBlobsForSet
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
array &$resByKey
Method modifyTableSpecificBlobsForCas
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
array &$resByKey
Function doGetMulti
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function doGetMulti( array $keys, $flags = 0 ) {
$result = [];
$valueSizeByKey = [];
$dataByKey = $this->fetchBlobs( $keys );
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getKeyLocation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getKeyLocation( $key ) {
if ( $this->useLB ) {
// LoadBalancer based configuration
$shardIndex = 0;
} else {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function addCasTokenFields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function addCasTokenFields( IDatabase $db, array $fields ) {
$type = $db->getType();
if ( $type === 'mysql' ) {
$fields['castoken'] = $db->buildConcat( [
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function modifyTableSpecificBlobsForAdd
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function modifyTableSpecificBlobsForAdd(
IDatabase $db,
string $ptable,
float $mtime,
array $argsByKey,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function buildMultiUpsertSetForOverwrite
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function buildMultiUpsertSetForOverwrite( IDatabase $db, string $mt ) {
$expressionsByColumn = [
'value' => $db->buildExcludedValue( 'value' ),
'exptime' => $db->buildExcludedValue( 'exptime' )
];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function createTables
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function createTables() {
foreach ( $this->getShardServerIndexes() as $shardIndex ) {
$db = $this->getConnection( $shardIndex );
if ( in_array( $db->getType(), [ 'mysql', 'postgres' ], true ) ) {
for ( $i = 0; $i < $this->numTableShards; $i++ ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function unserialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function unserialize( $value ) {
if ( $value === self::TOMB_SERIAL ) {
return false; // tombstone
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"