| Conditions | 33 |
| Paths | > 20000 |
| Total Lines | 140 |
| Code Lines | 82 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 353 | public function execSelect(string $table, array $queryOptions) |
||
| 354 | { |
||
| 355 | list($options, $query, $select, $fields, $foreignKeys, $columns, $indexes, |
||
| 356 | $where, $group, $order, $limit, $page, $textLength, $isGroup, $tableName, |
||
| 357 | $unselected) = $this->prepareSelect($table, $queryOptions); |
||
| 358 | |||
| 359 | $error = null; |
||
| 360 | // From driver.inc.php |
||
| 361 | $start = microtime(true); |
||
| 362 | $statement = $this->driver->query($query); |
||
| 363 | // From adminer.inc.php |
||
| 364 | $duration = $this->trans->formatTime($start); // Compute and format the duration |
||
| 365 | |||
| 366 | if (!$statement) { |
||
| 367 | return ['error' => $this->driver->error()]; |
||
| 368 | } |
||
| 369 | // From select.inc.php |
||
| 370 | $rows = []; |
||
| 371 | while (($row = $statement->fetchAssoc())) { |
||
| 372 | if ($page && $this->driver->jush() == "oracle") { |
||
| 373 | unset($row["RNUM"]); |
||
| 374 | } |
||
| 375 | $rows[] = $row; |
||
| 376 | } |
||
| 377 | if (!$rows) { |
||
| 378 | return ['error' => $this->trans->lang('No rows.')]; |
||
| 379 | } |
||
| 380 | // $backward_keys = $this->driver->backwardKeys($table, $tableName); |
||
| 381 | |||
| 382 | // Results headers |
||
| 383 | $headers = [ |
||
| 384 | '', // !$group && $select ? '' : lang('Modify'); |
||
| 385 | ]; |
||
| 386 | $names = []; |
||
| 387 | $functions = []; |
||
| 388 | reset($select); |
||
| 389 | $rank = 1; |
||
| 390 | foreach ($rows[0] as $key => $value) { |
||
| 391 | $header = []; |
||
| 392 | if (!isset($unselected[$key])) { |
||
| 393 | $value = $queryOptions["columns"][key($select)] ?? []; |
||
| 394 | $fun = $value["fun"] ?? ''; |
||
| 395 | $field = $fields[$select ? ($value ? $value["col"] : current($select)) : $key]; |
||
| 396 | $name = ($field ? $this->util->fieldName($field, $rank) : ($fun ? "*" : $key)); |
||
| 397 | $header = \compact('value', 'field', 'name'); |
||
| 398 | if ($name != "") { |
||
| 399 | $rank++; |
||
| 400 | $names[$key] = $name; |
||
| 401 | $column = $this->driver->escapeId($key); |
||
| 402 | // $href = remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key); |
||
| 403 | // $desc = "&desc%5B0%5D=1"; |
||
| 404 | $header['column'] = $column; |
||
| 405 | $header['key'] = $this->util->html($this->util->bracketEscape($key)); |
||
| 406 | $header['sql'] = $this->admin->applySqlFunction($fun, $name); //! columns looking like functions |
||
| 407 | } |
||
| 408 | $functions[$key] = $fun; |
||
| 409 | next($select); |
||
| 410 | } |
||
| 411 | $headers[] = $header; |
||
| 412 | } |
||
| 413 | |||
| 414 | // $lengths = []; |
||
| 415 | // if($queryOptions["modify"]) |
||
| 416 | // { |
||
| 417 | // foreach($rows as $row) |
||
| 418 | // { |
||
| 419 | // foreach($row as $key => $value) |
||
| 420 | // { |
||
| 421 | // $lengths[$key] = \max($lengths[$key], \min(40, strlen(\utf8_decode($value)))); |
||
| 422 | // } |
||
| 423 | // } |
||
| 424 | // } |
||
| 425 | |||
| 426 | $results = []; |
||
| 427 | foreach ($rows as $n => $row) { |
||
| 428 | $uniqueIds = $this->util->uniqueIds($rows[$n], $indexes); |
||
| 429 | if (empty($uniqueIds)) { |
||
| 430 | foreach ($rows[$n] as $key => $value) { |
||
| 431 | if (!\preg_match('~^(COUNT\((\*|(DISTINCT )?`(?:[^`]|``)+`)\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\(`(?:[^`]|``)+`\))$~', $key)) { |
||
| 432 | //! columns looking like functions |
||
| 433 | $uniqueIds[$key] = $value; |
||
| 434 | } |
||
| 435 | } |
||
| 436 | } |
||
| 437 | |||
| 438 | // Unique identifier to edit returned data. |
||
| 439 | // $unique_idf = ""; |
||
| 440 | $rowIds = [ |
||
| 441 | 'where' => [], |
||
| 442 | 'null' => [], |
||
| 443 | ]; |
||
| 444 | foreach ($uniqueIds as $key => $value) { |
||
| 445 | $key = \trim($key); |
||
| 446 | $type = ''; |
||
| 447 | $collation = ''; |
||
| 448 | if (isset($fields[$key])) { |
||
| 449 | $type = $fields[$key]->type; |
||
| 450 | $collation = $fields[$key]->collation; |
||
| 451 | } |
||
| 452 | if (($this->driver->jush() == "sql" || $this->driver->jush() == "pgsql") && |
||
| 453 | \preg_match('~char|text|enum|set~', $type) && strlen($value) > 64) { |
||
| 454 | $key = (\strpos($key, '(') ? $key : $this->driver->escapeId($key)); //! columns looking like functions |
||
| 455 | $key = "MD5(" . ($this->driver->jush() != 'sql' || \preg_match("~^utf8~", $collation) ? |
||
| 456 | $key : "CONVERT($key USING " . $this->driver->charset() . ")") . ")"; |
||
| 457 | $value = \md5($value); |
||
| 458 | } |
||
| 459 | if ($value !== null) { |
||
| 460 | $rowIds['where'][$this->util->bracketEscape($key)] = $value; |
||
| 461 | } else { |
||
| 462 | $rowIds['null'][] = $this->util->bracketEscape($key); |
||
| 463 | } |
||
| 464 | // $unique_idf .= "&" . ($value !== null ? \urlencode("where[" . $this->util->bracketEscape($key) . "]") . |
||
| 465 | // "=" . \urlencode($value) : \urlencode("null[]") . "=" . \urlencode($key)); |
||
| 466 | } |
||
| 467 | |||
| 468 | $cols = []; |
||
| 469 | foreach ($row as $key => $value) { |
||
| 470 | if (isset($names[$key])) { |
||
| 471 | $field = $fields[$key] ?? new TableFieldEntity(); |
||
| 472 | $value = $this->driver->value($value, $field); |
||
| 473 | if ($value != "" && (!isset($email_fields[$key]) || $email_fields[$key] != "")) { |
||
| 474 | //! filled e-mails can be contained on other pages |
||
| 475 | $email_fields[$key] = ($this->util->isMail($value) ? $names[$key] : ""); |
||
| 476 | } |
||
| 477 | |||
| 478 | $link = ""; |
||
| 479 | |||
| 480 | $value = $this->util->selectValue($value ?? '', $link, $field, $textLength); |
||
| 481 | $text = \preg_match('~text|lob~', $field->type); |
||
| 482 | |||
| 483 | $cols[] = \compact(/*'id', */'text', 'value'/*, 'editable'*/); |
||
| 484 | } |
||
| 485 | } |
||
| 486 | $results[] = ['ids' => $rowIds, 'cols' => $cols]; |
||
| 487 | } |
||
| 488 | |||
| 489 | $total = $this->driver->result($this->driver->countRowsSql($table, $where, $isGroup, $group)); |
||
| 490 | |||
| 491 | $rows = $results; |
||
| 492 | return \compact('duration', 'headers', 'query', 'rows', 'limit', 'total', 'error'); |
||
| 493 | } |
||
| 495 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths