Skip to content

Commit 6665289

Browse files
kamil-tekielaMauricioFauth
authored andcommitted
Remove dead code
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent 912e5dc commit 6665289

1 file changed

Lines changed: 21 additions & 42 deletions

File tree

libraries/classes/Navigation/Nodes/NodeDatabase.php

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,27 @@ public function __construct($name, $type = Node::OBJECT, $isGroup = false)
6464
* ('tables', 'views', etc)
6565
* @param string $searchClause A string used to filter the results of
6666
* the query
67-
* @param bool $singleItem Whether to get presence of a single known
68-
* item or false in none
6967
*
7068
* @return int
7169
*/
72-
public function getPresence($type = '', $searchClause = '', $singleItem = false)
70+
public function getPresence($type = '', $searchClause = '')
7371
{
7472
$retval = 0;
7573
switch ($type) {
7674
case 'tables':
77-
$retval = $this->getTableCount($searchClause, $singleItem);
75+
$retval = $this->getTableCount($searchClause);
7876
break;
7977
case 'views':
80-
$retval = $this->getViewCount($searchClause, $singleItem);
78+
$retval = $this->getViewCount($searchClause);
8179
break;
8280
case 'procedures':
83-
$retval = $this->getProcedureCount($searchClause, $singleItem);
81+
$retval = $this->getProcedureCount($searchClause);
8482
break;
8583
case 'functions':
86-
$retval = $this->getFunctionCount($searchClause, $singleItem);
84+
$retval = $this->getFunctionCount($searchClause);
8785
break;
8886
case 'events':
89-
$retval = $this->getEventCount($searchClause, $singleItem);
87+
$retval = $this->getEventCount($searchClause);
9088
break;
9189
default:
9290
break;
@@ -101,12 +99,10 @@ public function getPresence($type = '', $searchClause = '', $singleItem = false)
10199
* @param string $which tables|views
102100
* @param string $searchClause A string used to filter the results of
103101
* the query
104-
* @param bool $singleItem Whether to get presence of a single known
105-
* item or false in none
106102
*
107103
* @return int
108104
*/
109-
private function getTableOrViewCount($which, string $searchClause, $singleItem)
105+
private function getTableOrViewCount($which, string $searchClause)
110106
{
111107
if ($which === 'tables') {
112108
$condition = 'IN';
@@ -120,7 +116,7 @@ private function getTableOrViewCount($which, string $searchClause, $singleItem)
120116
$query .= 'WHERE `TABLE_SCHEMA`=' . $GLOBALS['dbi']->quoteString($this->realName) . ' ';
121117
$query .= 'AND `TABLE_TYPE` ' . $condition . "('BASE TABLE', 'SYSTEM VERSIONED') ";
122118
if ($searchClause !== '') {
123-
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'TABLE_NAME');
119+
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, 'TABLE_NAME');
124120
}
125121

126122
return (int) $GLOBALS['dbi']->fetchValue($query);
@@ -132,7 +128,6 @@ private function getTableOrViewCount($which, string $searchClause, $singleItem)
132128
if ($searchClause !== '') {
133129
$query .= 'AND ' . $this->getWhereClauseForSearch(
134130
$searchClause,
135-
$singleItem,
136131
'Tables_in_' . $this->realName
137132
);
138133
}
@@ -145,42 +140,36 @@ private function getTableOrViewCount($which, string $searchClause, $singleItem)
145140
*
146141
* @param string $searchClause A string used to filter the results of
147142
* the query
148-
* @param bool $singleItem Whether to get presence of a single known
149-
* item or false in none
150143
*
151144
* @return int
152145
*/
153-
private function getTableCount(string $searchClause, $singleItem)
146+
private function getTableCount(string $searchClause)
154147
{
155-
return $this->getTableOrViewCount('tables', $searchClause, $singleItem);
148+
return $this->getTableOrViewCount('tables', $searchClause);
156149
}
157150

158151
/**
159152
* Returns the number of views present inside this database
160153
*
161154
* @param string $searchClause A string used to filter the results of
162155
* the query
163-
* @param bool $singleItem Whether to get presence of a single known
164-
* item or false in none
165156
*
166157
* @return int
167158
*/
168-
private function getViewCount(string $searchClause, $singleItem)
159+
private function getViewCount(string $searchClause)
169160
{
170-
return $this->getTableOrViewCount('views', $searchClause, $singleItem);
161+
return $this->getTableOrViewCount('views', $searchClause);
171162
}
172163

173164
/**
174165
* Returns the number of procedures present inside this database
175166
*
176167
* @param string $searchClause A string used to filter the results of
177168
* the query
178-
* @param bool $singleItem Whether to get presence of a single known
179-
* item or false in none
180169
*
181170
* @return int
182171
*/
183-
private function getProcedureCount(string $searchClause, $singleItem)
172+
private function getProcedureCount(string $searchClause)
184173
{
185174
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
186175
$query = 'SELECT COUNT(*) ';
@@ -189,15 +178,15 @@ private function getProcedureCount(string $searchClause, $singleItem)
189178
. Util::getCollateForIS() . '=' . $GLOBALS['dbi']->quoteString($this->realName);
190179
$query .= "AND `ROUTINE_TYPE`='PROCEDURE' ";
191180
if ($searchClause !== '') {
192-
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'ROUTINE_NAME');
181+
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, 'ROUTINE_NAME');
193182
}
194183

195184
return (int) $GLOBALS['dbi']->fetchValue($query);
196185
}
197186

198187
$query = 'SHOW PROCEDURE STATUS WHERE `Db`=' . $GLOBALS['dbi']->quoteString($this->realName) . ' ';
199188
if ($searchClause !== '') {
200-
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'Name');
189+
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, 'Name');
201190
}
202191

203192
return $GLOBALS['dbi']->queryAndGetNumRows($query);
@@ -208,12 +197,10 @@ private function getProcedureCount(string $searchClause, $singleItem)
208197
*
209198
* @param string $searchClause A string used to filter the results of
210199
* the query
211-
* @param bool $singleItem Whether to get presence of a single known
212-
* item or false in none
213200
*
214201
* @return int
215202
*/
216-
private function getFunctionCount(string $searchClause, $singleItem)
203+
private function getFunctionCount(string $searchClause)
217204
{
218205
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
219206
$query = 'SELECT COUNT(*) ';
@@ -222,15 +209,15 @@ private function getFunctionCount(string $searchClause, $singleItem)
222209
. Util::getCollateForIS() . '=' . $GLOBALS['dbi']->quoteString($this->realName) . ' ';
223210
$query .= "AND `ROUTINE_TYPE`='FUNCTION' ";
224211
if ($searchClause !== '') {
225-
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'ROUTINE_NAME');
212+
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, 'ROUTINE_NAME');
226213
}
227214

228215
return (int) $GLOBALS['dbi']->fetchValue($query);
229216
}
230217

231218
$query = 'SHOW FUNCTION STATUS WHERE `Db`=' . $GLOBALS['dbi']->quoteString($this->realName) . ' ';
232219
if ($searchClause !== '') {
233-
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'Name');
220+
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, 'Name');
234221
}
235222

236223
return $GLOBALS['dbi']->queryAndGetNumRows($query);
@@ -241,28 +228,26 @@ private function getFunctionCount(string $searchClause, $singleItem)
241228
*
242229
* @param string $searchClause A string used to filter the results of
243230
* the query
244-
* @param bool $singleItem Whether to get presence of a single known
245-
* item or false in none
246231
*
247232
* @return int
248233
*/
249-
private function getEventCount(string $searchClause, $singleItem)
234+
private function getEventCount(string $searchClause)
250235
{
251236
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
252237
$query = 'SELECT COUNT(*) ';
253238
$query .= 'FROM `INFORMATION_SCHEMA`.`EVENTS` ';
254239
$query .= 'WHERE `EVENT_SCHEMA` '
255240
. Util::getCollateForIS() . '=' . $GLOBALS['dbi']->quoteString($this->realName) . ' ';
256241
if ($searchClause !== '') {
257-
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'EVENT_NAME');
242+
$query .= 'AND ' . $this->getWhereClauseForSearch($searchClause, 'EVENT_NAME');
258243
}
259244

260245
return (int) $GLOBALS['dbi']->fetchValue($query);
261246
}
262247

263248
$query = 'SHOW EVENTS FROM ' . Util::backquote($this->realName) . ' ';
264249
if ($searchClause !== '') {
265-
$query .= 'WHERE ' . $this->getWhereClauseForSearch($searchClause, $singleItem, 'Name');
250+
$query .= 'WHERE ' . $this->getWhereClauseForSearch($searchClause, 'Name');
266251
}
267252

268253
return $GLOBALS['dbi']->queryAndGetNumRows($query);
@@ -272,20 +257,14 @@ private function getEventCount(string $searchClause, $singleItem)
272257
* Returns the WHERE clause for searching inside a database
273258
*
274259
* @param string $searchClause A string used to filter the results of the query
275-
* @param bool $singleItem Whether to get presence of a single known item
276260
* @param string $columnName Name of the column in the result set to match
277261
*
278262
* @return string WHERE clause for searching
279263
*/
280264
private function getWhereClauseForSearch(
281265
string $searchClause,
282-
$singleItem,
283266
$columnName
284267
) {
285-
if ($singleItem) {
286-
return Util::backquote($columnName) . ' = ' . $GLOBALS['dbi']->quoteString($searchClause);
287-
}
288-
289268
return Util::backquote($columnName) . ' LIKE '
290269
. $GLOBALS['dbi']->quoteString('%' . $GLOBALS['dbi']->escapeMysqlWildcards($searchClause) . '%');
291270
}

0 commit comments

Comments
 (0)