com web/bugs: Move lists query to repository class: src/Repository/PackageRepository.php www/admin/index.php
| From: | Peter Kokot | Date: | Wed, 19 Dec 2018 01:22:12 +0000 |
| Subject: | com web/bugs: Move lists query to repository class: src/Repository/PackageRepository.php www/admin/index.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-27594@lists.php.net to get a copy of this message | ||
Commit: 11fd2afda1fdbb0e0365886cd9cafc7b74dd525f
Author: Peter Kokot <peterkokot@gmail.com> Wed, 19 Dec 2018 02:22:12 +0100
Parents: f038854680d7bd625713757555bead86b789e1fe
Branches: master
Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=11fd2afda1fdbb0e0365886cd9cafc7b74dd525f
Log:
Move lists query to repository class
Changed paths:
M src/Repository/PackageRepository.php
M www/admin/index.php
Diff:
diff --git a/src/Repository/PackageRepository.php b/src/Repository/PackageRepository.php
index 96392c8..aaaa399 100644
--- a/src/Repository/PackageRepository.php
+++ b/src/Repository/PackageRepository.php
@@ -117,4 +117,20 @@ class PackageRepository
return $packages;
}
+
+ /**
+ * Find all package mailing lists.
+ */
+ public function findLists(): array
+ {
+ $sql = "SELECT name, list_email
+ FROM bugdb_pseudo_packages
+ WHERE project = 'php' AND LENGTH(list_email) > 0
+ ORDER BY list_email
+ ";
+
+ $statement = $this->dbh->query($sql);
+
+ return $statement->fetchAll();
+ }
}
diff --git a/www/admin/index.php b/www/admin/index.php
index ebb905b..1c2c810 100644
--- a/www/admin/index.php
+++ b/www/admin/index.php
@@ -1,4 +1,7 @@
<?php
+
+use App\Repository\PackageRepository;
+
require_once '../../include/prepend.php';
session_start();
@@ -49,17 +52,8 @@ if ($action === 'phpinfo') {
echo $m[1];
} elseif ($action === 'list_lists') {
-
- $res = $dbh->query("
- SELECT name, list_email
- FROM bugdb_pseudo_packages
- WHERE project = 'php'
- AND LENGTH(list_email) > 0
- ORDER BY list_email
- ");
-
echo "<dl>\n";
- while ($row = $res->fetch()) {
+ foreach ((new PackageRepository($dbh))->findLists() as $row) {
echo "<dt>", $row['name'], ": </dt>\n<dd>",
mailto_list(explode(',', $row['list_email'])), "</dd>\n";
}
echo "</dl>\n";