Commit graph

2022 commits

Author SHA1 Message Date
Mike Colagrosso
5b1bb2a9f0 Change tag type from string to enum (TagType) 2024-11-04 13:16:56 -06:00
Mike Colagrosso
59eee3cc57 Explicitly set sort order for sources, contributors, and toc entries
This is just to avoid any future undefined behavior. The current DB table implementation returns these rows in insertion order, but it might not be wise to depend on that. Either way, the result sets of these queries are small and can be sorted quickly.
2024-11-04 13:16:56 -06:00
Mike Colagrosso
7d8cfd351e Ebook tags: Store UrlName so it can be queried 2024-11-04 13:16:56 -06:00
Mike Colagrosso
7339255d5f FilterEbooks: Require an exact match for search 2024-11-04 13:16:56 -06:00
Mike Colagrosso
9a4da8f961 Fix PHPStan errors for CollectionType enum
Use the `value` property of PHP enums to get the underlying string for functions that expect a string.

Followup to #392
2024-11-04 13:16:56 -06:00
Mike Colagrosso
b792dec9e5 Make collection type (series, set) an enum 2024-11-04 13:16:56 -06:00
Mike Colagrosso
d3b7f5015a Move array definition to the function that uses it 2024-11-04 13:16:56 -06:00
Mike Colagrosso
c8d5dfb11f Add properties that were previously omitted
PHP 8.3 (part of Ubuntu 24.04) outputs a deprecated warning for properties that
were not in the class definition. Error below. There were a few of these
missing from the `Ebook`, `GitCommit`, `CollectionMembership`, `EbookSource`,
and `Contributor` classes. Adding them doesn't change any functionality, but it
does make it clearer what properties a class has.

Some of these properties are never set for `Ebook` instances created from the
filesystem, i.e., `Created` and `Updated`, and some of them need to be manually
set to make `Ebook` instances from the filesystem and the database match, e.g.,
`GitCommitId`, `CollectionEbookId`, `EbookSourceId`, and `ContributorId`.
Making the `Ebook` instances from the filesystem and the database match each
other makes it easier to spot bugs in the future.

Previous errors with PHP 8.3:

```
PHP Deprecated:  Creation of dynamic property Ebook::$Created is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42
PHP Deprecated:  Creation of dynamic property Ebook::$Updated is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42
PHP Deprecated:  Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property GitCommit::$GitCommitId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property GitCommit::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property CollectionMembership::$CollectionEbookId is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42
PHP Deprecated:  Creation of dynamic property CollectionMembership::$EbookId is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42
PHP Deprecated:  Creation of dynamic property CollectionMembership::$CollectionId is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php on line 42
PHP Deprecated:  Creation of dynamic property EbookSource::$EbookSourceId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property EbookSource::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property EbookSource::$EbookSourceId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property EbookSource::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property Contributor::$ContributorId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property Contributor::$EbookId is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
PHP Deprecated:  Creation of dynamic property Contributor::$SortOrder is deprecated in /standardebooks.org/web/lib/DbConnection.php on line 286
```
2024-11-04 13:16:56 -06:00
Mike Colagrosso
a9a0782946 Timestamps: Set DEFAULT and ON UPDATE values
Newer versions of MariaDB, such as this one included with Ubuntu 24.04:

    Server version: 10.11.8-MariaDB-0ubuntu0.24.04.1 Ubuntu 24.04

change the default behavior to not automatically set timestamp defaults and on update values:

    $ mysqld --verbose --help | grep explicit-defaults-for-timestamp
    explicit-defaults-for-timestamp                              TRUE

whereas my older machines allowed it:

    $ mysqld --verbose --help | grep explicit-defaults-for-timestamp
    explicit-defaults-for-timestamp                              FALSE

More background on the flag here:

    https://dev.mysql.com/doc/refman/8.4/en/timestamp-initialization.html
2024-11-04 13:16:56 -06:00
Mike Colagrosso
e9a8c9f595 Don't call rebuild-cache library from deploy
Should have put this change in #384
2024-11-04 13:16:56 -06:00
Mike Colagrosso
ec26e7f9af Remove Library::RebuildCache 2024-11-04 13:16:56 -06:00
Mike Colagrosso
f4a19a2d12 Replace GetEbooksFromFilesystem with a DB implementation 2024-11-04 13:16:56 -06:00
Mike Colagrosso
364a2ca78f Rename GetAllArtists to GetArtists 2024-11-04 13:16:56 -06:00
Mike Colagrosso
41b4c0f8f6 Replace Created with EbookCreated for publication date 2024-11-04 13:16:56 -06:00
Mike Colagrosso
ab95722f1e Replace Collections with CollectionMemberships missed in #374 2024-11-04 13:16:56 -06:00
Mike Colagrosso
2613871e2d Replace LocTags with LocSubjects missed in #351 2024-11-04 13:16:56 -06:00
Mike Colagrosso
6c8e819316 Implement OpenSearch feed search with FilterEbooks 2024-11-04 13:16:56 -06:00
Mike Colagrosso
e06fd910ed Removed unused function Ebook::IsInCollection() 2024-11-04 13:16:56 -06:00
Mike Colagrosso
807e8410b4 Use array shapes in the PHPDoc
This makes the extra documentation unnecessary
2024-11-04 13:16:56 -06:00
Mike Colagrosso
e5fc21ffd3 Remove unneeded HasTag() method
It was used in APCu search before the DB
2024-11-04 13:16:56 -06:00
Mike Colagrosso
989dcab9f0 Implement FilterEbooks via DB 2024-11-04 13:16:56 -06:00
Mike Colagrosso
d9b6e3020c IndexableText improvements
Description and LongDescription were adding too many extraneous matches. Maintain
how special characters are handled in search currently.
2024-11-04 13:16:56 -06:00
Mike Colagrosso
4abf6e29d2 Add an index for EbookCreated
This is the default sort on /ebooks, so it should have an index
2024-11-04 13:16:56 -06:00
Mike Colagrosso
be6873d21d Remove distinct from query in GetEbookCollections
The point of the commits in #374, e.g., the new `CollectionEbooks` table, was so that `distinct` wasn't needed.
2024-11-04 13:16:56 -06:00
Mike Colagrosso
50aa81cb29 Create a helper function for SQL set membership 2024-11-04 13:16:56 -06:00
Mike Colagrosso
44dc65005d Query Contributors table for GetEbooksByAuthor() 2024-11-04 13:16:56 -06:00
Mike Colagrosso
2d5e66f2f2 Get carousel books from the DB 2024-11-04 13:16:56 -06:00
Mike Colagrosso
402dae95ff Add a Type enum to Tags for artwork/ebook 2024-11-04 13:16:56 -06:00
Mike Colagrosso
ee29c526f8 Add a CollectionMembership class 2024-11-04 13:16:56 -06:00
Mike Colagrosso
a25660bc8b Split Collections into two tables 2024-11-04 13:16:56 -06:00
Mike Colagrosso
d5748d1006 update-ebook-database: Keys aren't always integers 2024-11-04 13:16:56 -06:00
Mike Colagrosso
4d321061c5 Use ::class names instead of strings in LocSubject and EbookTag 2024-11-04 13:16:56 -06:00
Mike Colagrosso
43416e76db Get list of tags from DB 2024-11-04 13:16:56 -06:00
Mike Colagrosso
b3a173aa91 Get ebooks in a collection from DB 2024-11-04 13:16:56 -06:00
Mike Colagrosso
da68637ba0 Get list of collections from DB 2024-11-04 13:16:56 -06:00
Mike Colagrosso
4653b15288 Get ebook from DB for artworks 2024-11-04 13:16:56 -06:00
Mike Colagrosso
c85db527cf Get ebook from DB for downloads 2024-11-04 13:16:56 -06:00
Mike Colagrosso
252d17340f Fix bug from porting the logic from TitleWithCreditsHtml and ContributorsHtml 2024-11-04 13:16:56 -06:00
Mike Colagrosso
415faeb19d Remove unused import that should have been in #371 2024-11-04 13:16:56 -06:00
Mike Colagrosso
1fd3688621 Use Ebook::GetByIdentifier() to read ebooks 2024-11-04 13:16:56 -06:00
Mike Colagrosso
b176a68d4d Replace TextSinglePageSizeNumber and TextSinglePageSizeUnit with TextSinglePageSizeFormatted 2024-11-04 13:16:56 -06:00
Mike Colagrosso
1589dda35c Correct errors found in #336 2024-11-04 13:16:56 -06:00
Mike Colagrosso
4e7f6cfc88 Adds a validator in ./scripts/update-ebook-db to compare
It compares objects from `Ebook::FromFilesystem()` and `Ebook::GetByIdentifier()` to confirm there are no differences.
2024-11-04 13:16:56 -06:00
Mike Colagrosso
fc4a509b0d Don't call update-ebook-database with verbose flag
`./scripts/update-ebook-database --verbose` should be for low-level debugging only
2024-11-04 13:16:56 -06:00
Mike Colagrosso
2098b265a8 Rename the constructor Ebook::__construct() to static Ebook::FromFilesystem()
Also added `GetFoo()` methods for all the derived properties like `GetUrl()`, `GetHasDownloads()`, etc. Removed that logic from the constructor so that it's reusable in `Ebook::FromFilesystem()` and `Ebook::GetByIdentifier()`
2024-11-04 13:16:56 -06:00
Mike Colagrosso
f605a4df60 Rename Created and Updated in PHP code to EbookCreated and EbookUpdated to match the schema 2024-11-04 13:16:56 -06:00
Mike Colagrosso
ac7db8d375 Add primary keys to LocSubjects and Tags tables
Missed these before, and in addition to being a good practice, they are needed to maintain insertion order of LocSubjects and Tags.
2024-11-04 13:16:56 -06:00
Mike Colagrosso
dc62553269 Remove leading slash from exceptions in lib/Exceptions 2024-11-04 13:16:56 -06:00
Mike Colagrosso
5c69923176 Workaround a bug in Safe-PHP causes PHPStan errors 2024-11-04 13:16:56 -06:00
Mike Colagrosso
72d679a04f Fix PHPStan errors 2024-11-04 13:16:56 -06:00