Skip to content

Commit fdba812

Browse files
committed
Merge branch '4.0' into 'main'
2 parents a51e5ec + 5a8710e commit fdba812

File tree

15 files changed

+71
-22
lines changed

15 files changed

+71
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ This is a log of major user-visible changes in each phpMyFAQ release.
1515
- migrated from Webpack to Vite v6 (Thorsten)
1616
- migrated from Jest to vitest (Thorsten)
1717

18+
### phpMyFAQ v4.0.5 - unreleased
19+
20+
- updated Hellenic translation (Vasileios Tzimourtos)
21+
- fixed minor bugs (Thorsten)
22+
1823
### phpMyFAQ v4.0.4 - 2025-01-09
1924

2025
- improved update from v3 (Thorsten)

docs/development.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,26 @@ To create a new SSL certificate, you can use the following command:
363363
$ mkcert -install -cert-file .docker/cert.pem -key-file .docker/cert-key.pem localhost
364364

365365
For more information, please visit the [mkcert](https://github.com/FiloSottile/mkcert) website.
366+
367+
### 6.7.2 Using a OpenLDAP docker container for testing
368+
369+
To test phpMyFAQ during development with an OpenLDAP docker container, you can use the following test setup:
370+
371+
$ docker pull rroemhild/test-openldap
372+
$ docker run --rm -p 10389:10389 -p 10636:10636 rroemhild/test-openldap
373+
374+
The credentials for the OpenLDAP container are stored in the file content/core/config/ldap.php:
375+
376+
<?php
377+
$PMF_LDAP['ldap_server'] = 'ldap://<your ip address>';
378+
$PMF_LDAP['ldap_port'] = 10389;
379+
$PMF_LDAP['ldap_user'] = 'cn=admin,dc=planetexpress,dc=com';
380+
$PMF_LDAP['ldap_password'] = 'GoodNewsEveryone';
381+
$PMF_LDAP['ldap_base'] = 'ou=people,dc=planetexpress,dc=com';
382+
383+
After activating the LDAP authentication in the admin backend, you can use the following credentials to log in:
384+
385+
Username: professor
386+
Password: professor
387+
388+
More information about the OpenLDAP docker container can be found on the [Docker Hub](https://hub.docker.com/r/rroemhild/test-openldap).

docs/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ download it and unzip the archive on your hard disk.
8383

8484
If you want to use Git, please run the following commands on your shell:
8585

86-
$ git clone [email protected]:thorsten/phpMyFAQ.git 3.2
86+
$ git clone [email protected]:thorsten/phpMyFAQ.git 4.0
8787
$ cd phpMyFAQ
8888
$ curl -s https://getcomposer.org/installer | php
8989
$ php composer.phar install

phpmyfaq/src/phpMyFAQ/Auth/AuthLdap.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,14 @@ public function __construct(Configuration $configuration)
7171
*/
7272
public function create(string $login, #[SensitiveParameter] string $password, string $domain = ''): bool
7373
{
74+
$result = false;
7475
$user = new User($this->configuration);
75-
$result = $user->createUser($login, '', $domain);
76+
77+
try {
78+
$result = $user->createUser($login, '', $domain);
79+
} catch (\Exception $e) {
80+
$this->configuration->getLogger()->info($e->getMessage());
81+
}
7682

7783
$this->connect($this->activeServer);
7884

phpmyfaq/src/phpMyFAQ/Controller/AbstractController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ public function __construct()
8282
* @param string[] $templateVars
8383
* @param Response|null $response
8484
* @return Response
85-
* @throws Exception
86-
* @throws LoaderError
85+
* @throws Exception|LoaderError
8786
*/
8887
public function render(string $pathToTwigFile, array $templateVars = [], ?Response $response = null): Response
8988
{

phpmyfaq/src/phpMyFAQ/Controller/Api/SetupController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
use Symfony\Component\HttpFoundation\JsonResponse;
2727
use Symfony\Component\HttpFoundation\Request;
2828
use Symfony\Component\HttpFoundation\Response;
29-
use Symfony\Component\HttpFoundation\StreamedJsonResponse;
30-
use Symfony\Component\HttpFoundation\StreamedResponse;
3129

3230
class SetupController extends AbstractController
3331
{
@@ -108,7 +106,9 @@ public function updateDatabase(Request $request): JsonResponse
108106
$this->configuration->set('main.maintenanceMode', 'false');
109107
return new JsonResponse(['success' => '✅ Database successfully updated.'], Response::HTTP_OK);
110108
}
111-
} catch (Exception $exception) {
109+
110+
return new JsonResponse(['error' => 'Update database failed.'], Response::HTTP_BAD_GATEWAY);
111+
} catch (Exception | \Exception $exception) {
112112
return new JsonResponse(
113113
['error' => 'Update database failed: ' . $exception->getMessage()],
114114
Response::HTTP_BAD_GATEWAY

phpmyfaq/src/phpMyFAQ/Controller/WebAuthnController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use phpMyFAQ\System;
2323
use phpMyFAQ\Template\TwigWrapper;
2424
use phpMyFAQ\Translation;
25-
use phpMyFAQ\User\CurrentUser;
2625
use Symfony\Component\HttpFoundation\Request;
2726
use Symfony\Component\HttpFoundation\Response;
2827
use Symfony\Component\Routing\Annotation\Route;
@@ -41,7 +40,6 @@ public function __construct()
4140
public function index(Request $request): Response
4241
{
4342
$system = new System();
44-
$user = CurrentUser::getCurrentUser($this->configuration);
4543

4644
$topNavigation = [
4745
[
@@ -98,7 +96,7 @@ public function index(Request $request): Response
9896
'richSnippetsEnabled' => $this->configuration->get('seo.enableRichSnippets'),
9997
'tplSetName' => TwigWrapper::getTemplateSetName(),
10098
'msgLoginUser' => Translation::get('msgLoginUser'),
101-
'isUserLoggedIn' => $user->isLoggedIn(),
99+
'isUserLoggedIn' => $this->currentUser->isLoggedIn(),
102100
'title' => Translation::get('msgLoginUser'),
103101
'baseHref' => $system->getSystemUri($this->configuration),
104102
'customCss' => $this->configuration->getCustomCss(),

phpmyfaq/src/phpMyFAQ/Ldap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public function bind(string $rdn = '', #[SensitiveParameter] string $password =
142142
if ('' === $rdn && '' === $password) {
143143
return ldap_bind($this->ds);
144144
}
145+
145146
return ldap_bind($this->ds, $rdn, $password);
146147
}
147148

@@ -163,6 +164,7 @@ public function getMail(string $username): bool|string
163164
*/
164165
private function getLdapData(string $username, string $data): bool|string
165166
{
167+
166168
if ($this->ds === false) {
167169
$this->error = 'The LDAP connection handler is not a valid resource.';
168170

phpmyfaq/src/phpMyFAQ/Mail.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class Mail
183183
public function __construct(Configuration $configuration)
184184
{
185185
// Set default value for public properties
186-
$this->agent = $configuration->get('mail.remoteSMTP') ? 'SMTP' : 'built-in';
186+
$this->agent = $configuration->get('mail.remoteSMTP') ? 'smtp' : 'built-in';
187187
$this->boundary = self::createBoundary();
188188
$this->messageId = '<' . Request::createFromGlobals()->server->get('REQUEST_TIME') . '.' . md5(microtime()) .
189189
'@' . self::getServerName() . '>';
@@ -366,7 +366,7 @@ public function addTo(string $address, ?string $name = null): bool
366366
*/
367367
public function send(): int
368368
{
369-
// Sanity check
369+
// Check
370370
if (count($this->to) + count($this->cc) + count($this->bcc) < 1) {
371371
throw new Exception(
372372
'<strong>Mail Class</strong>: you need at least to set one recipient among TO, CC and BCC!'
@@ -430,7 +430,7 @@ public function send(): int
430430
}
431431

432432
return match ($this->agent) {
433-
'SMTP', 'built-in' => $mua->send($recipients, $this->headers, $this->body),
433+
'smtp', 'built-in' => $mua->send($recipients, $this->headers, $this->body),
434434
default => throw new Exception('<strong>Mail Class</strong>: ' . $this->agent . ' has no implementation!'),
435435
};
436436
}

phpmyfaq/src/phpMyFAQ/News.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,15 @@ public function getLatestData(bool $showArchive = false, bool $active = true, bo
137137
/**
138138
* Fetches all news headers.
139139
*
140-
* @return array<mixed>
140+
* @return array
141141
*/
142142
public function getHeader(): array
143143
{
144144
$headers = [];
145-
$now = date('YmdHis');
146145

147146
$query = sprintf("
148147
SELECT
149-
id, datum, lang, header, active, date_start, date_end
148+
id, datum, lang, header, active
150149
FROM
151150
%sfaqnews
152151
WHERE
@@ -158,14 +157,12 @@ public function getHeader(): array
158157

159158
if ($this->configuration->getDb()->numRows($result) > 0) {
160159
while ($row = $this->configuration->getDb()->fetchObject($result)) {
161-
$expired = ($now > $row->date_end);
162160
$headers[] = [
163161
'id' => $row->id,
164162
'lang' => $row->lang,
165163
'header' => $row->header,
166164
'date' => Date::createIsoDate($row->datum),
167-
'active' => $row->active,
168-
'expired' => $expired
165+
'active' => $row->active
169166
];
170167
}
171168
}

0 commit comments

Comments
 (0)