mirror of
https://github.com/standardebooks/web.git
synced 2025-07-19 04:44:48 -04:00
Fix broken updated timestamps in OPDS feeds, and fix and add some type hints.
This commit is contained in:
parent
34e35194d8
commit
06b82cdaaa
15 changed files with 344 additions and 300 deletions
|
@ -1,10 +1,8 @@
|
|||
<?
|
||||
use Safe\DateTimeImmutable;
|
||||
use function Safe\file_get_contents;
|
||||
|
||||
class AtomFeed extends Feed{
|
||||
public string $Id;
|
||||
public ?DateTimeImmutable $Updated = null;
|
||||
public ?string $Subtitle = null;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?
|
||||
// Composer auto-loads the lib/ directory in composer.json
|
||||
// Composer auto-loads the `lib/` directory in `composer.json`.
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use function Safe\error_log;
|
||||
|
@ -74,8 +74,7 @@ if($GLOBALS['User'] === null){
|
|||
$httpBasicAuthLogin = $_SERVER['PHP_AUTH_USER'] ?? null;
|
||||
|
||||
if($httpBasicAuthLogin !== null){
|
||||
// If there's no logged in user, but a username was sent via HTTP basic auth,
|
||||
// log them in while we're here.
|
||||
// If there's no logged in user, but a username was sent via HTTP basic auth, log them in while we're here.
|
||||
|
||||
$session = new Session();
|
||||
try{
|
||||
|
@ -90,7 +89,7 @@ if($GLOBALS['User'] === null){
|
|||
$GLOBALS['User'] = $session->User;
|
||||
}
|
||||
catch(Exception){
|
||||
// Do nothing
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
use Safe\DateTimeImmutable;
|
||||
|
||||
class InvalidEbookRepoFilesystemPathException extends AppException{
|
||||
/** @var string $message */
|
||||
protected $message = 'Invalid RepoFilesystemPath.';
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
<?
|
||||
use Safe\DateTimeImmutable;
|
||||
|
||||
use function Safe\exec;
|
||||
use function Safe\file_get_contents;
|
||||
use function Safe\file_put_contents;
|
||||
use function Safe\tempnam;
|
||||
use function Safe\unlink;
|
||||
|
||||
class Feed{
|
||||
abstract class Feed{
|
||||
public string $Url;
|
||||
public string $Title;
|
||||
/** @var array<Ebook|OpdsNavigationEntry> $Entries */
|
||||
|
@ -13,6 +15,7 @@ class Feed{
|
|||
public string $Path;
|
||||
public ?string $Stylesheet = null;
|
||||
protected ?string $XmlString = null;
|
||||
public ?DateTimeImmutable $Updated = null;
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
|
@ -32,6 +35,8 @@ class Feed{
|
|||
// METHODS
|
||||
// *******
|
||||
|
||||
abstract public function SaveIfChanged(): bool;
|
||||
|
||||
protected function CleanXmlString(string $xmlString): string{
|
||||
$tempFilename = tempnam('/tmp/', 'se-');
|
||||
file_put_contents($tempFilename, $xmlString);
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?
|
||||
use Safe\DateTimeImmutable;
|
||||
|
||||
use function Safe\file_get_contents;
|
||||
use function Safe\filesize;
|
||||
use function Safe\preg_replace;
|
||||
|
|
|
@ -145,13 +145,16 @@ class User{
|
|||
}
|
||||
|
||||
/**
|
||||
* Get a `User` if they are considered "registered".
|
||||
*
|
||||
* We consider a `User` "registered" if they have a row in the `Benefits` table. Emails without that row may only be signed up for the newsletter, and thus are not considered to be "registered" users.
|
||||
*
|
||||
* @param ?string $identifier Either an email or a UUID (i.e., an api key).
|
||||
*
|
||||
* @throws Exceptions\UserNotFoundException
|
||||
* @throws Exceptions\PasswordRequiredException
|
||||
*/
|
||||
public static function GetIfRegistered(?string $identifier, ?string $password = null): User{
|
||||
// We consider a user "registered" if they have a row in the Benefits table.
|
||||
// Emails without that row may only be signed up for the newsletter and thus are not "registered" users
|
||||
// The identifier is either an email or a UUID (api key)
|
||||
if($identifier === null){
|
||||
throw new Exceptions\UserNotFoundException();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue