Skip to content

Commit d19971d

Browse files
committed
build: moved private API controller in another folder, fixed code formatting in tests
1 parent 966c26e commit d19971d

File tree

240 files changed

+2818
-2904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+2818
-2904
lines changed

phpmyfaq/.htaccess

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization"
109109
RewriteRule ^add-question.html$ index.php?action=ask [L,QSA]
110110
RewriteRule ^show-categories.html$ index.php?action=show [L,QSA]
111111
RewriteRule ^forgot-password$ index.php?action=password [L,QSA]
112-
RewriteRule ^(search|open-questions|glossary|overview|login|privacy)\.html$ index.php?action=$1 [L,QSA]
112+
RewriteRule ^(search|open-questions|glossary|overview|login|privacy|contact)\.html$ index.php?action=$1 [L,QSA]
113113
RewriteRule ^(login) index.php?action=login [L,QSA]
114114
# start page
115115
RewriteRule ^index.html$ index.php [L,QSA]
@@ -162,5 +162,6 @@ Header set Access-Control-Allow-Headers "Content-Type, Authorization"
162162
RewriteCond %{REQUEST_URI} ^(.*/)setup/
163163
RewriteCond %{REQUEST_URI} !index\.php$
164164
RewriteRule ^(.*/)?setup/(.*) $1setup/index.php [L,QSA]
165-
RewriteRule ^update/(.*) update/index.php [L,QSA]
165+
RewriteRule ^update$ update/ [R=301,L]
166+
RewriteRule ^update/(.*) index.php [L,QSA]
166167
</IfModule>

phpmyfaq/index.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use phpMyFAQ\Attachment\AttachmentFactory;
2424
use phpMyFAQ\Category;
2525
use phpMyFAQ\Category\Relation;
26-
use phpMyFAQ\Controller\PageNotFoundController;
2726
use phpMyFAQ\Core\Exception;
2827
use phpMyFAQ\Entity\SeoEntity;
2928
use phpMyFAQ\Enums\PermissionType;
@@ -148,7 +147,7 @@
148147

149148
// Send response and exit
150149
$routeResponse->send();
151-
exit;
150+
exit();
152151
} catch (ResourceNotFoundException $e) {
153152
// No route matched - continue with legacy logic below
154153
}
@@ -585,10 +584,7 @@
585584
'msgSubmit' => Translation::get(key: 'msgNewContentSubmit'),
586585
'loginPageMessage' => Translation::get(key: 'loginPageMessage'),
587586
'msgAdvancedSearch' => Translation::get(key: 'msgAdvancedSearch'),
588-
'currentYear' => date(
589-
format: 'Y',
590-
timestamp: time(),
591-
),
587+
'currentYear' => date(format: 'Y', timestamp: time()),
592588
'cookieConsentEnabled' => $faqConfig->get('layout.enableCookieConsent'),
593589
];
594590

@@ -650,19 +646,15 @@
650646
'msgPrivacyNote' => Translation::get(key: 'msgPrivacyNote'),
651647
'isCookieConsentEnabled' => $faqConfig->get('layout.enableCookieConsent'),
652648
'cookiePreferences' => Translation::get(key: 'cookiePreferences'),
653-
'currentYear' => date(
654-
format: 'Y',
655-
timestamp: time(),
656-
),
649+
'currentYear' => date(format: 'Y', timestamp: time()),
657650
];
658651

659652
//
660653
// Show the login box or logged-in user information
661654
//
662655
if ($user->isLoggedIn() && $user->getUserId() > 0) {
663656
if (
664-
$user->perm->hasPermission($user->getUserId(), PermissionType::VIEW_ADMIN_LINK->value)
665-
|| $user->isSuperAdmin()
657+
$user->perm->hasPermission($user->getUserId(), PermissionType::VIEW_ADMIN_LINK->value) || $user->isSuperAdmin()
666658
) {
667659
$templateVars = [
668660
...$templateVars,
@@ -688,10 +680,10 @@
688680
// Handle 404 action with PageNotFoundController
689681
//
690682
if ('404' === $action) {
691-
$pageNotFoundController = new \phpMyFAQ\Controller\PageNotFoundController();
683+
$pageNotFoundController = new \phpMyFAQ\Controller\Frontend\PageNotFoundController();
692684
$notFoundResponse = $pageNotFoundController->index($request);
693685
$notFoundResponse->send();
694-
exit;
686+
exit();
695687
}
696688

697689
//

phpmyfaq/setup/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
use Composer\Autoload\ClassLoader;
2727
use phpMyFAQ\Application;
28-
use phpMyFAQ\Controller\Frontend\SetupController;
28+
use phpMyFAQ\Controller\Frontend\Api\SetupController;
2929
use phpMyFAQ\Environment;
3030
use phpMyFAQ\Strings;
3131
use phpMyFAQ\Translation;

phpmyfaq/src/Bootstrap.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
use phpMyFAQ\Configuration\ElasticsearchConfiguration;
2626
use phpMyFAQ\Configuration\LdapConfiguration;
2727
use phpMyFAQ\Configuration\OpenSearchConfiguration;
28-
use phpMyFAQ\Database;
2928
use phpMyFAQ\Core\Exception;
29+
use phpMyFAQ\Database;
3030
use phpMyFAQ\Environment;
3131
use Symfony\Component\HttpClient\HttpClient;
3232
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -40,7 +40,7 @@
4040
$foundCurrPath = false;
4141
$includePaths = explode(PATH_SEPARATOR, ini_get('include_path'));
4242
$i = 0;
43-
while ((!$foundCurrPath) && ($i < count($includePaths))) {
43+
while (!$foundCurrPath && $i < count($includePaths)) {
4444
if ('.' == $includePaths[$i]) {
4545
$foundCurrPath = true;
4646
}
@@ -100,7 +100,7 @@
100100
if (!$isSetupContext) {
101101
$response = new RedirectResponse('/setup/');
102102
$response->send();
103-
exit;
103+
exit();
104104
}
105105
} else {
106106
if (file_exists(PMF_CONFIG_DIR . '/database.php')) {
@@ -152,7 +152,7 @@
152152
$dbConfig->getUser(),
153153
$dbConfig->getPassword(),
154154
$dbConfig->getDatabase(),
155-
$dbConfig->getPort()
155+
$dbConfig->getPort(),
156156
);
157157
} catch (Exception $exception) {
158158
Database::errorPage($exception->getMessage());
@@ -210,7 +210,7 @@
210210
// Optional: wait for Elasticsearch to be ready (HTTP health)
211211
try {
212212
$http = HttpClient::create(['verify_peer' => false]);
213-
$deadline = time() + (int)($_ENV['SEARCH_WAIT_TIMEOUT'] ?? 15);
213+
$deadline = time() + (int) ($_ENV['SEARCH_WAIT_TIMEOUT'] ?? 15);
214214
do {
215215
try {
216216
$res = $http->request('GET', rtrim($esBaseUri, '/') . '/_cluster/health');
@@ -247,7 +247,7 @@
247247
// Optional: wait for OpenSearch to be ready (HTTP health)
248248
try {
249249
$http = HttpClient::create(['verify_peer' => false]);
250-
$deadline = time() + (int)($_ENV['SEARCH_WAIT_TIMEOUT'] ?? 15);
250+
$deadline = time() + (int) ($_ENV['SEARCH_WAIT_TIMEOUT'] ?? 15);
251251
do {
252252
try {
253253
$res = $http->request('GET', rtrim($baseUri, '/') . '/_cluster/health');

0 commit comments

Comments
 (0)