Commit graph

97 commits

Author SHA1 Message Date
Mike Colagrosso
0eaf2e8e47 Handle nullable and non-nullable validation consistently 2024-11-04 13:16:56 -06:00
Mike Colagrosso
8a61713fa4 Ebook validation: Trim properties that are present 2024-11-04 13:16:56 -06:00
Mike Colagrosso
93857641de Clean up line breaks on DELETE statements 2024-11-04 13:16:56 -06:00
Mike Colagrosso
2378320d0c Contributor, EbookSource, GitCommit: Move INSERT statements to Create() methods 2024-11-04 13:16:56 -06:00
Mike Colagrosso
4aefe412f9 Pass enum to Db::Query, not its value 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
b792dec9e5 Make collection type (series, set) an enum 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
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
e5fc21ffd3 Remove unneeded HasTag() method
It was used in APCu search before the 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
ee29c526f8 Add a CollectionMembership class 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
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
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
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
Mike Colagrosso
032032b920 Additional Ebook validation 2024-11-04 13:16:56 -06:00
Mike Colagrosso
3ef1af1237 Add @throws to Ebook::GetByIdentifier 2024-11-04 13:16:56 -06:00
Mike Colagrosso
196f5ae573 Ebook::GetByIdentifier can't return null 2024-11-04 13:16:56 -06:00
Mike Colagrosso
572fd90fed Replace Library::GetEbookByIdentifier with Ebook::GetByIdentifier
The new method throws an exception instead of returning null.
2024-11-04 13:16:56 -06:00
Mike Colagrosso
f736c20e3b Fix error found by PHPStan
PHPStan doesn't think that Identifier can be null:

```
549    Strict comparison using === between string and null will always evaluate to false.
```
2024-11-04 13:16:56 -06:00
Mike Colagrosso
cc8de11ca4 Replace static GetOrCreate with GetByNameOrCreate 2024-11-04 13:16:56 -06:00
Mike Colagrosso
63d411a2e6 Initial code changes to insert/update Ebook records 2024-11-04 13:16:56 -06:00
Alex Cabal
70ae877dd8 Bump PHPStan check level to max and add final round of type hints 2024-05-13 10:48:05 -05:00
Alex Cabal
703e1a7a03 Continue improving type hints 2024-05-10 23:38:57 -05:00
Alex Cabal
c4c8e7353f Enable strict exception type hint checking in PHPStan and add exception type hints 2024-05-10 20:47:36 -05:00
Alex Cabal
e55fecaaa2 Switch from DateTime to DateTimeImmutable across codebase 2024-04-13 14:05:14 -05:00
Mike Colagrosso
29fc6f9ff2 Update AlternateTitle to parse dcterms:alternate 2024-02-25 15:43:47 -06:00
Alex Cabal
2b47b65437 Clean up function imports 2024-01-31 10:28:22 -06:00
Mike Colagrosso
09b4385100 Convert SOURCE_ constants to an enum 2024-01-30 11:10:05 -06:00
Alex Cabal
ca3fc6dbfd Refactor HttpInput::Str and rename some exceptions for consistency 2024-01-18 11:21:05 -06:00
Alex Cabal
f7ff76bf7d Rename some Formatter functions for clarity 2024-01-17 16:04:30 -06:00
Alex Cabal
783c09864f Add type hints for remaining classes 2024-01-08 16:08:57 -06:00
Mike Colagrosso
6a5c05511a Add cover art database
Co-authored-by: Job Curtis <job.curtis@gmail.com>
Co-authored-by: Alex Cabal <alex@standardebooks.org>
2024-01-03 19:14:04 -06:00
Alex Cabal
65c4578a4e Handle exception for a possible attack vector 2023-07-20 15:05:24 -05:00
Alex Cabal
bd4b8d8944 Some type check fixes 2023-06-21 11:01:43 -05:00
Alex Cabal
8127f0c7e2 Remove unused exception variables, now that this is possible with PHP8 2023-06-06 21:00:12 -05:00
Alex Cabal
8d8de1e062 Fix reading ease description calculation 2023-03-16 11:40:58 -05:00
Alex Cabal
cee4517517 Suppress PHP warnings that are handled by PHP Safe 2023-01-30 16:37:45 -06:00
Alex Cabal
04759aa17b Add size warning when single-page download is larger than 1MB 2023-01-13 16:42:57 -06:00
Alex Cabal
c2dabfbe2d Add comment for clarity 2022-07-27 11:30:56 -05:00
Weijia Cheng
f2ffacdff8 Restrict Internet Archive source to scans only 2022-07-27 11:29:12 -05:00
Alex Cabal
885b8745e7 Default to author name if no file-as found 2022-07-14 12:55:09 -05:00
Alex Cabal
011cd747f1 Convert newsletter to use Users table as base 2022-07-04 12:09:49 -05:00
Alex Cabal
6c8414f844 Update PropertiesBase to new patterns and improve static analysis checks 2022-06-30 13:23:05 -05:00