Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Lwt\Modules\Activity\Domain\ActivityRepositoryInterface;
use Lwt\Shared\Infrastructure\Database\Connection;
use Lwt\Shared\Infrastructure\Database\UserScopedQuery;
use Lwt\Shared\Infrastructure\Globals;

/**
* MySQL implementation of ActivityRepositoryInterface.
Expand Down Expand Up @@ -63,7 +62,7 @@ public function getActivityForDateRange(string $startDate, string $endDate): arr
$bindings = [$startDate, $endDate];
$userScope = UserScopedQuery::forTablePrepared('activity_log', $bindings);

$tableName = Globals::table('activity_log');
$tableName = 'activity_log';
$rows = Connection::preparedFetchAll(
"SELECT AlDate, AlTermsCreated, AlTermsReviewed, AlTextsRead
FROM {$tableName}
Expand Down Expand Up @@ -93,7 +92,7 @@ public function getActiveDatesDescending(): array
$bindings = [];
$userScope = UserScopedQuery::forTablePrepared('activity_log', $bindings);

$tableName = Globals::table('activity_log');
$tableName = 'activity_log';
$rows = Connection::preparedFetchAll(
"SELECT AlDate
FROM {$tableName}
Expand All @@ -119,7 +118,7 @@ public function getTodaySummary(): array
$bindings = [];
$userScope = UserScopedQuery::forTablePrepared('activity_log', $bindings);

$tableName = Globals::table('activity_log');
$tableName = 'activity_log';
$row = Connection::preparedFetchOne(
"SELECT AlTermsCreated, AlTermsReviewed, AlTextsRead
FROM {$tableName}
Expand Down Expand Up @@ -150,7 +149,7 @@ public function getTodaySummary(): array
*/
private function incrementColumn(string $column, int $count): void
{
$tableName = Globals::table('activity_log');
$tableName = 'activity_log';
$userId = UserScopedQuery::getUserIdForInsert('activity_log');

$bindings = [$userId, $count, $count];
Expand Down
3 changes: 1 addition & 2 deletions src/Modules/Admin/Application/Services/TtsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* TTS Service - Business logic for Text-to-Speech settings
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Admin\Application\Services
Expand All @@ -17,7 +17,6 @@

namespace Lwt\Modules\Admin\Application\Services;

use Lwt\Shared\Infrastructure\Globals;
use Lwt\Shared\Infrastructure\Http\InputValidator;
use Lwt\Shared\Infrastructure\Http\SecurityHeaders;
use Lwt\Shared\Infrastructure\Database\Settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Get Server Data Use Case
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Admin\Application\UseCases\ServerData
Expand Down Expand Up @@ -94,13 +94,8 @@ private function getDatabaseSize(): float
'words', 'word_tag_map'
];

$prefixedTables = array_map(
fn($table) => Globals::table($table),
$tableNames
);

$placeholders = implode(', ', array_fill(0, count($prefixedTables), '?'));
$bindings = array_merge([$dbname], $prefixedTables);
$placeholders = implode(', ', array_fill(0, count($tableNames), '?'));
$bindings = array_merge([$dbname], $tableNames);

/** @var float|int|string|null $temp_size */
$temp_size = Connection::preparedFetchValue(
Expand Down
1 change: 0 additions & 1 deletion src/Modules/Admin/Http/UserManagementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Lwt\Modules\Admin\Http;

use Lwt\Shared\Http\BaseController;
use Lwt\Shared\Infrastructure\Globals;
use Lwt\Modules\Admin\Application\UseCases\UserManagement\ListUsers;
use Lwt\Modules\Admin\Application\UseCases\UserManagement\CreateUser;
use Lwt\Modules\Admin\Application\UseCases\UserManagement\UpdateUser;
Expand Down
7 changes: 3 additions & 4 deletions src/Modules/Book/Application/UseCases/CreateBookFromTexts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Create Book From Texts Use Case
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Book\Application\UseCases
Expand All @@ -25,7 +25,6 @@
use Lwt\Shared\Infrastructure\Database\TextParsing;
use Lwt\Modules\Text\Domain\Text;
use Lwt\Modules\Text\Domain\TextRepositoryInterface;
use Lwt\Shared\Infrastructure\Globals;
use RuntimeException;

/**
Expand Down Expand Up @@ -237,7 +236,7 @@ private function linkTextToBook(
): void {
$bindings = [$bookId, $chapterNum, $chapterTitle, $textId];
Connection::preparedExecute(
"UPDATE " . Globals::table('texts') .
"UPDATE texts" .
" SET TxBkID = ?, TxChapterNum = ?, TxChapterTitle = ? WHERE TxID = ?",
$bindings
);
Expand All @@ -254,7 +253,7 @@ private function applyTags(int $textId, array $tagIds): void
foreach ($tagIds as $tagId) {
$bindings = [$textId, $tagId];
Connection::preparedExecute(
"INSERT IGNORE INTO " . Globals::table('text_tag_map') .
"INSERT IGNORE INTO text_tag_map" .
" (TtTxID, TtT2ID) VALUES (?, ?)",
$bindings
);
Expand Down
7 changes: 3 additions & 4 deletions src/Modules/Book/Application/UseCases/ImportEpub.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Import EPUB Use Case
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Book\Application\UseCases
Expand All @@ -27,7 +27,6 @@
use Lwt\Shared\Infrastructure\Database\UserScopedQuery;
use Lwt\Modules\Text\Domain\Text;
use Lwt\Modules\Text\Domain\TextRepositoryInterface;
use Lwt\Shared\Infrastructure\Globals;
use InvalidArgumentException;
use RuntimeException;

Expand Down Expand Up @@ -363,7 +362,7 @@ private function linkTextToBook(
): void {
$bindings = [$bookId, $chapterNum, $chapterTitle, $textId];
Connection::preparedExecute(
"UPDATE " . Globals::table('texts') .
"UPDATE texts" .
" SET TxBkID = ?, TxChapterNum = ?, TxChapterTitle = ? WHERE TxID = ?",
$bindings
);
Expand All @@ -380,7 +379,7 @@ private function applyTags(int $textId, array $tagIds): void
foreach ($tagIds as $tagId) {
$bindings = [$textId, $tagId];
Connection::preparedExecute(
"INSERT IGNORE INTO " . Globals::table('text_tag_map') .
"INSERT IGNORE INTO text_tag_map" .
" (TtTxID, TtT2ID) VALUES (?, ?)",
$bindings
);
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/Book/Infrastructure/MySqlBookRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* MySQL Book Repository
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Book\Infrastructure
Expand Down Expand Up @@ -65,7 +65,7 @@ class MySqlBookRepository implements BookRepositoryInterface
*/
protected function query(): QueryBuilder
{
return Globals::query($this->tableName);
return QueryBuilder::table($this->tableName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Local Dictionary Service - Business logic for local dictionary management
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Dictionary\Application\Services
Expand Down Expand Up @@ -216,8 +216,8 @@ public function lookup(int $languageId, string $term): array

$bindings = [$languageId, $termLc];
$sql = "SELECT le.LeTerm, le.LeDefinition, le.LeReading, le.LePartOfSpeech, ld.LdName
FROM " . Globals::table('local_dictionary_entries') . " le
INNER JOIN " . Globals::table('local_dictionaries') . " ld ON le.LeLdID = ld.LdID
FROM local_dictionary_entries le
INNER JOIN local_dictionaries ld ON le.LeLdID = ld.LdID
WHERE ld.LdLgID = ? AND ld.LdEnabled = 1 AND le.LeTermLc = ?"
. UserScopedQuery::forTablePrepared('local_dictionaries', $bindings, 'ld')
. " ORDER BY ld.LdPriority ASC";
Expand Down Expand Up @@ -253,8 +253,8 @@ public function lookupPrefix(int $languageId, string $prefix, int $limit = 10):
$bindings[] = $limit;

$sql = "SELECT DISTINCT le.LeTerm, le.LeDefinition
FROM " . Globals::table('local_dictionary_entries') . " le
INNER JOIN " . Globals::table('local_dictionaries') . " ld ON le.LeLdID = ld.LdID
FROM local_dictionary_entries le
INNER JOIN local_dictionaries ld ON le.LeLdID = ld.LdID
WHERE ld.LdLgID = ? AND ld.LdEnabled = 1 AND le.LeTermLc LIKE ?"
. $userScope
. " ORDER BY le.LeTermLc ASC
Expand Down Expand Up @@ -552,8 +552,8 @@ public function createVocabularyFromEntries(int $dictId, int $languageId): int
{
$this->assertOwnsDictionary($dictId);

$entriesTable = Globals::table('local_dictionary_entries');
$wordsTable = Globals::table('words');
$entriesTable = 'local_dictionary_entries';
$wordsTable = 'words';

$bindings = [$languageId, $dictId];
$userColumn = UserScopedQuery::insertColumn('words');
Expand Down Expand Up @@ -603,8 +603,8 @@ public function createVocabularyFromEntries(int $dictId, int $languageId): int
*/
private function linkOccurrencesForLanguage(int $languageId): void
{
$occurrencesTable = Globals::table('word_occurrences');
$wordsTable = Globals::table('words');
$occurrencesTable = 'word_occurrences';
$wordsTable = 'words';

Connection::preparedExecute(
"UPDATE {$occurrencesTable} o
Expand Down Expand Up @@ -779,7 +779,7 @@ private function insertBatch(array $batch): void
$values[] = $pos;
}

$sql = "INSERT INTO " . Globals::table('local_dictionary_entries') .
$sql = "INSERT INTO local_dictionary_entries" .
" (" . implode(', ', $columns) . ") VALUES " .
implode(', ', $placeholders);

Expand Down
12 changes: 3 additions & 9 deletions src/Modules/Home/Application/HomeFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Home Facade
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Home\Application
Expand Down Expand Up @@ -92,14 +92,8 @@ public function getDatabaseSize(): float
'words', 'word_tag_map'
];

// Use Globals::table() to get properly prefixed table names
$prefixedTables = array_map(
fn($table) => Globals::table($table),
$tableNames
);

$placeholders = implode(', ', array_fill(0, count($prefixedTables), '?'));
$bindings = array_merge([$dbname], $prefixedTables);
$placeholders = implode(', ', array_fill(0, count($tableNames), '?'));
$bindings = array_merge([$dbname], $tableNames);

/** @var mixed $sizeRaw */
$sizeRaw = Connection::preparedFetchValue(
Expand Down
3 changes: 1 addition & 2 deletions src/Modules/Text/Application/Services/AnnotationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This service contains functions for creating, saving, and managing
* text annotations for the print/improved view.
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Text\Application\Services
Expand All @@ -20,7 +20,6 @@

namespace Lwt\Modules\Text\Application\Services;

use Lwt\Shared\Infrastructure\Globals;
use Lwt\Shared\Infrastructure\Utilities\StringUtils;
use Lwt\Shared\Infrastructure\Utilities\ErrorHandler;
use Lwt\Shared\Infrastructure\Database\Connection;
Expand Down
3 changes: 1 addition & 2 deletions src/Modules/Text/Application/Services/TextDisplayService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Text Display Service - Business logic for displaying annotated texts
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Text\Application\Services
Expand All @@ -17,7 +17,6 @@

namespace Lwt\Modules\Text\Application\Services;

use Lwt\Shared\Infrastructure\Globals;
use Lwt\Shared\Infrastructure\Database\Connection;
use Lwt\Shared\Infrastructure\Database\QueryBuilder;
use Lwt\Shared\Infrastructure\Database\Settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Text Navigation Service - Navigation utilities for previous/next texts.
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Text\Application\Services
Expand All @@ -17,7 +17,6 @@

namespace Lwt\Modules\Text\Application\Services;

use Lwt\Shared\Infrastructure\Globals;
use Lwt\Shared\Infrastructure\Http\InputValidator;
use Lwt\Shared\Infrastructure\Database\Connection;
use Lwt\Shared\Infrastructure\Database\QueryBuilder;
Expand Down
3 changes: 1 addition & 2 deletions src/Modules/Text/Application/Services/TextPrintService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Handles print operations for both plain text and improved annotated text.
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Text\Application\Services
Expand All @@ -19,7 +19,6 @@

namespace Lwt\Modules\Text\Application\Services;

use Lwt\Shared\Infrastructure\Globals;
use Lwt\Shared\Infrastructure\Database\Connection;
use Lwt\Shared\Infrastructure\Database\QueryBuilder;
use Lwt\Shared\Infrastructure\Database\Settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* This service handles text statistics, word counts, and "words to do" progress tracking.
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Text\Application\Services
Expand All @@ -19,7 +19,6 @@

namespace Lwt\Modules\Text\Application\Services;

use Lwt\Shared\Infrastructure\Globals;
use Lwt\Shared\Infrastructure\Database\Connection;
use Lwt\Shared\Infrastructure\Database\QueryBuilder;
use Lwt\Shared\Infrastructure\Database\Settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Expression Service - Multi-word expression handling
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Modules\Vocabulary\Application\Services
Expand All @@ -17,7 +17,6 @@

namespace Lwt\Modules\Vocabulary\Application\Services;

use Lwt\Shared\Infrastructure\Globals;
use Lwt\Shared\Infrastructure\Utilities\StringUtils;
use Lwt\Shared\Infrastructure\Database\Connection;
use Lwt\Shared\Infrastructure\Database\Escaping;
Expand Down
5 changes: 3 additions & 2 deletions src/Shared/Infrastructure/Bootstrap/SessionBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* \file
* \brief Session bootstrap class - handles PHP session initialization.
*
* PHP version 8.1
* PHP version 8.2
*
* @category Lwt
* @package Lwt\Shared\Infrastructure\Bootstrap
Expand Down Expand Up @@ -137,7 +137,8 @@ public static function startSession(): void
*/
public static function bootstrap(): void
{
self::setErrorReporting(Globals::isErrorDisplayEnabled());
// Errors are logged, never displayed: output would corrupt HTML and API responses.
self::setErrorReporting(false);
self::setConfigurationOptions();
// Start a PHP session if not one already exists
if (\session_id() == '') {
Expand Down
Loading