From 787c36201072efeab07dff480c9329d4f0e98e73 Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Thu, 5 Sep 2024 15:19:56 -0400 Subject: [PATCH 001/139] Use local password hash service instead of laminas-crypt. (#3888) --- module/VuFind/config/module.config.php | 1 + module/VuFind/src/VuFind/Auth/Database.php | 25 ++++-- .../src/VuFind/Auth/DatabaseFactory.php | 73 +++++++++++++++ .../VuFind/src/VuFind/Auth/PluginManager.php | 4 +- .../VuFind/Controller/InstallController.php | 11 +-- .../src/VuFind/Crypt/PasswordHasher.php | 90 +++++++++++++++++++ 6 files changed, 191 insertions(+), 13 deletions(-) create mode 100644 module/VuFind/src/VuFind/Auth/DatabaseFactory.php create mode 100644 module/VuFind/src/VuFind/Crypt/PasswordHasher.php diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php index 9a74716244e..69508443e7f 100644 --- a/module/VuFind/config/module.config.php +++ b/module/VuFind/config/module.config.php @@ -436,6 +436,7 @@ 'VuFind\Cover\Loader' => 'VuFind\Cover\LoaderFactory', 'VuFind\Cover\Router' => 'VuFind\Cover\RouterFactory', 'VuFind\Crypt\HMAC' => 'VuFind\Crypt\HMACFactory', + 'VuFind\Crypt\PasswordHasher' => 'Laminas\ServiceManager\Factory\InvokableFactory', 'VuFind\Crypt\SecretCalculator' => 'VuFind\Crypt\SecretCalculatorFactory', 'VuFind\Date\Converter' => 'VuFind\Service\DateConverterFactory', 'VuFind\Db\AdapterFactory' => 'VuFind\Service\ServiceWithConfigIniFactory', diff --git a/module/VuFind/src/VuFind/Auth/Database.php b/module/VuFind/src/VuFind/Auth/Database.php index aba9bb09854..e342afe4f7b 100644 --- a/module/VuFind/src/VuFind/Auth/Database.php +++ b/module/VuFind/src/VuFind/Auth/Database.php @@ -31,8 +31,8 @@ namespace VuFind\Auth; -use Laminas\Crypt\Password\Bcrypt; use Laminas\Http\PhpEnvironment\Request; +use VuFind\Crypt\PasswordHasher; use VuFind\Db\Entity\UserEntityInterface; use VuFind\Db\Service\UserServiceInterface; use VuFind\Exception\Auth as AuthException; @@ -54,6 +54,13 @@ */ class Database extends AbstractBase { + /** + * Password hasher + * + * @var PasswordHasher + */ + protected $hasher; + /** * Username * @@ -68,6 +75,16 @@ class Database extends AbstractBase */ protected $password; + /** + * Constructor + * + * @param ?PasswordHasher $hasher Password hash service (null to create one) + */ + public function __construct(?PasswordHasher $hasher = null) + { + $this->hasher = $hasher ?? new PasswordHasher(); + } + /** * Attempt to authenticate the current user. Throws exception if login fails. * @@ -121,8 +138,7 @@ protected function passwordHashingEnabled() protected function setUserPassword(UserEntityInterface $user, string $pass): void { if ($this->passwordHashingEnabled()) { - $bcrypt = new Bcrypt(); - $user->setPasswordHash($bcrypt->create($pass)); + $user->setPasswordHash($this->hasher->create($pass)); } else { $user->setRawPassword($pass); } @@ -300,8 +316,7 @@ protected function checkPassword($password, $userRow) ); } - $bcrypt = new Bcrypt(); - return $bcrypt->verify($password, $userRow->getPasswordHash() ?? ''); + return $this->hasher->verify($password, $userRow->getPasswordHash() ?? ''); } // Default case: unencrypted passwords: diff --git a/module/VuFind/src/VuFind/Auth/DatabaseFactory.php b/module/VuFind/src/VuFind/Auth/DatabaseFactory.php new file mode 100644 index 00000000000..a8e0d0af016 --- /dev/null +++ b/module/VuFind/src/VuFind/Auth/DatabaseFactory.php @@ -0,0 +1,73 @@ + + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ + +namespace VuFind\Auth; + +use Laminas\ServiceManager\Exception\ServiceNotCreatedException; +use Laminas\ServiceManager\Exception\ServiceNotFoundException; +use Psr\Container\ContainerExceptionInterface as ContainerException; +use Psr\Container\ContainerInterface; +use VuFind\Crypt\PasswordHasher; + +/** + * Factory for Database authentication module. + * + * @category VuFind + * @package Authentication + * @author Demian Katz + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ +class DatabaseFactory implements \Laminas\ServiceManager\Factory\FactoryInterface +{ + /** + * Create an object + * + * @param ContainerInterface $container Service manager + * @param string $requestedName Service being created + * @param null|array $options Extra options (optional) + * + * @return object + * + * @throws ServiceNotFoundException if unable to resolve the service. + * @throws ServiceNotCreatedException if an exception is raised when + * creating a service. + * @throws ContainerException&\Throwable if any other error occurs + */ + public function __invoke( + ContainerInterface $container, + $requestedName, + array $options = null + ) { + if (!empty($options)) { + throw new \Exception('Unexpected options sent to factory.'); + } + return new $requestedName($container->get(PasswordHasher::class)); + } +} diff --git a/module/VuFind/src/VuFind/Auth/PluginManager.php b/module/VuFind/src/VuFind/Auth/PluginManager.php index c7f480b75c9..6772f100d06 100644 --- a/module/VuFind/src/VuFind/Auth/PluginManager.php +++ b/module/VuFind/src/VuFind/Auth/PluginManager.php @@ -29,8 +29,6 @@ namespace VuFind\Auth; -use Laminas\ServiceManager\Factory\InvokableFactory; - /** * Auth handler plugin manager * @@ -75,7 +73,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager AlmaDatabase::class => ILSFactory::class, CAS::class => CASFactory::class, ChoiceAuth::class => ChoiceAuthFactory::class, - Database::class => InvokableFactory::class, + Database::class => DatabaseFactory::class, Email::class => EmailFactory::class, Facebook::class => FacebookFactory::class, ILS::class => ILSFactory::class, diff --git a/module/VuFind/src/VuFind/Controller/InstallController.php b/module/VuFind/src/VuFind/Controller/InstallController.php index 897cb57a57c..129a6546bc1 100644 --- a/module/VuFind/src/VuFind/Controller/InstallController.php +++ b/module/VuFind/src/VuFind/Controller/InstallController.php @@ -29,9 +29,9 @@ namespace VuFind\Controller; -use Laminas\Crypt\Password\Bcrypt; use Laminas\Mvc\MvcEvent; use VuFind\Config\Writer as ConfigWriter; +use VuFind\Crypt\PasswordHasher; use VuFind\Db\Service\TagServiceInterface; use VuFind\Db\Service\UserCardServiceInterface; use VuFind\Db\Service\UserServiceInterface; @@ -811,18 +811,19 @@ public function performsecurityfixAction() // Now we want to loop through the database and update passwords (if // necessary). $ilsAuthenticator = $this->getService(\VuFind\Auth\ILSAuthenticator::class); - $userRows = $this->getDbService(UserServiceInterface::class)->getInsecureRows(); + $userService = $this->getDbService(UserServiceInterface::class); + $userRows = $userService->getInsecureRows(); if (count($userRows) > 0) { - $bcrypt = new Bcrypt(); + $hasher = $this->getService(PasswordHasher::class); foreach ($userRows as $row) { if ($row->getRawPassword() != '') { - $row->setPasswordHash($bcrypt->create($row->getRawPassword())); + $row->setPasswordHash($hasher->create($row->getRawPassword())); $row->setRawPassword(''); } if ($rawPassword = $row->getRawCatPassword()) { $ilsAuthenticator->saveUserCatalogCredentials($row, $row->getCatUsername(), $rawPassword); } else { - $row->save(); + $userService->persistEntity($row); } } $msg = count($userRows) . ' user row(s) encrypted.'; diff --git a/module/VuFind/src/VuFind/Crypt/PasswordHasher.php b/module/VuFind/src/VuFind/Crypt/PasswordHasher.php new file mode 100644 index 00000000000..65b7481a551 --- /dev/null +++ b/module/VuFind/src/VuFind/Crypt/PasswordHasher.php @@ -0,0 +1,90 @@ + + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ + +namespace VuFind\Crypt; + +use function password_hash; +use function password_verify; + +use const PASSWORD_BCRYPT; + +/** + * Password hasher + * + * @category VuFind + * @package Crypt + * @author Demian Katz + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ +class PasswordHasher +{ + /** + * Algorithm to use for hashing + * + * @var string + */ + protected string $algorithm = PASSWORD_BCRYPT; + + /** + * Cost of hashing + * + * @var int + */ + protected int $cost = 10; + + /** + * Create a hash from a password + * + * @param string $password Password to hash + * + * @return string + */ + public function create(string $password): string + { + $options = ['cost' => $this->cost]; + return password_hash($password, $this->algorithm, $options); + } + + /** + * Does the provided password match the provided hash value? + * + * @param string $password Password to check + * @param string $hash Hash to compare against + * + * @return bool + */ + public function verify(string $password, string $hash): bool + { + return password_verify($password, $hash); + } +} From 4580d427883dbdbbce0b03ec8775229f25e6b26b Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Thu, 5 Sep 2024 22:22:32 +0300 Subject: [PATCH 002/139] Make it possible to retrieve user's saved searches only (#3905) --- .../VuFind/src/VuFind/Db/Service/SearchService.php | 13 ++++++++++--- .../VuFind/Db/Service/SearchServiceInterface.php | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/module/VuFind/src/VuFind/Db/Service/SearchService.php b/module/VuFind/src/VuFind/Db/Service/SearchService.php index d4a64545a55..96391c87ef2 100644 --- a/module/VuFind/src/VuFind/Db/Service/SearchService.php +++ b/module/VuFind/src/VuFind/Db/Service/SearchService.php @@ -154,17 +154,24 @@ public function getSearchByIdAndOwner( /** * Get an array of rows for the specified user. * - * @param string $sessionId Session ID of current user. + * @param ?string $sessionId Session ID of current user or null to ignore searches in session. * @param UserEntityInterface|int|null $userOrId User entity or ID of current user (optional). * * @return SearchEntityInterface[] */ - public function getSearches(string $sessionId, UserEntityInterface|int|null $userOrId = null): array + public function getSearches(?string $sessionId, UserEntityInterface|int|null $userOrId = null): array { + // If we don't get a session id or user id, don't return anything: + if (null === $sessionId && null === $userOrId) { + return []; + } $uid = $userOrId instanceof UserEntityInterface ? $userOrId->getId() : $userOrId; $callback = function ($select) use ($sessionId, $uid) { - $select->where->equalTo('session_id', $sessionId)->and->equalTo('saved', 0); + if (null !== $sessionId) { + $select->where->equalTo('session_id', $sessionId)->and->equalTo('saved', 0); + } if ($uid !== null) { + // Note: It doesn't hurt to use OR here even if there are no other terms $select->where->OR->equalTo('user_id', $uid); } $select->order('created'); diff --git a/module/VuFind/src/VuFind/Db/Service/SearchServiceInterface.php b/module/VuFind/src/VuFind/Db/Service/SearchServiceInterface.php index 098c70a1cae..52683b5d009 100644 --- a/module/VuFind/src/VuFind/Db/Service/SearchServiceInterface.php +++ b/module/VuFind/src/VuFind/Db/Service/SearchServiceInterface.php @@ -99,7 +99,7 @@ public function getSearchByIdAndOwner( /** * Get an array of rows for the specified user. * - * @param string $sessionId Session ID of current user. + * @param ?string $sessionId Session ID of current user or null to ignore searches in session. * @param UserEntityInterface|int|null $userOrId User entity or ID of current user (optional). * * @return SearchEntityInterface[] From 366b057c57f987418cdb5d7f97c89a39b41f03a2 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Thu, 5 Sep 2024 22:24:33 +0300 Subject: [PATCH 003/139] Use static as return type in db entity interfaces (#3902) --- .../Db/Entity/AccessTokenEntityInterface.php | 12 +-- .../Db/Entity/AuthHashEntityInterface.php | 20 ++--- .../Entity/ChangeTrackerEntityInterface.php | 24 +++--- .../Db/Entity/CommentsEntityInterface.php | 16 ++-- .../Entity/ExternalSessionEntityInterface.php | 12 +-- .../Db/Entity/FeedbackEntityInterface.php | 36 ++++---- .../Db/Entity/LoginTokenEntityInterface.php | 32 +++---- .../Entity/OaiResumptionEntityInterface.php | 8 +- .../Db/Entity/RatingsEntityInterface.php | 16 ++-- .../Db/Entity/RecordEntityInterface.php | 20 ++--- .../Db/Entity/ResourceEntityInterface.php | 24 +++--- .../Db/Entity/ResourceTagsEntityInterface.php | 20 ++--- .../Db/Entity/SearchEntityInterface.php | 40 ++++----- .../Db/Entity/SessionEntityInterface.php | 16 ++-- .../Db/Entity/ShortlinksEntityInterface.php | 12 +-- .../VuFind/Db/Entity/TagsEntityInterface.php | 4 +- .../Db/Entity/UserCardEntityInterface.php | 32 +++---- .../VuFind/Db/Entity/UserEntityInterface.php | 84 +++++++++---------- .../Db/Entity/UserListEntityInterface.php | 20 ++--- .../Db/Entity/UserResourceEntityInterface.php | 20 ++--- .../VuFind/src/VuFind/Db/Row/AccessToken.php | 12 +-- module/VuFind/src/VuFind/Db/Row/AuthHash.php | 20 ++--- .../src/VuFind/Db/Row/ChangeTracker.php | 24 +++--- module/VuFind/src/VuFind/Db/Row/Comments.php | 16 ++-- .../src/VuFind/Db/Row/ExternalSession.php | 14 ++-- module/VuFind/src/VuFind/Db/Row/Feedback.php | 36 ++++---- .../VuFind/src/VuFind/Db/Row/LoginToken.php | 32 +++---- .../src/VuFind/Db/Row/OaiResumption.php | 8 +- module/VuFind/src/VuFind/Db/Row/Ratings.php | 18 ++-- module/VuFind/src/VuFind/Db/Row/Record.php | 20 ++--- module/VuFind/src/VuFind/Db/Row/Resource.php | 24 +++--- .../VuFind/src/VuFind/Db/Row/ResourceTags.php | 22 ++--- module/VuFind/src/VuFind/Db/Row/Search.php | 42 +++++----- module/VuFind/src/VuFind/Db/Row/Session.php | 16 ++-- .../VuFind/src/VuFind/Db/Row/Shortlinks.php | 14 ++-- module/VuFind/src/VuFind/Db/Row/Tags.php | 4 +- module/VuFind/src/VuFind/Db/Row/User.php | 84 +++++++++---------- module/VuFind/src/VuFind/Db/Row/UserCard.php | 32 +++---- module/VuFind/src/VuFind/Db/Row/UserList.php | 20 ++--- .../VuFind/src/VuFind/Db/Row/UserResource.php | 22 ++--- 40 files changed, 474 insertions(+), 474 deletions(-) diff --git a/module/VuFind/src/VuFind/Db/Entity/AccessTokenEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/AccessTokenEntityInterface.php index 01468cfe62e..baa8bd89cfb 100644 --- a/module/VuFind/src/VuFind/Db/Entity/AccessTokenEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/AccessTokenEntityInterface.php @@ -45,18 +45,18 @@ interface AccessTokenEntityInterface extends EntityInterface * * @param ?UserEntityInterface $user User owning token * - * @return AccessTokenEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): AccessTokenEntityInterface; + public function setUser(?UserEntityInterface $user): static; /** * Set data. * * @param string $data Data * - * @return AccessTokenEntityInterface + * @return static */ - public function setData(string $data): AccessTokenEntityInterface; + public function setData(string $data): static; /** * Is the access token revoked? @@ -70,7 +70,7 @@ public function isRevoked(): bool; * * @param bool $revoked Revoked * - * @return AccessTokenEntityInterface + * @return static */ - public function setRevoked(bool $revoked): AccessTokenEntityInterface; + public function setRevoked(bool $revoked): static; } diff --git a/module/VuFind/src/VuFind/Db/Entity/AuthHashEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/AuthHashEntityInterface.php index 36b8cea943e..4d9ed61751d 100644 --- a/module/VuFind/src/VuFind/Db/Entity/AuthHashEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/AuthHashEntityInterface.php @@ -61,9 +61,9 @@ public function getSessionId(): ?string; * * @param ?string $sessionId PHP Session id string * - * @return AuthHashEntityInterface + * @return static */ - public function setSessionId(?string $sessionId): AuthHashEntityInterface; + public function setSessionId(?string $sessionId): static; /** * Get hash value. @@ -77,9 +77,9 @@ public function getHash(): string; * * @param string $hash Hash Value * - * @return AuthHashEntityInterface + * @return static */ - public function setHash(string $hash): AuthHashEntityInterface; + public function setHash(string $hash): static; /** * Get type of hash. @@ -93,9 +93,9 @@ public function getHashType(): ?string; * * @param ?string $type Hash Type * - * @return AuthHashEntityInterface + * @return static */ - public function setHashType(?string $type): AuthHashEntityInterface; + public function setHashType(?string $type): static; /** * Get data. @@ -109,9 +109,9 @@ public function getData(): ?string; * * @param ?string $data Data * - * @return AuthHashEntityInterface + * @return static */ - public function setData(?string $data): AuthHashEntityInterface; + public function setData(?string $data): static; /** * Get created date. @@ -125,7 +125,7 @@ public function getCreated(): DateTime; * * @param DateTime $dateTime Created date * - * @return AuthHashEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): AuthHashEntityInterface; + public function setCreated(DateTime $dateTime): static; } diff --git a/module/VuFind/src/VuFind/Db/Entity/ChangeTrackerEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/ChangeTrackerEntityInterface.php index 9dc5559c092..90afc00a5d2 100644 --- a/module/VuFind/src/VuFind/Db/Entity/ChangeTrackerEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/ChangeTrackerEntityInterface.php @@ -47,9 +47,9 @@ interface ChangeTrackerEntityInterface extends EntityInterface * * @param string $id Id * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setId(string $id): ChangeTrackerEntityInterface; + public function setId(string $id): static; /** * Getter for identifier. @@ -63,9 +63,9 @@ public function getId(): string; * * @param string $name Index name * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setIndexName(string $name): ChangeTrackerEntityInterface; + public function setIndexName(string $name): static; /** * Getter for index name (formerly core). @@ -79,9 +79,9 @@ public function getIndexName(): string; * * @param ?DateTime $dateTime Time first added to index. * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setFirstIndexed(?DateTime $dateTime): ChangeTrackerEntityInterface; + public function setFirstIndexed(?DateTime $dateTime): static; /** * FirstIndexed getter. @@ -95,9 +95,9 @@ public function getFirstIndexed(): ?DateTime; * * @param ?DateTime $dateTime Last time changed in index. * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setLastIndexed(?DateTime $dateTime): ChangeTrackerEntityInterface; + public function setLastIndexed(?DateTime $dateTime): static; /** * LastIndexed getter. @@ -111,9 +111,9 @@ public function getLastIndexed(): ?DateTime; * * @param ?DateTime $dateTime Last time original record was edited * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setLastRecordChange(?DateTime $dateTime): ChangeTrackerEntityInterface; + public function setLastRecordChange(?DateTime $dateTime): static; /** * LastRecordChange getter. @@ -127,9 +127,9 @@ public function getLastRecordChange(): ?DateTime; * * @param ?DateTime $dateTime Time record was removed from index * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setDeleted(?DateTime $dateTime): ChangeTrackerEntityInterface; + public function setDeleted(?DateTime $dateTime): static; /** * Deleted getter. diff --git a/module/VuFind/src/VuFind/Db/Entity/CommentsEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/CommentsEntityInterface.php index aaaf17680b8..892c68632a7 100644 --- a/module/VuFind/src/VuFind/Db/Entity/CommentsEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/CommentsEntityInterface.php @@ -54,9 +54,9 @@ public function getId(): int; * * @param string $comment Comment * - * @return Comments + * @return static */ - public function setComment(string $comment): CommentsEntityInterface; + public function setComment(string $comment): static; /** * Comment getter @@ -70,9 +70,9 @@ public function getComment(): string; * * @param DateTime $dateTime Created date * - * @return Comments + * @return static */ - public function setCreated(DateTime $dateTime): CommentsEntityInterface; + public function setCreated(DateTime $dateTime): static; /** * Created getter @@ -86,9 +86,9 @@ public function getCreated(): DateTime; * * @param ?UserEntityInterface $user User that created comment * - * @return Comments + * @return static */ - public function setUser(?UserEntityInterface $user): CommentsEntityInterface; + public function setUser(?UserEntityInterface $user): static; /** * User getter @@ -102,7 +102,7 @@ public function getUser(): ?UserEntityInterface; * * @param ResourceEntityInterface $resource Resource id. * - * @return Comments + * @return static */ - public function setResource(ResourceEntityInterface $resource): CommentsEntityInterface; + public function setResource(ResourceEntityInterface $resource): static; } diff --git a/module/VuFind/src/VuFind/Db/Entity/ExternalSessionEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/ExternalSessionEntityInterface.php index b71efd39945..5ef2136f25d 100644 --- a/module/VuFind/src/VuFind/Db/Entity/ExternalSessionEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/ExternalSessionEntityInterface.php @@ -61,9 +61,9 @@ public function getSessionId(): string; * * @param string $sessionId PHP session id string * - * @return ExternalSessionEntityInterface + * @return static */ - public function setSessionId(string $sessionId): ExternalSessionEntityInterface; + public function setSessionId(string $sessionId): static; /** * Get external session id string. @@ -77,9 +77,9 @@ public function getExternalSessionId(): string; * * @param string $externalSessionId External session id string * - * @return ExternalSessionEntityInterface + * @return static */ - public function setExternalSessionId(string $externalSessionId): ExternalSessionEntityInterface; + public function setExternalSessionId(string $externalSessionId): static; /** * Get created date. @@ -93,7 +93,7 @@ public function getCreated(): DateTime; * * @param DateTime $dateTime Created date * - * @return ExternalSessionEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): ExternalSessionEntityInterface; + public function setCreated(DateTime $dateTime): static; } diff --git a/module/VuFind/src/VuFind/Db/Entity/FeedbackEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/FeedbackEntityInterface.php index b7f91118c4b..4f75f29fa77 100644 --- a/module/VuFind/src/VuFind/Db/Entity/FeedbackEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/FeedbackEntityInterface.php @@ -54,9 +54,9 @@ public function getId(): int; * * @param string $message Message * - * @return FeedbackEntityInterface + * @return static */ - public function setMessage(string $message): FeedbackEntityInterface; + public function setMessage(string $message): static; /** * Message getter @@ -70,9 +70,9 @@ public function getMessage(): string; * * @param array $data Form data * - * @return FeedbackEntityInterface + * @return static */ - public function setFormData(array $data): FeedbackEntityInterface; + public function setFormData(array $data): static; /** * Form data getter @@ -86,9 +86,9 @@ public function getFormData(): array; * * @param string $name Form name * - * @return FeedbackEntityInterface + * @return static */ - public function setFormName(string $name): FeedbackEntityInterface; + public function setFormName(string $name): static; /** * Form name getter @@ -102,9 +102,9 @@ public function getFormName(): string; * * @param DateTime $dateTime Created date * - * @return FeedbackEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): FeedbackEntityInterface; + public function setCreated(DateTime $dateTime): static; /** * Created getter @@ -118,9 +118,9 @@ public function getCreated(): DateTime; * * @param DateTime $dateTime Last update date * - * @return FeedbackEntityInterface + * @return static */ - public function setUpdated(DateTime $dateTime): FeedbackEntityInterface; + public function setUpdated(DateTime $dateTime): static; /** * Updated getter @@ -134,9 +134,9 @@ public function getUpdated(): DateTime; * * @param string $status Status * - * @return FeedbackEntityInterface + * @return static */ - public function setStatus(string $status): FeedbackEntityInterface; + public function setStatus(string $status): static; /** * Status getter @@ -150,9 +150,9 @@ public function getStatus(): string; * * @param string $url Site URL * - * @return FeedbackEntityInterface + * @return static */ - public function setSiteUrl(string $url): FeedbackEntityInterface; + public function setSiteUrl(string $url): static; /** * Site URL getter @@ -166,9 +166,9 @@ public function getSiteUrl(): string; * * @param ?UserEntityInterface $user User that created request * - * @return FeedbackEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): FeedbackEntityInterface; + public function setUser(?UserEntityInterface $user): static; /** * User getter @@ -182,9 +182,9 @@ public function getUser(): ?UserEntityInterface; * * @param ?UserEntityInterface $user User that updated request * - * @return FeedbackEntityInterface + * @return static */ - public function setUpdatedBy(?UserEntityInterface $user): FeedbackEntityInterface; + public function setUpdatedBy(?UserEntityInterface $user): static; /** * Updatedby getter diff --git a/module/VuFind/src/VuFind/Db/Entity/LoginTokenEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/LoginTokenEntityInterface.php index 23809fb3c42..b6be0b860aa 100644 --- a/module/VuFind/src/VuFind/Db/Entity/LoginTokenEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/LoginTokenEntityInterface.php @@ -54,9 +54,9 @@ public function getId(): int; * * @param UserEntityInterface $user User to set * - * @return LoginTokenEntityInterface + * @return static */ - public function setUser(UserEntityInterface $user): LoginTokenEntityInterface; + public function setUser(UserEntityInterface $user): static; /** * User getter (only null if entity has not been populated yet). @@ -70,9 +70,9 @@ public function getUser(): ?UserEntityInterface; * * @param string $token Token * - * @return LoginTokenEntityInterface + * @return static */ - public function setToken(string $token): LoginTokenEntityInterface; + public function setToken(string $token): static; /** * Get token string. @@ -86,9 +86,9 @@ public function getToken(): string; * * @param string $series Series * - * @return LoginTokenEntityInterface + * @return static */ - public function setSeries(string $series): LoginTokenEntityInterface; + public function setSeries(string $series): static; /** * Get series string. @@ -102,9 +102,9 @@ public function getSeries(): string; * * @param DateTime $dateTime Last login date/time * - * @return LoginTokenEntityInterface + * @return static */ - public function setLastLogin(DateTime $dateTime): LoginTokenEntityInterface; + public function setLastLogin(DateTime $dateTime): static; /** * Get last login date/time. @@ -118,9 +118,9 @@ public function getLastLogin(): DateTime; * * @param ?string $browser Browser details (or null for none) * - * @return LoginTokenEntityInterface + * @return static */ - public function setBrowser(?string $browser): LoginTokenEntityInterface; + public function setBrowser(?string $browser): static; /** * Get browser details (or null for none). @@ -134,9 +134,9 @@ public function getBrowser(): ?string; * * @param ?string $platform Platform details (or null for none) * - * @return LoginTokenEntityInterface + * @return static */ - public function setPlatform(?string $platform): LoginTokenEntityInterface; + public function setPlatform(?string $platform): static; /** * Get platform details (or null for none). @@ -150,9 +150,9 @@ public function getPlatform(): ?string; * * @param int $expires Expiration timestamp * - * @return LoginTokenEntityInterface + * @return static */ - public function setExpires(int $expires): LoginTokenEntityInterface; + public function setExpires(int $expires): static; /** * Get expiration timestamp. @@ -166,9 +166,9 @@ public function getExpires(): int; * * @param ?string $sid Last session ID (or null for none) * - * @return LoginTokenEntityInterface + * @return static */ - public function setLastSessionId(?string $sid): LoginTokenEntityInterface; + public function setLastSessionId(?string $sid): static; /** * Get last session ID (or null for none). diff --git a/module/VuFind/src/VuFind/Db/Entity/OaiResumptionEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/OaiResumptionEntityInterface.php index 5da2323329a..84287e68e3f 100644 --- a/module/VuFind/src/VuFind/Db/Entity/OaiResumptionEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/OaiResumptionEntityInterface.php @@ -54,9 +54,9 @@ public function getId(): int; * * @param ?string $params Resumption parameters. * - * @return OaiResumptionEntityInterface + * @return static */ - public function setResumptionParameters(?string $params): OaiResumptionEntityInterface; + public function setResumptionParameters(?string $params): static; /** * Get resumption parameters. @@ -70,9 +70,9 @@ public function getResumptionParameters(): ?string; * * @param DateTime $dateTime Expiration date * - * @return OaiResumptionEntityInterface + * @return static */ - public function setExpiry(DateTime $dateTime): OaiResumptionEntityInterface; + public function setExpiry(DateTime $dateTime): static; /** * Get expiry date. diff --git a/module/VuFind/src/VuFind/Db/Entity/RatingsEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/RatingsEntityInterface.php index b23317960c0..0e520febcd5 100644 --- a/module/VuFind/src/VuFind/Db/Entity/RatingsEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/RatingsEntityInterface.php @@ -61,9 +61,9 @@ public function getUser(): ?UserEntityInterface; * * @param ?UserEntityInterface $user User * - * @return RatingsEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): RatingsEntityInterface; + public function setUser(?UserEntityInterface $user): static; /** * Get resource. @@ -77,9 +77,9 @@ public function getResource(): ResourceEntityInterface; * * @param ResourceEntityInterface $resource Resource * - * @return RatingsEntityInterface + * @return static */ - public function setResource(ResourceEntityInterface $resource): RatingsEntityInterface; + public function setResource(ResourceEntityInterface $resource): static; /** * Get rating. @@ -93,9 +93,9 @@ public function getRating(): int; * * @param int $rating Rating * - * @return RatingsEntityInterface + * @return static */ - public function setRating(int $rating): RatingsEntityInterface; + public function setRating(int $rating): static; /** * Get created date. @@ -109,7 +109,7 @@ public function getCreated(): DateTime; * * @param DateTime $dateTime Created date * - * @return RatingsEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): RatingsEntityInterface; + public function setCreated(DateTime $dateTime): static; } diff --git a/module/VuFind/src/VuFind/Db/Entity/RecordEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/RecordEntityInterface.php index 63f2cd4d793..ee4ff96aefc 100644 --- a/module/VuFind/src/VuFind/Db/Entity/RecordEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/RecordEntityInterface.php @@ -61,9 +61,9 @@ public function getRecordId(): ?string; * * @param ?string $recordId Record id * - * @return RecordEntityInterface + * @return static */ - public function setRecordId(?string $recordId): RecordEntityInterface; + public function setRecordId(?string $recordId): static; /** * Get record source. @@ -77,9 +77,9 @@ public function getSource(): ?string; * * @param ?string $recordSource Record source * - * @return RecordEntityInterface + * @return static */ - public function setSource(?string $recordSource): RecordEntityInterface; + public function setSource(?string $recordSource): static; /** * Get record version. @@ -93,9 +93,9 @@ public function getVersion(): string; * * @param string $recordVersion Record version * - * @return RecordEntityInterface + * @return static */ - public function setVersion(string $recordVersion): RecordEntityInterface; + public function setVersion(string $recordVersion): static; /** * Get record data. @@ -109,9 +109,9 @@ public function getData(): ?string; * * @param ?string $recordData Record data * - * @return RecordEntityInterface + * @return static */ - public function setData(?string $recordData): RecordEntityInterface; + public function setData(?string $recordData): static; /** * Get updated date. @@ -125,7 +125,7 @@ public function getUpdated(): DateTime; * * @param DateTime $dateTime Updated date * - * @return RecordEntityInterface + * @return static */ - public function setUpdated(DateTime $dateTime): RecordEntityInterface; + public function setUpdated(DateTime $dateTime): static; } diff --git a/module/VuFind/src/VuFind/Db/Entity/ResourceEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/ResourceEntityInterface.php index 0a948ee7ba7..bf7dbae1e85 100644 --- a/module/VuFind/src/VuFind/Db/Entity/ResourceEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/ResourceEntityInterface.php @@ -52,9 +52,9 @@ public function getId(): int; * * @param string $recordId recordId * - * @return ResourceEntityInterface + * @return static */ - public function setRecordId(string $recordId): ResourceEntityInterface; + public function setRecordId(string $recordId): static; /** * Record Id getter @@ -68,9 +68,9 @@ public function getRecordId(): string; * * @param string $title Title of the record. * - * @return ResourceEntityInterface + * @return static */ - public function setTitle(string $title): ResourceEntityInterface; + public function setTitle(string $title): static; /** * Title getter @@ -84,27 +84,27 @@ public function getTitle(): string; * * @param ?string $author Author of the title. * - * @return ResourceEntityInterface + * @return static */ - public function setAuthor(?string $author): ResourceEntityInterface; + public function setAuthor(?string $author): static; /** * Year setter * * @param ?int $year Year title is published. * - * @return ResourceEntityInterface + * @return static */ - public function setYear(?int $year): ResourceEntityInterface; + public function setYear(?int $year): static; /** * Source setter * * @param string $source Source (a search backend ID). * - * @return ResourceEntityInterface + * @return static */ - public function setSource(string $source): ResourceEntityInterface; + public function setSource(string $source): static; /** * Source getter @@ -118,9 +118,9 @@ public function getSource(): string; * * @param ?string $extraMetadata ExtraMetadata. * - * @return ResourceEntityInterface + * @return static */ - public function setExtraMetadata(?string $extraMetadata): ResourceEntityInterface; + public function setExtraMetadata(?string $extraMetadata): static; /** * Extra Metadata getter diff --git a/module/VuFind/src/VuFind/Db/Entity/ResourceTagsEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/ResourceTagsEntityInterface.php index dae2e9efa7a..cf307fac330 100644 --- a/module/VuFind/src/VuFind/Db/Entity/ResourceTagsEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/ResourceTagsEntityInterface.php @@ -61,9 +61,9 @@ public function getResource(): ?ResourceEntityInterface; * * @param ?ResourceEntityInterface $resource Resource * - * @return ResourceTagsEntityInterface + * @return static */ - public function setResource(?ResourceEntityInterface $resource): ResourceTagsEntityInterface; + public function setResource(?ResourceEntityInterface $resource): static; /** * Get tag. @@ -77,9 +77,9 @@ public function getTag(): TagsEntityInterface; * * @param TagsEntityInterface $tag Tag * - * @return ResourceTagsEntityInterface + * @return static */ - public function setTag(TagsEntityInterface $tag): ResourceTagsEntityInterface; + public function setTag(TagsEntityInterface $tag): static; /** * Get user list. @@ -93,9 +93,9 @@ public function getUserList(): ?UserListEntityInterface; * * @param ?UserListEntityInterface $list User list * - * @return ResourceTagsEntityInterface + * @return static */ - public function setUserList(?UserListEntityInterface $list): ResourceTagsEntityInterface; + public function setUserList(?UserListEntityInterface $list): static; /** * Get user. @@ -109,9 +109,9 @@ public function getUser(): ?UserEntityInterface; * * @param ?UserEntityInterface $user User * - * @return ResourceTagsEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): ResourceTagsEntityInterface; + public function setUser(?UserEntityInterface $user): static; /** * Get created date. @@ -125,7 +125,7 @@ public function getPosted(): DateTime; * * @param DateTime $dateTime Created date * - * @return ResourceTagsEntityInterface + * @return static */ - public function setPosted(DateTime $dateTime): ResourceTagsEntityInterface; + public function setPosted(DateTime $dateTime): static; } diff --git a/module/VuFind/src/VuFind/Db/Entity/SearchEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/SearchEntityInterface.php index ca6bf3a8cec..70e45ac46b8 100644 --- a/module/VuFind/src/VuFind/Db/Entity/SearchEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/SearchEntityInterface.php @@ -61,9 +61,9 @@ public function getUser(): ?UserEntityInterface; * * @param ?UserEntityInterface $user User * - * @return SearchEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): SearchEntityInterface; + public function setUser(?UserEntityInterface $user): static; /** * Get session identifier. @@ -77,9 +77,9 @@ public function getSessionId(): ?string; * * @param ?string $sessionId Session id * - * @return SearchEntityInterface + * @return static */ - public function setSessionId(?string $sessionId): SearchEntityInterface; + public function setSessionId(?string $sessionId): static; /** * Get created date. @@ -93,9 +93,9 @@ public function getCreated(): DateTime; * * @param DateTime $dateTime Created date * - * @return SearchEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): SearchEntityInterface; + public function setCreated(DateTime $dateTime): static; /** * Get title. @@ -109,9 +109,9 @@ public function getTitle(): ?string; * * @param ?string $title Title * - * @return SearchEntityInterface + * @return static */ - public function setTitle(?string $title): SearchEntityInterface; + public function setTitle(?string $title): static; /** * Get saved. @@ -125,9 +125,9 @@ public function getSaved(): bool; * * @param bool $saved Saved * - * @return SearchEntityInterface + * @return static */ - public function setSaved(bool $saved): SearchEntityInterface; + public function setSaved(bool $saved): static; /** * Get the search object from the row. @@ -141,9 +141,9 @@ public function getSearchObject(): ?\VuFind\Search\Minified; * * @param ?\VuFind\Search\Minified $searchObject Search object * - * @return SearchEntityInterface + * @return static */ - public function setSearchObject(?\VuFind\Search\Minified $searchObject): SearchEntityInterface; + public function setSearchObject(?\VuFind\Search\Minified $searchObject): static; /** * Get checksum. @@ -157,9 +157,9 @@ public function getChecksum(): ?int; * * @param ?int $checksum Checksum * - * @return SearchEntityInterface + * @return static */ - public function setChecksum(?int $checksum): SearchEntityInterface; + public function setChecksum(?int $checksum): static; /** * Get notification frequency. @@ -173,9 +173,9 @@ public function getNotificationFrequency(): int; * * @param int $notificationFrequency Notification frequency * - * @return SearchEntityInterface + * @return static */ - public function setNotificationFrequency(int $notificationFrequency): SearchEntityInterface; + public function setNotificationFrequency(int $notificationFrequency): static; /** * When was the last notification sent? @@ -189,9 +189,9 @@ public function getLastNotificationSent(): DateTime; * * @param DateTime $lastNotificationSent Time when last notification was sent * - * @return SearchEntityInterface + * @return static */ - public function setLastNotificationSent(Datetime $lastNotificationSent): SearchEntityInterface; + public function setLastNotificationSent(Datetime $lastNotificationSent): static; /** * Get notification base URL. @@ -205,7 +205,7 @@ public function getNotificationBaseUrl(): string; * * @param string $notificationBaseUrl Notification base URL * - * @return SearchEntityInterface + * @return static */ - public function setNotificationBaseUrl(string $notificationBaseUrl): SearchEntityInterface; + public function setNotificationBaseUrl(string $notificationBaseUrl): static; } diff --git a/module/VuFind/src/VuFind/Db/Entity/SessionEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/SessionEntityInterface.php index 368d2784731..d5065709c4d 100644 --- a/module/VuFind/src/VuFind/Db/Entity/SessionEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/SessionEntityInterface.php @@ -54,27 +54,27 @@ public function getId(): int; * * @param ?string $sid Session Id. * - * @return SessionEntityInterface + * @return static */ - public function setSessionId(?string $sid): SessionEntityInterface; + public function setSessionId(?string $sid): static; /** * Created setter. * * @param DateTime $dateTime Created date * - * @return SessionEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): SessionEntityInterface; + public function setCreated(DateTime $dateTime): static; /** * Set time the session is last used. * * @param int $lastUsed Time last used * - * @return SessionEntityInterface + * @return static */ - public function setLastUsed(int $lastUsed): SessionEntityInterface; + public function setLastUsed(int $lastUsed): static; /** * Get time when the session was last used. @@ -88,9 +88,9 @@ public function getLastUsed(): int; * * @param ?string $data Session data. * - * @return SessionEntityInterface + * @return static */ - public function setData(?string $data): SessionEntityInterface; + public function setData(?string $data): static; /** * Get session data. diff --git a/module/VuFind/src/VuFind/Db/Entity/ShortlinksEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/ShortlinksEntityInterface.php index e9992fd0e21..a0ad4947a5d 100644 --- a/module/VuFind/src/VuFind/Db/Entity/ShortlinksEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/ShortlinksEntityInterface.php @@ -62,9 +62,9 @@ public function getPath(): string; * * @param string $path Path * - * @return ShortlinksEntityInterface + * @return static */ - public function setPath(string $path): ShortlinksEntityInterface; + public function setPath(string $path): static; /** * Get shortlinks hash. @@ -78,9 +78,9 @@ public function getHash(): ?string; * * @param ?string $hash Shortlinks hash * - * @return ShortlinksEntityInterface + * @return static */ - public function setHash(?string $hash): ShortlinksEntityInterface; + public function setHash(?string $hash): static; /** * Get creation timestamp. @@ -94,7 +94,7 @@ public function getCreated(): DateTime; * * @param DateTime $dateTime Creation timestamp * - * @return ShortlinksEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): ShortlinksEntityInterface; + public function setCreated(DateTime $dateTime): static; } diff --git a/module/VuFind/src/VuFind/Db/Entity/TagsEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/TagsEntityInterface.php index 5166d8aa1c0..430096035d5 100644 --- a/module/VuFind/src/VuFind/Db/Entity/TagsEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/TagsEntityInterface.php @@ -52,9 +52,9 @@ public function getId(): int; * * @param string $tag Tag * - * @return TagsEntityInterface + * @return static */ - public function setTag(string $tag): TagsEntityInterface; + public function setTag(string $tag): static; /** * Tag getter diff --git a/module/VuFind/src/VuFind/Db/Entity/UserCardEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/UserCardEntityInterface.php index 08b965f5bd3..48f7a389dbb 100644 --- a/module/VuFind/src/VuFind/Db/Entity/UserCardEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/UserCardEntityInterface.php @@ -54,9 +54,9 @@ public function getId(): ?int; * * @param string $cardName User card name. * - * @return UserCardEntityInterface + * @return static */ - public function setCardName(string $cardName): UserCardEntityInterface; + public function setCardName(string $cardName): static; /** * Get user card name. @@ -70,9 +70,9 @@ public function getCardName(): string; * * @param string $catUsername Catalog username * - * @return UserCardEntityInterface + * @return static */ - public function setCatUsername(string $catUsername): UserCardEntityInterface; + public function setCatUsername(string $catUsername): static; /** * Get catalog username. @@ -86,9 +86,9 @@ public function getCatUsername(): string; * * @param ?string $catPassword Cat password * - * @return UserCardEntityInterface + * @return static */ - public function setRawCatPassword(?string $catPassword): UserCardEntityInterface; + public function setRawCatPassword(?string $catPassword): static; /** * Get raw catalog password. @@ -102,9 +102,9 @@ public function getRawCatPassword(): ?string; * * @param ?string $passEnc Encrypted password * - * @return UserCardEntityInterface + * @return static */ - public function setCatPassEnc(?string $passEnc): UserCardEntityInterface; + public function setCatPassEnc(?string $passEnc): static; /** * Get encrypted catalog password. @@ -118,9 +118,9 @@ public function getCatPassEnc(): ?string; * * @param ?string $homeLibrary Home library * - * @return UserCardEntityInterface + * @return static */ - public function setHomeLibrary(?string $homeLibrary): UserCardEntityInterface; + public function setHomeLibrary(?string $homeLibrary): static; /** * Get home library. @@ -134,9 +134,9 @@ public function getHomeLibrary(): ?string; * * @param DateTime $dateTime Created date * - * @return UserCardEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): UserCardEntityInterface; + public function setCreated(DateTime $dateTime): static; /** * Get created date. @@ -150,9 +150,9 @@ public function getCreated(): DateTime; * * @param DateTime $dateTime Saved date and time * - * @return UserCardEntityInterface + * @return static */ - public function setSaved(DateTime $dateTime): UserCardEntityInterface; + public function setSaved(DateTime $dateTime): static; /** * Get saved time. @@ -166,9 +166,9 @@ public function getSaved(): DateTime; * * @param UserEntityInterface $user User that owns card * - * @return UserCardEntityInterface + * @return static */ - public function setUser(UserEntityInterface $user): UserCardEntityInterface; + public function setUser(UserEntityInterface $user): static; /** * User getter diff --git a/module/VuFind/src/VuFind/Db/Entity/UserEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/UserEntityInterface.php index 8a0752a8fb4..c7d1759c829 100644 --- a/module/VuFind/src/VuFind/Db/Entity/UserEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/UserEntityInterface.php @@ -54,9 +54,9 @@ public function getId(): ?int; * * @param string $username Username * - * @return UserEntityInterface + * @return static */ - public function setUsername(string $username): UserEntityInterface; + public function setUsername(string $username): static; /** * Get username. @@ -70,9 +70,9 @@ public function getUsername(): string; * * @param string $password Password * - * @return UserEntityInterface + * @return static */ - public function setRawPassword(string $password): UserEntityInterface; + public function setRawPassword(string $password): static; /** * Get raw (unhashed) password (if available). This should only be used when hashing is disabled. @@ -86,9 +86,9 @@ public function getRawPassword(): string; * * @param ?string $hash Password hash * - * @return UserEntityInterface + * @return static */ - public function setPasswordHash(?string $hash): UserEntityInterface; + public function setPasswordHash(?string $hash): static; /** * Get hashed password. This should only be used when hashing is enabled. @@ -102,9 +102,9 @@ public function getPasswordHash(): ?string; * * @param string $firstName New first name * - * @return UserEntityInterface + * @return static */ - public function setFirstname(string $firstName): UserEntityInterface; + public function setFirstname(string $firstName): static; /** * Get firstname. @@ -118,9 +118,9 @@ public function getFirstname(): string; * * @param string $lastName New last name * - * @return UserEntityInterface + * @return static */ - public function setLastname(string $lastName): UserEntityInterface; + public function setLastname(string $lastName): static; /** * Get lastname. @@ -134,9 +134,9 @@ public function getLastname(): string; * * @param string $email Email address * - * @return UserEntityInterface + * @return static */ - public function setEmail(string $email): UserEntityInterface; + public function setEmail(string $email): static; /** * Get email. @@ -150,9 +150,9 @@ public function getEmail(): string; * * @param string $email New pending email * - * @return UserEntityInterface + * @return static */ - public function setPendingEmail(string $email): UserEntityInterface; + public function setPendingEmail(string $email): static; /** * Get pending email. @@ -166,9 +166,9 @@ public function getPendingEmail(): string; * * @param ?string $catId Catalog id * - * @return UserEntityInterface + * @return static */ - public function setCatId(?string $catId): UserEntityInterface; + public function setCatId(?string $catId): static; /** * Get catalog id. @@ -182,9 +182,9 @@ public function getCatId(): ?string; * * @param ?string $catUsername Catalog username * - * @return UserEntityInterface + * @return static */ - public function setCatUsername(?string $catUsername): UserEntityInterface; + public function setCatUsername(?string $catUsername): static; /** * Get catalog username. @@ -198,9 +198,9 @@ public function getCatUsername(): ?string; * * @param ?string $homeLibrary Home library * - * @return UserEntityInterface + * @return static */ - public function setHomeLibrary(?string $homeLibrary): UserEntityInterface; + public function setHomeLibrary(?string $homeLibrary): static; /** * Get home library. @@ -214,9 +214,9 @@ public function getHomeLibrary(): ?string; * * @param ?string $catPassword Cat password * - * @return UserEntityInterface + * @return static */ - public function setRawCatPassword(?string $catPassword): UserEntityInterface; + public function setRawCatPassword(?string $catPassword): static; /** * Get raw catalog password. @@ -230,9 +230,9 @@ public function getRawCatPassword(): ?string; * * @param ?string $passEnc Encrypted password * - * @return UserEntityInterface + * @return static */ - public function setCatPassEnc(?string $passEnc): UserEntityInterface; + public function setCatPassEnc(?string $passEnc): static; /** * Get encrypted catalog password. @@ -246,9 +246,9 @@ public function getCatPassEnc(): ?string; * * @param string $college College * - * @return UserEntityInterface + * @return static */ - public function setCollege(string $college): UserEntityInterface; + public function setCollege(string $college): static; /** * Get college. @@ -262,9 +262,9 @@ public function getCollege(): string; * * @param string $major Major * - * @return UserEntityInterface + * @return static */ - public function setMajor(string $major): UserEntityInterface; + public function setMajor(string $major): static; /** * Get major. @@ -278,9 +278,9 @@ public function getMajor(): string; * * @param string $hash Hash value to save * - * @return UserEntityInterface + * @return static */ - public function setVerifyHash(string $hash): UserEntityInterface; + public function setVerifyHash(string $hash): static; /** * Get verification hash for recovery. @@ -294,9 +294,9 @@ public function getVerifyHash(): string; * * @param ?string $authMethod New value (null for none) * - * @return UserEntityInterface + * @return static */ - public function setAuthMethod(?string $authMethod): UserEntityInterface; + public function setAuthMethod(?string $authMethod): static; /** * Get active authentication method (if any). @@ -310,9 +310,9 @@ public function getAuthMethod(): ?string; * * @param string $lang Last language * - * @return UserEntityInterface + * @return static */ - public function setLastLanguage(string $lang): UserEntityInterface; + public function setLastLanguage(string $lang): static; /** * Get last language. @@ -333,18 +333,18 @@ public function hasUserProvidedEmail(): bool; * * @param bool $userProvided New value * - * @return UserEntityInterface + * @return static */ - public function setHasUserProvidedEmail(bool $userProvided): UserEntityInterface; + public function setHasUserProvidedEmail(bool $userProvided): static; /** * Last login setter. * * @param DateTime $dateTime Last login date * - * @return UserEntityInterface + * @return static */ - public function setLastLogin(DateTime $dateTime): UserEntityInterface; + public function setLastLogin(DateTime $dateTime): static; /** * Last login getter @@ -358,9 +358,9 @@ public function getLastLogin(): DateTime; * * @param DateTime $dateTime Last login date * - * @return UserEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): UserEntityInterface; + public function setCreated(DateTime $dateTime): static; /** * Created getter @@ -374,9 +374,9 @@ public function getCreated(): Datetime; * * @param ?DateTime $dateTime Verification date (or null) * - * @return UserEntityInterface + * @return static */ - public function setEmailVerified(?DateTime $dateTime): UserEntityInterface; + public function setEmailVerified(?DateTime $dateTime): static; /** * Get email verification date (or null for unverified). diff --git a/module/VuFind/src/VuFind/Db/Entity/UserListEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/UserListEntityInterface.php index 6dd9ce2d692..a78c5179677 100644 --- a/module/VuFind/src/VuFind/Db/Entity/UserListEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/UserListEntityInterface.php @@ -54,9 +54,9 @@ public function getId(): ?int; * * @param string $title Title * - * @return UserListEntityInterface + * @return static */ - public function setTitle(string $title): UserListEntityInterface; + public function setTitle(string $title): static; /** * Get title. @@ -70,9 +70,9 @@ public function getTitle(): string; * * @param ?string $description Description * - * @return UserListEntityInterface + * @return static */ - public function setDescription(?string $description): UserListEntityInterface; + public function setDescription(?string $description): static; /** * Get description. @@ -86,9 +86,9 @@ public function getDescription(): ?string; * * @param DateTime $dateTime Created date * - * @return UserListEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): UserListEntityInterface; + public function setCreated(DateTime $dateTime): static; /** * Get created date. @@ -102,9 +102,9 @@ public function getCreated(): DateTime; * * @param bool $public Is the list public? * - * @return UserListEntityInterface + * @return static */ - public function setPublic(bool $public): UserListEntityInterface; + public function setPublic(bool $public): static; /** * Is this a public list? @@ -118,9 +118,9 @@ public function isPublic(): bool; * * @param ?UserEntityInterface $user User owning the list. * - * @return UserListEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): UserListEntityInterface; + public function setUser(?UserEntityInterface $user): static; /** * Get user. diff --git a/module/VuFind/src/VuFind/Db/Entity/UserResourceEntityInterface.php b/module/VuFind/src/VuFind/Db/Entity/UserResourceEntityInterface.php index 6a787b3601e..b9bdcf4f2ff 100644 --- a/module/VuFind/src/VuFind/Db/Entity/UserResourceEntityInterface.php +++ b/module/VuFind/src/VuFind/Db/Entity/UserResourceEntityInterface.php @@ -61,9 +61,9 @@ public function getUser(): UserEntityInterface; * * @param UserEntityInterface $user User * - * @return UserResourceEntityInterface + * @return static */ - public function setUser(UserEntityInterface $user): UserResourceEntityInterface; + public function setUser(UserEntityInterface $user): static; /** * Get resource. @@ -77,9 +77,9 @@ public function getResource(): ResourceEntityInterface; * * @param ResourceEntityInterface $resource Resource * - * @return UserResourceEntityInterface + * @return static */ - public function setResource(ResourceEntityInterface $resource): UserResourceEntityInterface; + public function setResource(ResourceEntityInterface $resource): static; /** * Get user list. @@ -93,9 +93,9 @@ public function getUserList(): ?UserListEntityInterface; * * @param ?UserListEntityInterface $list User list * - * @return UserResourceEntityInterface + * @return static */ - public function setUserList(?UserListEntityInterface $list): UserResourceEntityInterface; + public function setUserList(?UserListEntityInterface $list): static; /** * Get notes. @@ -109,9 +109,9 @@ public function getNotes(): ?string; * * @param ?string $notes Notes associated with the resource * - * @return UserResourceEntityInterface + * @return static */ - public function setNotes(?string $notes): UserResourceEntityInterface; + public function setNotes(?string $notes): static; /** * Get saved date. @@ -125,7 +125,7 @@ public function getSaved(): DateTime; * * @param DateTime $dateTime Created date * - * @return UserResourceEntityInterface + * @return static */ - public function setSaved(DateTime $dateTime): UserResourceEntityInterface; + public function setSaved(DateTime $dateTime): static; } diff --git a/module/VuFind/src/VuFind/Db/Row/AccessToken.php b/module/VuFind/src/VuFind/Db/Row/AccessToken.php index 08136871d61..f771064f8ba 100644 --- a/module/VuFind/src/VuFind/Db/Row/AccessToken.php +++ b/module/VuFind/src/VuFind/Db/Row/AccessToken.php @@ -59,9 +59,9 @@ public function __construct($adapter) * * @param ?UserEntityInterface $user User owning token * - * @return AccessTokenEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): AccessTokenEntityInterface + public function setUser(?UserEntityInterface $user): static { $this->__set('user_id', $user?->getId()); return $this; @@ -72,9 +72,9 @@ public function setUser(?UserEntityInterface $user): AccessTokenEntityInterface * * @param string $data Data * - * @return AccessTokenEntityInterface + * @return static */ - public function setData(string $data): AccessTokenEntityInterface + public function setData(string $data): static { $this->__set('data', $data); return $this; @@ -95,9 +95,9 @@ public function isRevoked(): bool * * @param bool $revoked Revoked * - * @return AccessTokenEntityInterface + * @return static */ - public function setRevoked(bool $revoked): AccessTokenEntityInterface + public function setRevoked(bool $revoked): static { $this->__set('revoked', $revoked); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/AuthHash.php b/module/VuFind/src/VuFind/Db/Row/AuthHash.php index 5f340b829e4..de5a60da0ac 100644 --- a/module/VuFind/src/VuFind/Db/Row/AuthHash.php +++ b/module/VuFind/src/VuFind/Db/Row/AuthHash.php @@ -93,9 +93,9 @@ public function getSessionId(): ?string * * @param ?string $sessionId PHP Session id string * - * @return AuthHashEntityInterface + * @return static */ - public function setSessionId(?string $sessionId): AuthHashEntityInterface + public function setSessionId(?string $sessionId): static { $this->session_id = $sessionId; return $this; @@ -116,9 +116,9 @@ public function getHash(): string * * @param string $hash Hash Value * - * @return AuthHashEntityInterface + * @return static */ - public function setHash(string $hash): AuthHashEntityInterface + public function setHash(string $hash): static { $this->hash = $hash; return $this; @@ -139,9 +139,9 @@ public function getHashType(): ?string * * @param ?string $type Hash Type * - * @return AuthHashEntityInterface + * @return static */ - public function setHashType(?string $type): AuthHashEntityInterface + public function setHashType(?string $type): static { $this->type = $type; return $this; @@ -162,9 +162,9 @@ public function getData(): ?string * * @param ?string $data Data * - * @return AuthHashEntityInterface + * @return static */ - public function setData(?string $data): AuthHashEntityInterface + public function setData(?string $data): static { $this->__set('data', $data); return $this; @@ -185,9 +185,9 @@ public function getCreated(): DateTime * * @param DateTime $dateTime Created date * - * @return AuthHashEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): AuthHashEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/ChangeTracker.php b/module/VuFind/src/VuFind/Db/Row/ChangeTracker.php index d5dfd6621dd..e3f15904e1c 100644 --- a/module/VuFind/src/VuFind/Db/Row/ChangeTracker.php +++ b/module/VuFind/src/VuFind/Db/Row/ChangeTracker.php @@ -65,9 +65,9 @@ public function __construct($adapter) * * @param string $id Id * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setId(string $id): ChangeTrackerEntityInterface + public function setId(string $id): static { $this->id = $id; return $this; @@ -88,9 +88,9 @@ public function getId(): string * * @param string $name Index name * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setIndexName(string $name): ChangeTrackerEntityInterface + public function setIndexName(string $name): static { $this->core = $name; return $this; @@ -111,9 +111,9 @@ public function getIndexName(): string * * @param ?DateTime $dateTime Time first added to index. * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setFirstIndexed(?DateTime $dateTime): ChangeTrackerEntityInterface + public function setFirstIndexed(?DateTime $dateTime): static { $this->first_indexed = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -134,9 +134,9 @@ public function getFirstIndexed(): ?DateTime * * @param ?DateTime $dateTime Last time changed in index. * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setLastIndexed(?DateTime $dateTime): ChangeTrackerEntityInterface + public function setLastIndexed(?DateTime $dateTime): static { $this->last_indexed = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -157,9 +157,9 @@ public function getLastIndexed(): ?DateTime * * @param ?DateTime $dateTime Last time original record was edited * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setLastRecordChange(?DateTime $dateTime): ChangeTrackerEntityInterface + public function setLastRecordChange(?DateTime $dateTime): static { $this->last_record_change = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -180,9 +180,9 @@ public function getLastRecordChange(): ?DateTime * * @param ?DateTime $dateTime Time record was removed from index * - * @return ChangeTrackerEntityInterface + * @return static */ - public function setDeleted(?DateTime $dateTime): ChangeTrackerEntityInterface + public function setDeleted(?DateTime $dateTime): static { $this->deleted = $dateTime->format('Y-m-d H:i:s'); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/Comments.php b/module/VuFind/src/VuFind/Db/Row/Comments.php index 66387f37f05..dbe7d52ad50 100644 --- a/module/VuFind/src/VuFind/Db/Row/Comments.php +++ b/module/VuFind/src/VuFind/Db/Row/Comments.php @@ -80,9 +80,9 @@ public function getId(): int * * @param string $comment Comment * - * @return Comments + * @return static */ - public function setComment(string $comment): CommentsEntityInterface + public function setComment(string $comment): static { $this->comment = $comment; return $this; @@ -103,9 +103,9 @@ public function getComment(): string * * @param DateTime $dateTime Created date * - * @return Comments + * @return static */ - public function setCreated(DateTime $dateTime): CommentsEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -126,9 +126,9 @@ public function getCreated(): DateTime * * @param ?UserEntityInterface $user User that created comment * - * @return Comments + * @return static */ - public function setUser(?UserEntityInterface $user): CommentsEntityInterface + public function setUser(?UserEntityInterface $user): static { $this->user_id = $user ? $user->getId() : null; return $this; @@ -151,9 +151,9 @@ public function getUser(): ?UserEntityInterface * * @param ResourceEntityInterface $resource Resource id. * - * @return Comments + * @return static */ - public function setResource(ResourceEntityInterface $resource): CommentsEntityInterface + public function setResource(ResourceEntityInterface $resource): static { $this->resource_id = $resource->getId(); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/ExternalSession.php b/module/VuFind/src/VuFind/Db/Row/ExternalSession.php index 7dea047ffb6..ad46955a5fa 100644 --- a/module/VuFind/src/VuFind/Db/Row/ExternalSession.php +++ b/module/VuFind/src/VuFind/Db/Row/ExternalSession.php @@ -49,7 +49,7 @@ * @property string $external_session_id * @property string $created */ -class ExternalSession extends RowGateway implements \VuFind\Db\Entity\ExternalSessionEntityInterface +class ExternalSession extends RowGateway implements ExternalSessionEntityInterface { /** * Constructor @@ -86,9 +86,9 @@ public function getSessionId(): string * * @param string $sessionId PHP session id string * - * @return ExternalSessionEntityInterface + * @return static */ - public function setSessionId(string $sessionId): ExternalSessionEntityInterface + public function setSessionId(string $sessionId): static { $this->session_id = $sessionId; return $this; @@ -109,9 +109,9 @@ public function getExternalSessionId(): string * * @param string $externalSessionId External session id string * - * @return ExternalSessionEntityInterface + * @return static */ - public function setExternalSessionId(string $externalSessionId): ExternalSessionEntityInterface + public function setExternalSessionId(string $externalSessionId): static { $this->external_session_id = $externalSessionId; return $this; @@ -132,9 +132,9 @@ public function getCreated(): DateTime * * @param DateTime $dateTime Created date * - * @return ExternalSessionEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): ExternalSessionEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/Feedback.php b/module/VuFind/src/VuFind/Db/Row/Feedback.php index ee39ffc0f36..960cbc621e9 100644 --- a/module/VuFind/src/VuFind/Db/Row/Feedback.php +++ b/module/VuFind/src/VuFind/Db/Row/Feedback.php @@ -87,9 +87,9 @@ public function getId(): int * * @param string $message Message * - * @return FeedbackEntityInterface + * @return static */ - public function setMessage(string $message): FeedbackEntityInterface + public function setMessage(string $message): static { $this->message = $message; return $this; @@ -110,9 +110,9 @@ public function getMessage(): string * * @param array $data Form data * - * @return FeedbackEntityInterface + * @return static */ - public function setFormData(array $data): FeedbackEntityInterface + public function setFormData(array $data): static { $this->form_data = json_encode($data); return $this; @@ -133,9 +133,9 @@ public function getFormData(): array * * @param string $name Form name * - * @return FeedbackEntityInterface + * @return static */ - public function setFormName(string $name): FeedbackEntityInterface + public function setFormName(string $name): static { $this->form_name = $name; return $this; @@ -156,9 +156,9 @@ public function getFormName(): string * * @param DateTime $dateTime Created date * - * @return FeedbackEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): FeedbackEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -179,9 +179,9 @@ public function getCreated(): DateTime * * @param DateTime $dateTime Last update date * - * @return FeedbackEntityInterface + * @return static */ - public function setUpdated(DateTime $dateTime): FeedbackEntityInterface + public function setUpdated(DateTime $dateTime): static { $this->updated = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -202,9 +202,9 @@ public function getUpdated(): DateTime * * @param string $status Status * - * @return FeedbackEntityInterface + * @return static */ - public function setStatus(string $status): FeedbackEntityInterface + public function setStatus(string $status): static { $this->status = $status; return $this; @@ -225,9 +225,9 @@ public function getStatus(): string * * @param string $url Site URL * - * @return FeedbackEntityInterface + * @return static */ - public function setSiteUrl(string $url): FeedbackEntityInterface + public function setSiteUrl(string $url): static { $this->site_url = $url; return $this; @@ -248,9 +248,9 @@ public function getSiteUrl(): string * * @param ?UserEntityInterface $user User that created request * - * @return FeedbackEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): FeedbackEntityInterface + public function setUser(?UserEntityInterface $user): static { $this->user_id = $user?->getId(); return $this; @@ -273,9 +273,9 @@ public function getUser(): ?UserEntityInterface * * @param ?UserEntityInterface $user User that updated request * - * @return FeedbackEntityInterface + * @return static */ - public function setUpdatedBy(?UserEntityInterface $user): FeedbackEntityInterface + public function setUpdatedBy(?UserEntityInterface $user): static { $this->updated_by = $user ? $user->getId() : null; return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/LoginToken.php b/module/VuFind/src/VuFind/Db/Row/LoginToken.php index 5995dcb41ed..645b8ea027d 100644 --- a/module/VuFind/src/VuFind/Db/Row/LoginToken.php +++ b/module/VuFind/src/VuFind/Db/Row/LoginToken.php @@ -84,9 +84,9 @@ public function getId(): int * * @param UserEntityInterface $user User to set * - * @return LoginTokenEntityInterface + * @return static */ - public function setUser(UserEntityInterface $user): LoginTokenEntityInterface + public function setUser(UserEntityInterface $user): static { $this->user_id = $user->getId(); return $this; @@ -109,9 +109,9 @@ public function getUser(): ?UserEntityInterface * * @param string $token Token * - * @return LoginTokenEntityInterface + * @return static */ - public function setToken(string $token): LoginTokenEntityInterface + public function setToken(string $token): static { $this->token = $token; return $this; @@ -132,9 +132,9 @@ public function getToken(): string * * @param string $series Series * - * @return LoginTokenEntityInterface + * @return static */ - public function setSeries(string $series): LoginTokenEntityInterface + public function setSeries(string $series): static { $this->series = $series; return $this; @@ -155,9 +155,9 @@ public function getSeries(): string * * @param DateTime $dateTime Last login date/time * - * @return LoginTokenEntityInterface + * @return static */ - public function setLastLogin(DateTime $dateTime): LoginTokenEntityInterface + public function setLastLogin(DateTime $dateTime): static { $this->last_login = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -178,9 +178,9 @@ public function getLastLogin(): DateTime * * @param ?string $browser Browser details (or null for none) * - * @return LoginTokenEntityInterface + * @return static */ - public function setBrowser(?string $browser): LoginTokenEntityInterface + public function setBrowser(?string $browser): static { $this->browser = $browser; return $this; @@ -201,9 +201,9 @@ public function getBrowser(): ?string * * @param ?string $platform Platform details (or null for none) * - * @return LoginTokenEntityInterface + * @return static */ - public function setPlatform(?string $platform): LoginTokenEntityInterface + public function setPlatform(?string $platform): static { $this->platform = $platform; return $this; @@ -224,9 +224,9 @@ public function getPlatform(): ?string * * @param int $expires Expiration timestamp * - * @return LoginTokenEntityInterface + * @return static */ - public function setExpires(int $expires): LoginTokenEntityInterface + public function setExpires(int $expires): static { $this->expires = $expires; return $this; @@ -247,9 +247,9 @@ public function getExpires(): int * * @param ?string $sid Last session ID (or null for none) * - * @return LoginTokenEntityInterface + * @return static */ - public function setLastSessionId(?string $sid): LoginTokenEntityInterface + public function setLastSessionId(?string $sid): static { $this->last_session_id = $sid; return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/OaiResumption.php b/module/VuFind/src/VuFind/Db/Row/OaiResumption.php index ced137c1682..fbd3e97a4f5 100644 --- a/module/VuFind/src/VuFind/Db/Row/OaiResumption.php +++ b/module/VuFind/src/VuFind/Db/Row/OaiResumption.php @@ -111,9 +111,9 @@ public function getId(): int * * @param ?string $params Resumption parameters. * - * @return OaiResumptionEntityInterface + * @return static */ - public function setResumptionParameters(?string $params): OaiResumptionEntityInterface + public function setResumptionParameters(?string $params): static { $this->params = $params; return $this; @@ -134,9 +134,9 @@ public function getResumptionParameters(): ?string * * @param DateTime $dateTime Expiration date * - * @return OaiResumptionEntityInterface + * @return static */ - public function setExpiry(DateTime $dateTime): OaiResumptionEntityInterface + public function setExpiry(DateTime $dateTime): static { $this->expires = $dateTime->format('Y-m-d H:i:s'); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/Ratings.php b/module/VuFind/src/VuFind/Db/Row/Ratings.php index c077dd22ec8..a4ded638a5d 100644 --- a/module/VuFind/src/VuFind/Db/Row/Ratings.php +++ b/module/VuFind/src/VuFind/Db/Row/Ratings.php @@ -54,7 +54,7 @@ * @property string $created */ class Ratings extends RowGateway implements - \VuFind\Db\Entity\RatingsEntityInterface, + RatingsEntityInterface, \VuFind\Db\Table\DbTableAwareInterface, DbServiceAwareInterface { @@ -98,9 +98,9 @@ public function getUser(): ?UserEntityInterface * * @param ?UserEntityInterface $user User * - * @return RatingsEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): RatingsEntityInterface + public function setUser(?UserEntityInterface $user): static { $this->user_id = $user?->getId(); return $this; @@ -123,9 +123,9 @@ public function getResource(): ResourceEntityInterface * * @param ResourceEntityInterface $resource Resource * - * @return RatingsEntityInterface + * @return static */ - public function setResource(ResourceEntityInterface $resource): RatingsEntityInterface + public function setResource(ResourceEntityInterface $resource): static { $this->resource_id = $resource->getId(); return $this; @@ -146,9 +146,9 @@ public function getRating(): int * * @param int $rating Rating * - * @return RatingsEntityInterface + * @return static */ - public function setRating(int $rating): RatingsEntityInterface + public function setRating(int $rating): static { $this->rating = $rating; return $this; @@ -169,9 +169,9 @@ public function getCreated(): DateTime * * @param DateTime $dateTime Created date * - * @return RatingsEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): RatingsEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/Record.php b/module/VuFind/src/VuFind/Db/Row/Record.php index c023ca93952..1e3b897d0ae 100644 --- a/module/VuFind/src/VuFind/Db/Row/Record.php +++ b/module/VuFind/src/VuFind/Db/Row/Record.php @@ -85,9 +85,9 @@ public function getRecordId(): ?string * * @param ?string $recordId Record id * - * @return RecordEntityInterface + * @return static */ - public function setRecordId(?string $recordId): RecordEntityInterface + public function setRecordId(?string $recordId): static { $this->record_id = $recordId; return $this; @@ -108,9 +108,9 @@ public function getSource(): ?string * * @param ?string $recordSource Record source * - * @return RecordEntityInterface + * @return static */ - public function setSource(?string $recordSource): RecordEntityInterface + public function setSource(?string $recordSource): static { $this->source = $recordSource; return $this; @@ -131,9 +131,9 @@ public function getVersion(): string * * @param string $recordVersion Record version * - * @return RecordEntityInterface + * @return static */ - public function setVersion(string $recordVersion): RecordEntityInterface + public function setVersion(string $recordVersion): static { $this->version = $recordVersion; return $this; @@ -158,9 +158,9 @@ public function getData(): ?string * * @param ?string $recordData Record data * - * @return RecordEntityInterface + * @return static */ - public function setData(?string $recordData): RecordEntityInterface + public function setData(?string $recordData): static { $this->__set('data', $recordData); return $this; @@ -181,9 +181,9 @@ public function getUpdated(): DateTime * * @param DateTime $dateTime Updated date * - * @return RecordEntityInterface + * @return static */ - public function setUpdated(DateTime $dateTime): RecordEntityInterface + public function setUpdated(DateTime $dateTime): static { $this->updated = $dateTime->format('Y-m-d H:i:s'); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/Resource.php b/module/VuFind/src/VuFind/Db/Row/Resource.php index a3ad7ad5594..e369c47f80c 100644 --- a/module/VuFind/src/VuFind/Db/Row/Resource.php +++ b/module/VuFind/src/VuFind/Db/Row/Resource.php @@ -294,9 +294,9 @@ public function getId(): int * * @param string $recordId recordId * - * @return ResourceEntityInterface + * @return static */ - public function setRecordId(string $recordId): ResourceEntityInterface + public function setRecordId(string $recordId): static { $this->record_id = $recordId; return $this; @@ -317,9 +317,9 @@ public function getRecordId(): string * * @param string $title Title of the record. * - * @return ResourceEntityInterface + * @return static */ - public function setTitle(string $title): ResourceEntityInterface + public function setTitle(string $title): static { $this->title = $title; return $this; @@ -340,9 +340,9 @@ public function getTitle(): string * * @param ?string $author Author of the title. * - * @return ResourceEntityInterface + * @return static */ - public function setAuthor(?string $author): ResourceEntityInterface + public function setAuthor(?string $author): static { $this->author = $author; return $this; @@ -353,9 +353,9 @@ public function setAuthor(?string $author): ResourceEntityInterface * * @param ?int $year Year title is published. * - * @return ResourceEntityInterface + * @return static */ - public function setYear(?int $year): ResourceEntityInterface + public function setYear(?int $year): static { $this->year = $year; return $this; @@ -366,9 +366,9 @@ public function setYear(?int $year): ResourceEntityInterface * * @param string $source Source (a search backend ID). * - * @return ResourceEntityInterface + * @return static */ - public function setSource(string $source): ResourceEntityInterface + public function setSource(string $source): static { $this->source = $source; return $this; @@ -389,9 +389,9 @@ public function getSource(): string * * @param ?string $extraMetadata ExtraMetadata. * - * @return ResourceEntityInterface + * @return static */ - public function setExtraMetadata(?string $extraMetadata): ResourceEntityInterface + public function setExtraMetadata(?string $extraMetadata): static { $this->extra_metadata = $extraMetadata; return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/ResourceTags.php b/module/VuFind/src/VuFind/Db/Row/ResourceTags.php index 976a862cdad..783a212f8a7 100644 --- a/module/VuFind/src/VuFind/Db/Row/ResourceTags.php +++ b/module/VuFind/src/VuFind/Db/Row/ResourceTags.php @@ -59,7 +59,7 @@ * @property string $posted */ class ResourceTags extends RowGateway implements - \VuFind\Db\Entity\ResourceTagsEntityInterface, + ResourceTagsEntityInterface, \VuFind\Db\Table\DbTableAwareInterface, DbServiceAwareInterface { @@ -103,9 +103,9 @@ public function getResource(): ?ResourceEntityInterface * * @param ?ResourceEntityInterface $resource Resource * - * @return ResourceTagsEntityInterface + * @return static */ - public function setResource(?ResourceEntityInterface $resource): ResourceTagsEntityInterface + public function setResource(?ResourceEntityInterface $resource): static { $this->resource_id = $resource?->getId(); return $this; @@ -128,9 +128,9 @@ public function getTag(): TagsEntityInterface * * @param TagsEntityInterface $tag Tag * - * @return ResourceTagsEntityInterface + * @return static */ - public function setTag(TagsEntityInterface $tag): ResourceTagsEntityInterface + public function setTag(TagsEntityInterface $tag): static { $this->tag_id = $tag->getId(); return $this; @@ -153,9 +153,9 @@ public function getUserList(): ?UserListEntityInterface * * @param ?UserListEntityInterface $list User list * - * @return ResourceTagsEntityInterface + * @return static */ - public function setUserList(?UserListEntityInterface $list): ResourceTagsEntityInterface + public function setUserList(?UserListEntityInterface $list): static { $this->list_id = $list?->getId(); return $this; @@ -178,9 +178,9 @@ public function getUser(): ?UserEntityInterface * * @param ?UserEntityInterface $user User * - * @return ResourceTagsEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): ResourceTagsEntityInterface + public function setUser(?UserEntityInterface $user): static { $this->user_id = $user?->getId(); return $this; @@ -201,9 +201,9 @@ public function getPosted(): DateTime * * @param DateTime $dateTime Created date * - * @return ResourceTagsEntityInterface + * @return static */ - public function setPosted(DateTime $dateTime): ResourceTagsEntityInterface + public function setPosted(DateTime $dateTime): static { $this->posted = $dateTime->format('Y-m-d H:i:s'); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/Search.php b/module/VuFind/src/VuFind/Db/Row/Search.php index bdaeb354a50..0f5bac540d1 100644 --- a/module/VuFind/src/VuFind/Db/Row/Search.php +++ b/module/VuFind/src/VuFind/Db/Row/Search.php @@ -61,7 +61,7 @@ * @property string $notification_base_url */ class Search extends RowGateway implements - \VuFind\Db\Entity\SearchEntityInterface, + SearchEntityInterface, \VuFind\Db\Table\DbTableAwareInterface, DbServiceAwareInterface { @@ -217,9 +217,9 @@ public function getUser(): ?UserEntityInterface * * @param ?UserEntityInterface $user User * - * @return SearchEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): SearchEntityInterface + public function setUser(?UserEntityInterface $user): static { $this->user_id = $user?->getId(); return $this; @@ -240,9 +240,9 @@ public function getSessionId(): ?string * * @param ?string $sessionId Session id * - * @return SearchEntityInterface + * @return static */ - public function setSessionId(?string $sessionId): SearchEntityInterface + public function setSessionId(?string $sessionId): static { $this->session_id = $sessionId; return $this; @@ -263,9 +263,9 @@ public function getCreated(): DateTime * * @param DateTime $dateTime Created date * - * @return SearchEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): SearchEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -286,9 +286,9 @@ public function getTitle(): ?string * * @param ?string $title Title * - * @return SearchEntityInterface + * @return static */ - public function setTitle(?string $title): SearchEntityInterface + public function setTitle(?string $title): static { $this->title = $title; return $this; @@ -309,9 +309,9 @@ public function getSaved(): bool * * @param bool $saved Saved * - * @return SearchEntityInterface + * @return static */ - public function setSaved(bool $saved): SearchEntityInterface + public function setSaved(bool $saved): static { $this->saved = $saved ? 1 : 0; return $this; @@ -322,9 +322,9 @@ public function setSaved(bool $saved): SearchEntityInterface * * @param ?\VuFind\Search\Minified $searchObject Search object * - * @return SearchEntityInterface + * @return static */ - public function setSearchObject(?\VuFind\Search\Minified $searchObject): SearchEntityInterface + public function setSearchObject(?\VuFind\Search\Minified $searchObject): static { $this->search_object = $searchObject ? serialize($searchObject) : null; return $this; @@ -345,9 +345,9 @@ public function getChecksum(): ?int * * @param ?int $checksum Checksum * - * @return SearchEntityInterface + * @return static */ - public function setChecksum(?int $checksum): SearchEntityInterface + public function setChecksum(?int $checksum): static { $this->checksum = $checksum; return $this; @@ -368,9 +368,9 @@ public function getNotificationFrequency(): int * * @param int $notificationFrequency Notification frequency * - * @return SearchEntityInterface + * @return static */ - public function setNotificationFrequency(int $notificationFrequency): SearchEntityInterface + public function setNotificationFrequency(int $notificationFrequency): static { $this->notification_frequency = $notificationFrequency; return $this; @@ -391,9 +391,9 @@ public function getLastNotificationSent(): DateTime * * @param DateTime $lastNotificationSent Time when last notification was sent * - * @return SearchEntityInterface + * @return static */ - public function setLastNotificationSent(Datetime $lastNotificationSent): SearchEntityInterface + public function setLastNotificationSent(Datetime $lastNotificationSent): static { $this->last_notification_sent = $lastNotificationSent->format('Y-m-d H:i:s'); return $this; @@ -414,9 +414,9 @@ public function getNotificationBaseUrl(): string * * @param string $notificationBaseUrl Notification base URL * - * @return SearchEntityInterface + * @return static */ - public function setNotificationBaseUrl(string $notificationBaseUrl): SearchEntityInterface + public function setNotificationBaseUrl(string $notificationBaseUrl): static { $this->notification_base_url = $notificationBaseUrl; return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/Session.php b/module/VuFind/src/VuFind/Db/Row/Session.php index f3ede294dad..7db832b828a 100644 --- a/module/VuFind/src/VuFind/Db/Row/Session.php +++ b/module/VuFind/src/VuFind/Db/Row/Session.php @@ -74,9 +74,9 @@ public function getId(): int * * @param ?string $sid Session Id. * - * @return SessionEntityInterface + * @return static */ - public function setSessionId(?string $sid): SessionEntityInterface + public function setSessionId(?string $sid): static { $this->session_id = $sid; return $this; @@ -87,9 +87,9 @@ public function setSessionId(?string $sid): SessionEntityInterface * * @param DateTime $dateTime Created date * - * @return SessionEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): SessionEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -100,9 +100,9 @@ public function setCreated(DateTime $dateTime): SessionEntityInterface * * @param int $lastUsed Time last used * - * @return SessionEntityInterface + * @return static */ - public function setLastUsed(int $lastUsed): SessionEntityInterface + public function setLastUsed(int $lastUsed): static { $this->last_used = $lastUsed; return $this; @@ -123,9 +123,9 @@ public function getLastUsed(): int * * @param ?string $data Session data. * - * @return SessionEntityInterface + * @return static */ - public function setData(?string $data): SessionEntityInterface + public function setData(?string $data): static { $this->data = $data; return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/Shortlinks.php b/module/VuFind/src/VuFind/Db/Row/Shortlinks.php index b116ba0374f..13d1a716a24 100644 --- a/module/VuFind/src/VuFind/Db/Row/Shortlinks.php +++ b/module/VuFind/src/VuFind/Db/Row/Shortlinks.php @@ -46,7 +46,7 @@ * @property string $hash * @property string $created */ -class Shortlinks extends RowGateway implements \VuFind\Db\Entity\ShortlinksEntityInterface +class Shortlinks extends RowGateway implements ShortlinksEntityInterface { /** * Constructor @@ -84,9 +84,9 @@ public function getPath(): string * * @param string $path Path * - * @return ShortlinksEntityInterface + * @return static */ - public function setPath(string $path): ShortlinksEntityInterface + public function setPath(string $path): static { $this->path = $path; return $this; @@ -107,9 +107,9 @@ public function getHash(): ?string * * @param ?string $hash Shortlinks hash * - * @return ShortlinksEntityInterface + * @return static */ - public function setHash(?string $hash): ShortlinksEntityInterface + public function setHash(?string $hash): static { $this->hash = $hash; return $this; @@ -130,9 +130,9 @@ public function getCreated(): DateTime * * @param DateTime $dateTime Creation timestamp * - * @return ShortlinksEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): ShortlinksEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/Tags.php b/module/VuFind/src/VuFind/Db/Row/Tags.php index 32a6e245cee..b36457a3c06 100644 --- a/module/VuFind/src/VuFind/Db/Row/Tags.php +++ b/module/VuFind/src/VuFind/Db/Row/Tags.php @@ -129,9 +129,9 @@ public function getId(): int * * @param string $tag Tag * - * @return TagsEntityInterface + * @return static */ - public function setTag(string $tag): TagsEntityInterface + public function setTag(string $tag): static { $this->tag = $tag; return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/User.php b/module/VuFind/src/VuFind/Db/Row/User.php index 3347dc9ade2..97569a84497 100644 --- a/module/VuFind/src/VuFind/Db/Row/User.php +++ b/module/VuFind/src/VuFind/Db/Row/User.php @@ -716,9 +716,9 @@ public function getId(): ?int * * @param string $username Username * - * @return UserEntityInterface + * @return static */ - public function setUsername(string $username): UserEntityInterface + public function setUsername(string $username): static { $this->username = $username; return $this; @@ -739,9 +739,9 @@ public function getUsername(): string * * @param string $password Password * - * @return UserEntityInterface + * @return static */ - public function setRawPassword(string $password): UserEntityInterface + public function setRawPassword(string $password): static { $this->password = $password; return $this; @@ -762,9 +762,9 @@ public function getRawPassword(): string * * @param ?string $hash Password hash * - * @return UserEntityInterface + * @return static */ - public function setPasswordHash(?string $hash): UserEntityInterface + public function setPasswordHash(?string $hash): static { $this->pass_hash = $hash; return $this; @@ -785,9 +785,9 @@ public function getPasswordHash(): ?string * * @param string $firstName New first name * - * @return UserEntityInterface + * @return static */ - public function setFirstname(string $firstName): UserEntityInterface + public function setFirstname(string $firstName): static { $this->firstname = $firstName; return $this; @@ -808,9 +808,9 @@ public function getFirstname(): string * * @param string $lastName New last name * - * @return UserEntityInterface + * @return static */ - public function setLastname(string $lastName): UserEntityInterface + public function setLastname(string $lastName): static { $this->lastname = $lastName; return $this; @@ -831,9 +831,9 @@ public function getLastname(): string * * @param string $email Email address * - * @return UserEntityInterface + * @return static */ - public function setEmail(string $email): UserEntityInterface + public function setEmail(string $email): static { $this->email = $email; return $this; @@ -854,9 +854,9 @@ public function getEmail(): string * * @param string $email New pending email * - * @return UserEntityInterface + * @return static */ - public function setPendingEmail(string $email): UserEntityInterface + public function setPendingEmail(string $email): static { $this->pending_email = $email; return $this; @@ -877,9 +877,9 @@ public function getPendingEmail(): string * * @param ?string $catId Catalog id * - * @return UserEntityInterface + * @return static */ - public function setCatId(?string $catId): UserEntityInterface + public function setCatId(?string $catId): static { $this->cat_id = $catId; return $this; @@ -900,9 +900,9 @@ public function getCatId(): ?string * * @param ?string $catUsername Catalog username * - * @return UserEntityInterface + * @return static */ - public function setCatUsername(?string $catUsername): UserEntityInterface + public function setCatUsername(?string $catUsername): static { $this->cat_username = $catUsername; return $this; @@ -923,9 +923,9 @@ public function getCatUsername(): ?string * * @param ?string $homeLibrary Home library * - * @return UserEntityInterface + * @return static */ - public function setHomeLibrary(?string $homeLibrary): UserEntityInterface + public function setHomeLibrary(?string $homeLibrary): static { $this->home_library = $homeLibrary; return $this; @@ -946,9 +946,9 @@ public function getHomeLibrary(): ?string * * @param ?string $catPassword Cat password * - * @return UserEntityInterface + * @return static */ - public function setRawCatPassword(?string $catPassword): UserEntityInterface + public function setRawCatPassword(?string $catPassword): static { $this->cat_password = $catPassword; return $this; @@ -969,9 +969,9 @@ public function getRawCatPassword(): ?string * * @param ?string $passEnc Encrypted password * - * @return UserEntityInterface + * @return static */ - public function setCatPassEnc(?string $passEnc): UserEntityInterface + public function setCatPassEnc(?string $passEnc): static { $this->cat_pass_enc = $passEnc; return $this; @@ -992,9 +992,9 @@ public function getCatPassEnc(): ?string * * @param string $college College * - * @return UserEntityInterface + * @return static */ - public function setCollege(string $college): UserEntityInterface + public function setCollege(string $college): static { $this->college = $college; return $this; @@ -1015,9 +1015,9 @@ public function getCollege(): string * * @param string $major Major * - * @return UserEntityInterface + * @return static */ - public function setMajor(string $major): UserEntityInterface + public function setMajor(string $major): static { $this->major = $major; return $this; @@ -1038,9 +1038,9 @@ public function getMajor(): string * * @param string $hash Hash value to save * - * @return UserEntityInterface + * @return static */ - public function setVerifyHash(string $hash): UserEntityInterface + public function setVerifyHash(string $hash): static { $this->verify_hash = $hash; return $this; @@ -1061,9 +1061,9 @@ public function getVerifyHash(): string * * @param ?string $authMethod New value (null for none) * - * @return UserEntityInterface + * @return static */ - public function setAuthMethod(?string $authMethod): UserEntityInterface + public function setAuthMethod(?string $authMethod): static { $this->auth_method = $authMethod; return $this; @@ -1084,9 +1084,9 @@ public function getAuthMethod(): ?string * * @param string $lang Last language * - * @return UserEntityInterface + * @return static */ - public function setLastLanguage(string $lang): UserEntityInterface + public function setLastLanguage(string $lang): static { $this->last_language = $lang; return $this; @@ -1117,9 +1117,9 @@ public function hasUserProvidedEmail(): bool * * @param bool $userProvided New value * - * @return UserEntityInterface + * @return static */ - public function setHasUserProvidedEmail(bool $userProvided): UserEntityInterface + public function setHasUserProvidedEmail(bool $userProvided): static { $this->user_provided_email = $userProvided ? 1 : 0; return $this; @@ -1130,9 +1130,9 @@ public function setHasUserProvidedEmail(bool $userProvided): UserEntityInterface * * @param DateTime $dateTime Last login date * - * @return UserEntityInterface + * @return static */ - public function setLastLogin(DateTime $dateTime): UserEntityInterface + public function setLastLogin(DateTime $dateTime): static { $this->last_login = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -1153,9 +1153,9 @@ public function getLastLogin(): DateTime * * @param DateTime $dateTime Creation date * - * @return UserEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): UserEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -1176,9 +1176,9 @@ public function getCreated(): DateTime * * @param ?DateTime $dateTime Verification date (or null) * - * @return UserEntityInterface + * @return static */ - public function setEmailVerified(?DateTime $dateTime): UserEntityInterface + public function setEmailVerified(?DateTime $dateTime): static { $this->email_verified = $dateTime?->format('Y-m-d H:i:s'); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/UserCard.php b/module/VuFind/src/VuFind/Db/Row/UserCard.php index 0811386aff5..0b9b14f8f72 100644 --- a/module/VuFind/src/VuFind/Db/Row/UserCard.php +++ b/module/VuFind/src/VuFind/Db/Row/UserCard.php @@ -82,9 +82,9 @@ public function getId(): ?int * * @param string $cardName User card name. * - * @return UserCardEntityInterface + * @return static */ - public function setCardName(string $cardName): UserCardEntityInterface + public function setCardName(string $cardName): static { $this->card_name = $cardName; return $this; @@ -105,9 +105,9 @@ public function getCardName(): string * * @param string $catUsername Catalog username * - * @return UserCardEntityInterface + * @return static */ - public function setCatUsername(string $catUsername): UserCardEntityInterface + public function setCatUsername(string $catUsername): static { $this->cat_username = $catUsername; return $this; @@ -128,9 +128,9 @@ public function getCatUsername(): string * * @param ?string $catPassword Cat password * - * @return UserCardEntityInterface + * @return static */ - public function setRawCatPassword(?string $catPassword): UserCardEntityInterface + public function setRawCatPassword(?string $catPassword): static { $this->cat_password = $catPassword; return $this; @@ -151,9 +151,9 @@ public function getRawCatPassword(): ?string * * @param ?string $passEnc Encrypted password * - * @return UserCardEntityInterface + * @return static */ - public function setCatPassEnc(?string $passEnc): UserCardEntityInterface + public function setCatPassEnc(?string $passEnc): static { $this->cat_pass_enc = $passEnc; return $this; @@ -174,9 +174,9 @@ public function getCatPassEnc(): ?string * * @param ?string $homeLibrary Home library * - * @return UserCardEntityInterface + * @return static */ - public function setHomeLibrary(?string $homeLibrary): UserCardEntityInterface + public function setHomeLibrary(?string $homeLibrary): static { $this->home_library = $homeLibrary; return $this; @@ -197,9 +197,9 @@ public function getHomeLibrary(): ?string * * @param DateTime $dateTime Created date * - * @return UserCardEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): UserCardEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -220,9 +220,9 @@ public function getCreated(): DateTime * * @param DateTime $dateTime Saved date and time * - * @return UserCardEntityInterface + * @return static */ - public function setSaved(DateTime $dateTime): UserCardEntityInterface + public function setSaved(DateTime $dateTime): static { $this->saved = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -243,9 +243,9 @@ public function getSaved(): DateTime * * @param UserEntityInterface $user User that owns card * - * @return UserCardEntityInterface + * @return static */ - public function setUser(UserEntityInterface $user): UserCardEntityInterface + public function setUser(UserEntityInterface $user): static { $this->user_id = $user->getId(); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/UserList.php b/module/VuFind/src/VuFind/Db/Row/UserList.php index c546221339c..a6c9471ef30 100644 --- a/module/VuFind/src/VuFind/Db/Row/UserList.php +++ b/module/VuFind/src/VuFind/Db/Row/UserList.php @@ -263,9 +263,9 @@ public function getId(): ?int * * @param string $title Title * - * @return UserListEntityInterface + * @return static */ - public function setTitle(string $title): UserListEntityInterface + public function setTitle(string $title): static { $this->title = $title; return $this; @@ -286,9 +286,9 @@ public function getTitle(): string * * @param ?string $description Description * - * @return UserListEntityInterface + * @return static */ - public function setDescription(?string $description): UserListEntityInterface + public function setDescription(?string $description): static { $this->description = $description; return $this; @@ -309,9 +309,9 @@ public function getDescription(): ?string * * @param DateTime $dateTime Created date * - * @return UserListEntityInterface + * @return static */ - public function setCreated(DateTime $dateTime): UserListEntityInterface + public function setCreated(DateTime $dateTime): static { $this->created = $dateTime->format('Y-m-d H:i:s'); return $this; @@ -332,9 +332,9 @@ public function getCreated(): DateTime * * @param bool $public Is the list public? * - * @return UserListEntityInterface + * @return static */ - public function setPublic(bool $public): UserListEntityInterface + public function setPublic(bool $public): static { $this->public = $public ? '1' : '0'; return $this; @@ -345,9 +345,9 @@ public function setPublic(bool $public): UserListEntityInterface * * @param ?UserEntityInterface $user User owning the list. * - * @return UserListEntityInterface + * @return static */ - public function setUser(?UserEntityInterface $user): UserListEntityInterface + public function setUser(?UserEntityInterface $user): static { $this->user_id = $user?->getId(); return $this; diff --git a/module/VuFind/src/VuFind/Db/Row/UserResource.php b/module/VuFind/src/VuFind/Db/Row/UserResource.php index d8a5e110ab3..85b9dd2d274 100644 --- a/module/VuFind/src/VuFind/Db/Row/UserResource.php +++ b/module/VuFind/src/VuFind/Db/Row/UserResource.php @@ -57,7 +57,7 @@ * @property string $saved */ class UserResource extends RowGateway implements - \VuFind\Db\Entity\UserResourceEntityInterface, + UserResourceEntityInterface, \VuFind\Db\Table\DbTableAwareInterface, DbServiceAwareInterface { @@ -100,9 +100,9 @@ public function getUser(): UserEntityInterface * * @param UserEntityInterface $user User * - * @return UserResourceEntityInterface + * @return static */ - public function setUser(UserEntityInterface $user): UserResourceEntityInterface + public function setUser(UserEntityInterface $user): static { $this->user_id = $user->getId(); return $this; @@ -124,9 +124,9 @@ public function getResource(): ResourceEntityInterface * * @param ResourceEntityInterface $resource Resource * - * @return UserResourceEntityInterface + * @return static */ - public function setResource(ResourceEntityInterface $resource): UserResourceEntityInterface + public function setResource(ResourceEntityInterface $resource): static { $this->resource_id = $resource->getId(); return $this; @@ -149,9 +149,9 @@ public function getUserList(): ?UserListEntityInterface * * @param ?UserListEntityInterface $list User list * - * @return UserResourceEntityInterface + * @return static */ - public function setUserList(?UserListEntityInterface $list): UserResourceEntityInterface + public function setUserList(?UserListEntityInterface $list): static { $this->list_id = $list?->getId(); return $this; @@ -172,9 +172,9 @@ public function getNotes(): ?string * * @param ?string $notes Notes associated with the resource * - * @return UserResourceEntityInterface + * @return static */ - public function setNotes(?string $notes): UserResourceEntityInterface + public function setNotes(?string $notes): static { $this->notes = $notes; return $this; @@ -195,9 +195,9 @@ public function getSaved(): DateTime * * @param DateTime $dateTime Created date * - * @return UserResourceEntityInterface + * @return static */ - public function setSaved(DateTime $dateTime): UserResourceEntityInterface + public function setSaved(DateTime $dateTime): static { $this->saved = $dateTime->format('Y-m-d H:i:s'); return $this; From e72625da021099c610d1ee663ece7a4b4d8da62b Mon Sep 17 00:00:00 2001 From: Thomas Wagener Date: Thu, 12 Sep 2024 14:13:49 +0200 Subject: [PATCH 004/139] Signature fix of Solr's backend terms method (#3885) --- .../src/VuFindSearch/Backend/Solr/Backend.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php index afa5966086f..a104d0e7da5 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php @@ -334,18 +334,18 @@ public function similar($id, ParamBag $params = null) /** * Return terms from SOLR index. * - * @param string $field Index field - * @param string $start Starting term (blank for beginning of list) - * @param int $limit Maximum number of terms - * @param ParamBag $params Additional parameters + * @param string|ParamBag|null $field Index field + * @param ?string $start Starting term (blank for beginning of list) + * @param ?int $limit Maximum number of terms + * @param ?ParamBag $params Additional parameters * * @return Terms */ public function terms( - $field = null, - $start = null, - $limit = null, - ParamBag $params = null + string|ParamBag|null $field = null, + ?string $start = null, + ?int $limit = null, + ?ParamBag $params = null ) { // Support alternate syntax with ParamBag as first parameter: if ($field instanceof ParamBag && $params === null) { From d073ffa4daa718c440d810120718a5c98fecf75c Mon Sep 17 00:00:00 2001 From: Thomas Wagener Date: Thu, 12 Sep 2024 21:48:16 +0200 Subject: [PATCH 005/139] Preprocess query string before normalization (#3932) --- .../Backend/Solr/QueryBuilder.php | 7 +++- .../Backend/Solr/QueryBuilderTest.php | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php index 0c765fa35db..c0f9cd642d4 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/QueryBuilder.php @@ -157,7 +157,6 @@ public function build(AbstractQuery $query, ?ParamBag $params = null) $highlight = !empty($this->fieldsToHighlight); if ($handler = $this->getSearchHandler($finalQuery->getHandler(), $string)) { - $string = $handler->preprocessQueryString($string); if ( !$handler->hasExtendedDismax() && $this->getLuceneHelper()->containsAdvancedLuceneSyntax($string) @@ -577,9 +576,13 @@ protected function fixTrailingQuestionMarks($string) */ protected function getNormalizedQueryString($query) { + $queryString = $query->getString(); + if ($handler = $this->getSearchHandler($query->getHandler(), $queryString)) { + $queryString = $handler->preprocessQueryString($queryString); + } return $this->fixTrailingQuestionMarks( $this->getLuceneHelper()->normalizeSearchString( - $query->getString() + $queryString ) ); } diff --git a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/QueryBuilderTest.php b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/QueryBuilderTest.php index 6337c52e7ec..cb524c09e9b 100644 --- a/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/QueryBuilderTest.php +++ b/module/VuFindSearch/tests/unit-tests/src/VuFindTest/Backend/Solr/QueryBuilderTest.php @@ -983,4 +983,41 @@ public function testNegatedOrQuery() $response->get('q') ); } + + /** + * Test dismax munge. + * + * @return void + */ + public function testDismaxMunge() + { + // Set up an array of expected inputs and outputs: + $tests = [ + ['title - sub', 'title sub'], // normalization of freestanding hyphen + ['test + test', 'test and test'], // freestanding plus with munge + ['test+test', 'test+test'], // non-freestanding plus + ['test~0.9', 'test0.9'], // munge for removing char + ['test~10', 'test 10'], // more specific munge followed by normalization + ['TEST', 'test'], // lc munge + ]; + $specs = [ + 'test' => [ + 'DismaxFields' => ['foo'], + 'DismaxMunge' => [ + ['preg_replace', '/\s[\+]\s/', ' and '], + ['preg_replace', '/~1/', ' + 1'], + ['preg_replace', '/~/', ''], + ['lowercase'], + ], + ], + ]; + $qb = new QueryBuilder($specs); + foreach ($tests as $test) { + [$input, $output] = $test; + $q = new Query($input, 'test'); + $response = $qb->build($q); + $processedQ = $response->get('q'); + $this->assertEquals($output, $processedQ[0]); + } + } } From 6843dd12d131e28af5bd863165c11564cdaddef2 Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Thu, 12 Sep 2024 16:05:05 -0400 Subject: [PATCH 006/139] [VUFIND-1665] Persist limit value in DefaultRecord search links. (#3834) --- .../VuFindTest/Mink/ContainerLinksTest.php | 8 +++++-- .../DefaultRecord/link-author.phtml | 21 +++++++++++++------ .../DefaultRecord/link-journaltitle.phtml | 12 +++++++++-- .../DefaultRecord/link-publisher.phtml | 12 +++++++++-- .../DefaultRecord/link-series.phtml | 12 +++++++++-- .../DefaultRecord/link-subject.phtml | 12 +++++++++-- .../DefaultRecord/link-title.phtml | 12 +++++++++-- .../DefaultRecord/link-author.phtml | 21 +++++++++++++------ .../DefaultRecord/link-journaltitle.phtml | 12 +++++++++-- .../DefaultRecord/link-publisher.phtml | 12 +++++++++-- .../DefaultRecord/link-series.phtml | 12 +++++++++-- .../DefaultRecord/link-subject.phtml | 12 +++++++++-- .../DefaultRecord/link-title.phtml | 12 +++++++++-- 13 files changed, 136 insertions(+), 34 deletions(-) diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ContainerLinksTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ContainerLinksTest.php index 36bede702cf..5b54d62595e 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ContainerLinksTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/ContainerLinksTest.php @@ -66,10 +66,14 @@ protected function goToCollection() public function testDefaultContainerLinks(): void { $page = $this->performSearch('id:jnl1-1'); + $url = $this->findCss($page, '.result-body a.container-link')->getAttribute('href'); $this->assertMatchesRegularExpression( - '{.*/Search/Results\?lookfor=%22Arithmetic\+Facts%22&type=JournalTitle}', - $this->findCss($page, '.result-body a.container-link')->getAttribute('href') + '{.*/Search/Results}', + parse_url($url, PHP_URL_PATH) ); + parse_str(parse_url($url, PHP_URL_QUERY), $query); + $this->assertEquals('JournalTitle', $query['type']); + $this->assertEquals('"Arithmetic Facts"', $query['lookfor']); } /** diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-author.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-author.phtml index fd2570c81d0..670a745e0f6 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-author.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-author.phtml @@ -1,7 +1,16 @@ -searchOptions($this->driver->getSearchBackendIdentifier())->getSearchAction(); ?> url('author-home') . '?author=' . urlencode($this->lookfor); -} else { - echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=Author'; -} + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + if ($searchRoute === 'search-results') { // override search-results with author module + $searchRoute = 'author-home'; + $query = ['author' => $this->lookfor]; + } else { + $query = ['lookfor' => '"' . $this->lookfor . '"', 'type' => 'Author']; + } + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-journaltitle.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-journaltitle.phtml index 7022d5f9ac0..d5c4e1075d7 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-journaltitle.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-journaltitle.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSourceIdentifier())->getSearchAction(); -echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=JournalTitle'; + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'JournalTitle', 'lookfor' => '"' . $this->lookfor . '"']; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-publisher.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-publisher.phtml index 81634c1b93d..e7c179e914e 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-publisher.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-publisher.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSearchBackendIdentifier())->getSearchAction(); -echo $this->url($searchRoute, [], ['query' => ['type' => 'Publisher', 'lookfor' => $this->lookfor]]); + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'Publisher', 'lookfor' => $this->lookfor]; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-series.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-series.phtml index eea7ad2f0de..2397851c1f5 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-series.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-series.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSourceIdentifier())->getSearchAction(); -echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=Series'; + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'Series', 'lookfor' => '"' . $this->lookfor . '"']; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-subject.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-subject.phtml index 04a88ea549f..e1e3a0ab8d5 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-subject.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-subject.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSearchBackendIdentifier())->getSearchAction(); -echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=Subject'; + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'Subject', 'lookfor' => '"' . $this->lookfor . '"']; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-title.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-title.phtml index 4dba364b18a..1656980187e 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-title.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/link-title.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSourceIdentifier())->getSearchAction(); -echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=Title'; + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'Title', 'lookfor' => '"' . $this->lookfor . '"']; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-author.phtml b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-author.phtml index fd2570c81d0..670a745e0f6 100644 --- a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-author.phtml +++ b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-author.phtml @@ -1,7 +1,16 @@ -searchOptions($this->driver->getSearchBackendIdentifier())->getSearchAction(); ?> url('author-home') . '?author=' . urlencode($this->lookfor); -} else { - echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=Author'; -} + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + if ($searchRoute === 'search-results') { // override search-results with author module + $searchRoute = 'author-home'; + $query = ['author' => $this->lookfor]; + } else { + $query = ['lookfor' => '"' . $this->lookfor . '"', 'type' => 'Author']; + } + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-journaltitle.phtml b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-journaltitle.phtml index 7022d5f9ac0..d5c4e1075d7 100644 --- a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-journaltitle.phtml +++ b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-journaltitle.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSourceIdentifier())->getSearchAction(); -echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=JournalTitle'; + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'JournalTitle', 'lookfor' => '"' . $this->lookfor . '"']; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-publisher.phtml b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-publisher.phtml index 81634c1b93d..e7c179e914e 100644 --- a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-publisher.phtml +++ b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-publisher.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSearchBackendIdentifier())->getSearchAction(); -echo $this->url($searchRoute, [], ['query' => ['type' => 'Publisher', 'lookfor' => $this->lookfor]]); + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'Publisher', 'lookfor' => $this->lookfor]; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-series.phtml b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-series.phtml index eea7ad2f0de..2397851c1f5 100644 --- a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-series.phtml +++ b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-series.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSourceIdentifier())->getSearchAction(); -echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=Series'; + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'Series', 'lookfor' => '"' . $this->lookfor . '"']; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-subject.phtml b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-subject.phtml index 04a88ea549f..e1e3a0ab8d5 100644 --- a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-subject.phtml +++ b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-subject.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSearchBackendIdentifier())->getSearchAction(); -echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=Subject'; + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'Subject', 'lookfor' => '"' . $this->lookfor . '"']; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); diff --git a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-title.phtml b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-title.phtml index 4dba364b18a..1656980187e 100644 --- a/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-title.phtml +++ b/themes/bootstrap5/templates/RecordDriver/DefaultRecord/link-title.phtml @@ -1,3 +1,11 @@ searchOptions($this->driver->getSourceIdentifier())->getSearchAction(); -echo $this->url($searchRoute) . '?lookfor=%22' . urlencode($this->lookfor) . '%22&type=Title'; + $searchBackendId = $this->driver->getSearchBackendIdentifier(); + $options = $this->searchOptions($searchBackendId); + $searchRoute = $options->getSearchAction(); + $query = ['type' => 'Title', 'lookfor' => '"' . $this->lookfor . '"']; + if (($limit = $this->searchMemory()->getLastLimit($searchBackendId)) + && $limit !== $options->getDefaultLimit() + ) { + $query['limit'] = $limit; + } + echo $this->url($searchRoute, [], compact('query')); From 29e443267a23817ae92905f98d7d59b3d73bf88e Mon Sep 17 00:00:00 2001 From: Thomas Wagener Date: Thu, 12 Sep 2024 22:10:33 +0200 Subject: [PATCH 007/139] Disable jumpto for last search urls (#3935) --- .../src/VuFind/Search/UrlQueryHelper.php | 38 +++++++++++++------ .../VuFind/View/Helper/Root/SearchMemory.php | 1 + .../src/VuFindTest/Mink/JumpToRecordTest.php | 10 +++++ .../View/Helper/Root/SearchMemoryTest.php | 1 + 4 files changed, 39 insertions(+), 11 deletions(-) diff --git a/module/VuFind/src/VuFind/Search/UrlQueryHelper.php b/module/VuFind/src/VuFind/Search/UrlQueryHelper.php index db0efc57a79..ec7a8b9c222 100644 --- a/module/VuFind/src/VuFind/Search/UrlQueryHelper.php +++ b/module/VuFind/src/VuFind/Search/UrlQueryHelper.php @@ -340,7 +340,7 @@ public function addFilter($filter) /** * Remove all filters. * - * @return string + * @return UrlQueryHelper */ public function removeAllFilters() { @@ -354,7 +354,7 @@ public function removeAllFilters() /** * Reset default filter state. * - * @return string + * @return UrlQueryHelper */ public function resetDefaultFilters() { @@ -474,7 +474,7 @@ public function removeFacet($field, $value, $operator = 'AND') * * @param string $filter Filter to add * - * @return string + * @return UrlQueryHelper */ public function removeFilter($filter) { @@ -488,7 +488,7 @@ public function removeFilter($filter) * * @param string $p New page parameter (null for NO page parameter) * - * @return string + * @return UrlQueryHelper */ public function setPage($p) { @@ -501,7 +501,7 @@ public function setPage($p) * * @param string $s New sort parameter (null for NO sort parameter) * - * @return string + * @return UrlQueryHelper */ public function setSort($s) { @@ -519,7 +519,7 @@ public function setSort($s) * * @param string $handler new Handler. * - * @return string + * @return UrlQueryHelper */ public function setHandler($handler) { @@ -540,7 +540,7 @@ public function setHandler($handler) * * @param string $v New sort parameter (null for NO view parameter) * - * @return string + * @return UrlQueryHelper */ public function setViewParam($v) { @@ -556,7 +556,7 @@ public function setViewParam($v) * * @param string $l New limit parameter (null for NO limit parameter) * - * @return string + * @return UrlQueryHelper */ public function setLimit($l) { @@ -568,13 +568,29 @@ public function setLimit($l) ); } + /** + * Return HTTP parameters to render the current page with a different jumpto + * parameter. + * + * @param null|false|int $jumpto If results page is skipped when a search has only one hit + * + * @return UrlQueryHelper + */ + public function setJumpto(null|false|int $jumpto): UrlQueryHelper + { + return $this->updateQueryString( + 'jumpto', + $jumpto + ); + } + /** * Return HTTP parameters to render the current page with a different set * of search terms. * * @param string $lookfor New search terms * - * @return string + * @return UrlQueryHelper */ public function setSearchTerms($lookfor) { @@ -664,7 +680,7 @@ protected function filtered($field, $value, $filter) * for no default). * @param bool $clearPage Should we clear the page number, if any? * - * @return string + * @return UrlQueryHelper */ protected function updateQueryString( $field, @@ -673,7 +689,7 @@ protected function updateQueryString( $clearPage = false ) { $params = $this->urlParams; - if (null === $value || $value == $default) { + if (null === $value || $value === $default) { unset($params[$field]); } else { $params[$field] = $value; diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchMemory.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchMemory.php index c6928656be6..7ad8007e3ff 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/SearchMemory.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchMemory.php @@ -111,6 +111,7 @@ public function getLastSearchUrl(): ?string if (!empty($searchContext['page'])) { $queryHelper = $queryHelper->setPage($searchContext['page']); } + $queryHelper = $queryHelper->setJumpto(false); $url .= $queryHelper->getParams(false); diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/JumpToRecordTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/JumpToRecordTest.php index ba30f4bf249..df7b2b66e30 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/JumpToRecordTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/JumpToRecordTest.php @@ -57,6 +57,16 @@ public function testJumpToFirst() 'La congiura dei Principi Napoletani 1701 : (prima e seconda stesura) /', trim($this->findCssAndGetText($page, 'h1')) ); + + // check if jump to is disabled on breadcrumb link + $this->clickCss($page, '.breadcrumb li:first-child'); + $this->waitForPageLoad($page); + + $expected = 'Showing 1 - 1 results of 1'; + $this->assertStringStartsWith( + $expected, + $this->findCssAndGetText($page, '.search-stats') + ); } /** diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/SearchMemoryTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/SearchMemoryTest.php index 5c7b8a2486f..7d6d3f27d39 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/SearchMemoryTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/SearchMemoryTest.php @@ -94,6 +94,7 @@ protected function getMockSolrResults(): MockObject&Results $solrOptions = $solrParams->getOptions(); $solrOptions->expects($this->once())->method('getSearchAction')->willReturn($this->searchRoute); $mockQueryHelper = $this->createMock(UrlQueryHelper::class); + $mockQueryHelper->expects($this->any())->method('setJumpto')->willReturn($mockQueryHelper); $results = $this->createMock(Results::class); $results->expects($this->any())->method('getOptions')->willReturn($solrOptions); $results->expects($this->any())->method('getParams')->willReturn($solrParams); From fd8dc643482534f2d539d4fbe40c106a6c772d4e Mon Sep 17 00:00:00 2001 From: rominail Date: Fri, 13 Sep 2024 08:41:42 -0400 Subject: [PATCH 008/139] Possibility to use secret file rather than string password in config files (#3860) --- config/vufind/BrowZine.ini | 2 + config/vufind/EDS.ini | 2 + config/vufind/EPF.ini | 2 + config/vufind/Folio.ini | 2 + config/vufind/config.ini | 13 +- .../src/org/vufind/index/DatabaseManager.java | 143 ++++++++++++++---- .../src/VuFind/Config/Feature/SecretTrait.php | 84 ++++++++++ .../VuFind/Controller/InstallController.php | 22 +-- .../VuFind/src/VuFind/Db/AdapterFactory.php | 89 ++++++++--- module/VuFind/src/VuFind/ILS/Driver/Folio.php | 4 +- .../Search/Factory/BrowZineBackendFactory.php | 8 +- .../src/VuFind/Service/ReCaptchaFactory.php | 5 +- .../src/VuFindSearch/Backend/EDS/Backend.php | 7 +- 13 files changed, 313 insertions(+), 70 deletions(-) create mode 100644 module/VuFind/src/VuFind/Config/Feature/SecretTrait.php diff --git a/config/vufind/BrowZine.ini b/config/vufind/BrowZine.ini index 6345c609aa0..dce09baa526 100644 --- a/config/vufind/BrowZine.ini +++ b/config/vufind/BrowZine.ini @@ -4,6 +4,8 @@ [General] ; BrowZine-issued access token for API access_token = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +; Use access_token_file to load the secret from another file instead of including it directly in this configuration. +;access_token_file = /path/to/secret ; The ID number of your library (found in your BrowZine public access URL) library_id = "yyy" diff --git a/config/vufind/EDS.ini b/config/vufind/EDS.ini index 67fce1d8477..13605e34c08 100644 --- a/config/vufind/EDS.ini +++ b/config/vufind/EDS.ini @@ -271,6 +271,8 @@ next_prev_navigation = false ip_auth = false user_name = "USERNAME" password = "PASSWORD" +; Use password_file to load the secret from another file instead of including it directly in this configuration. +;password_file = /path/to/secret profile = "PROFILE" organization_id = "VuFind from MyUniversity" diff --git a/config/vufind/EPF.ini b/config/vufind/EPF.ini index 5c55710efb3..15ae4ff23db 100644 --- a/config/vufind/EPF.ini +++ b/config/vufind/EPF.ini @@ -111,5 +111,7 @@ top_rows = 2 ip_auth = false user_name = [USERNAME] password = [PASSWORD] +; Use password_file to load the secret from another file instead of including it directly in this configuration. +;password_file = /path/to/secret profile = [PROFILE] organization_id = "VuFind from MyUniversity" diff --git a/config/vufind/Folio.ini b/config/vufind/Folio.ini index 65870d59cc0..b8c03133043 100644 --- a/config/vufind/Folio.ini +++ b/config/vufind/Folio.ini @@ -6,6 +6,8 @@ base_url = https://localhost:9130 ; https://vufind.org/wiki/configuration:ils:folio username = diku_admin password = admin +; Use password_file to load the secret from another file instead of including it directly in this configuration. +;password_file = /path/to/secret tenant = diku ; If set to true, the driver will log all GET requests as debug messages; if false ; (the default), it will only log POSTs to reduce noise. diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 6dc6cfa4b75..3b8c5cd264f 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -771,13 +771,22 @@ url_shortener_key_type = md5 [Database] ; Connection string format is [platform]://[username]:[password]@[host]:[port]/[db] ; where: -; [platform] = database platform (mysql, oci8 or pgsql) +; [platform/driver] = database platform (mysql, oci8 or pgsql) ; [username] = username for connection ; [password] = password for connection (optional) ; [host] = host of database server ; [port] = port of database server (optional) ; [db] = database name +; For more granular configuration, comment out the database setting and use the individual parameters below. database = mysql://root@localhost/vufind +;database_driver = "mysql" +;database_username = "notroot" +;database_password = "password" +; database_password_file will be used in priority over database_password +;database_password_file = "/path/to/secret" +;database_host = "localhost" +;database_port = "3306" +;database_name = "vufind" ; Should SSL be enabled on connections? (Currently only supported for MySQL). ; IMPORTANT: when using Linux, if your database connection string above uses @@ -2448,6 +2457,8 @@ validateHierarchySequences = true ; [Http] section, or your Captcha may not work. ;recaptcha_siteKey = "get your reCaptcha key at" ;recaptcha_secretKey = "https://www.google.com/recaptcha/admin/create" +; Use recaptcha_secretKey_file to load the secret from another file instead of including it directly in this configuration. +;recaptcha_secretKey_file = /path/to/secret ; Valid theme values: dark, light ;recaptcha_theme = light diff --git a/import/index_java/src/org/vufind/index/DatabaseManager.java b/import/index_java/src/org/vufind/index/DatabaseManager.java index a1f9ac26a43..4173c7d0293 100644 --- a/import/index_java/src/org/vufind/index/DatabaseManager.java +++ b/import/index_java/src/org/vufind/index/DatabaseManager.java @@ -21,6 +21,10 @@ import org.apache.log4j.Logger; import org.solrmarc.tools.SolrMarcIndexerException; import java.sql.*; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.Path; /** * Database manager. @@ -70,49 +74,122 @@ private void connectToDatabase() if (vufindDatabase != null) { return; } + try { + connectToDatabaseUsingSplitConfig(); + } catch (Throwable e) { + logger.warn("Unable to connect to database using split config (" + e.getMessage() + ")"); + } + // If the split config allowed to setup the DB, do nothing further + if (vufindDatabase != null) { + return; + } + try { + connectToDatabaseUsingStringConfig(); + } catch (Throwable e) { + dieWithError("Unable to connect to VuFind database; " + e.getMessage()); + } + } + /** + * Connect to the VuFind database using the legacy PHP-style connection string in config.ini. + */ + private void connectToDatabaseUsingStringConfig() throws Throwable + { String dsn = ConfigManager.instance().getConfigSetting("config.ini", "Database", "database"); + if (dsn == null || dsn.isEmpty()) { + throw new Exception("Cannot find working database settings in config.ini"); + } - try { - // Parse key settings from the PHP-style DSN: - String username = ""; - String password = ""; - String classname = "invalid"; - String prefix = "invalid"; - String extraParams = ""; - if (dsn.substring(0, 8).equals("mysql://")) { - classname = "com.mysql.jdbc.Driver"; - prefix = "mysql"; - String useSsl = ConfigManager.instance().getBooleanConfigSetting("config.ini", "Database", "use_ssl", false) ? "true" : "false"; - extraParams = "?useSSL=" + useSsl; - if (useSsl != "false") { - String verifyCert = ConfigManager.instance().getBooleanConfigSetting("config.ini", "Database", "verify_server_certificate", false) ? "true" : "false"; - extraParams += "&verifyServerCertificate=" + verifyCert; - } - } else if (dsn.substring(0, 8).equals("pgsql://")) { - classname = "org.postgresql.Driver"; - prefix = "postgresql"; - } + // Parse key settings from the PHP-style DSN: + String platform = "invalid"; + if (dsn.substring(0, 8).equals("mysql://")) { + platform = "mysql"; + } else if (dsn.substring(0, 8).equals("pgsql://")) { + platform = "postgresql"; + } - Class.forName(classname).getDeclaredConstructor().newInstance(); - String[] parts = dsn.split("://"); + String host = ""; + String port = ""; + String name = ""; + String username = ""; + String password = ""; + String[] parts = dsn.split("://"); + if (parts.length > 1) { + parts = parts[1].split("@"); if (parts.length > 1) { - parts = parts[1].split("@"); + String[] pathParts = parts[1].split("/"); + name = pathParts[pathParts.length - 1]; + String[] hostParts = pathParts[0].split(":"); + host = hostParts[0]; + if (hostParts.length > 1) { + port = hostParts[1]; + } + parts = parts[0].split(":"); + username = parts[0]; if (parts.length > 1) { - dsn = prefix + "://" + parts[1]; - parts = parts[0].split(":"); - username = parts[0]; - if (parts.length > 1) { - password = parts[1]; - } + password = parts[1]; } } + } + connectToDatabaseUsingParams(platform, host, port, name, username, password); + } - // Connect to the database: - vufindDatabase = DriverManager.getConnection("jdbc:" + dsn + extraParams, username, password); - } catch (Throwable e) { - dieWithError("Unable to connect to VuFind database; " + e.getMessage()); + /** + * Connect to the VuFind database using the preferred granular config.ini settings. + */ + private void connectToDatabaseUsingSplitConfig() throws Throwable + { + String username = ConfigManager.instance().getConfigSetting("config.ini", "Database", "database_username"); + String password = ""; + String passwordFile = ConfigManager.instance().getConfigSetting("config.ini", "Database", "database_password_file"); + if (passwordFile != null && !passwordFile.isEmpty()) { + Path passwordFilePath = Paths.get(passwordFile); + password = Files.readString(passwordFilePath, Charset.defaultCharset()).trim(); + } + if (password.isEmpty()) { + password = ConfigManager.instance().getConfigSetting("config.ini", "Database", "database_password"); } + String host = ConfigManager.instance().getConfigSetting("config.ini", "Database", "database_host"); + String port = ConfigManager.instance().getConfigSetting("config.ini", "Database", "database_port"); + String name = ConfigManager.instance().getConfigSetting("config.ini", "Database", "database_name"); + String platform = ConfigManager.instance().getConfigSetting("config.ini", "Database", "database_driver"); + // If no platform is set, don't bother trying to connect: + if (platform != null && !platform.isEmpty()) { + connectToDatabaseUsingParams(platform, host, port, name, username, password); + } + } + + /** + * Connect to the VuFind database using provided values + */ + private void connectToDatabaseUsingParams(String platform, String host, String port, String name, String username, String password) throws Throwable + { + String classname = "invalid"; + String extraParams = ""; + String prefix = "invalid"; + if (platform.equals("mysql")) { + classname = "com.mysql.jdbc.Driver"; + prefix = "mysql"; + String useSsl = ConfigManager.instance().getBooleanConfigSetting("config.ini", "Database", "use_ssl", false) ? "true" : "false"; + extraParams = "?useSSL=" + useSsl; + if (useSsl != "false") { + String verifyCert = ConfigManager.instance().getBooleanConfigSetting("config.ini", "Database", "verify_server_certificate", false) ? "true" : "false"; + extraParams += "&verifyServerCertificate=" + verifyCert; + } + } else if (platform.equals("pgsql") || platform.equals("postgresql")) { + classname = "org.postgresql.Driver"; + prefix = "postgresql"; + } + + Class.forName(classname).getDeclaredConstructor().newInstance(); + String dsn = prefix + "://" + host; + if (!port.isEmpty()) { + dsn = dsn + ":" + port; + } + dsn = dsn + "/" + name; + + // Connect to the database: + vufindDatabase = DriverManager.getConnection("jdbc:" + dsn + extraParams, username, password); Runtime.getRuntime().addShutdownHook(new DatabaseManagerShutdownThread(this)); } diff --git a/module/VuFind/src/VuFind/Config/Feature/SecretTrait.php b/module/VuFind/src/VuFind/Config/Feature/SecretTrait.php new file mode 100644 index 00000000000..44eb21c9b6c --- /dev/null +++ b/module/VuFind/src/VuFind/Config/Feature/SecretTrait.php @@ -0,0 +1,84 @@ + + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ + +namespace VuFind\Config\Feature; + +use Laminas\Config\Config; + +/** + * Trait to import secret from file rather than a hardcoded config + * + * @category VuFind + * @package Config + * @author Robby ROUDON + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ +trait SecretTrait +{ + /** + * Load a secret value from the specified configuration and key. + * Will look for a _file-suffixed version of the key first, + * and load the data from a separate file if configured to do so. + * + * @param Config|array|null $config The config to read from + * @param string $key The key to retrieve + * + * @return string|null + */ + protected function getSecretFromConfig(Config|array|null $config, string $key): ?string + { + if ($config === null) { + return null; + } + if ($config instanceof Config) { + $config = $config->toArray(); + } + if ($secretFile = $config[$key . '_file'] ?? null) { + if (is_readable($secretFile)) { + $value = file_get_contents($secretFile); + return trim($value); + } elseif (method_exists($this, 'logWarning')) { + $this->logWarning( + 'The secret file (' . $secretFile . ')' . + ' for secret ' . $key . ' doesn\'t exist or is not readable.' + ); + } else { + error_log( + 'The secret file (' . $secretFile . ')' . + ' for secret ' . $key . ' doesn\'t exist or is not readable' + ); + } + } + if (isset($config[$key])) { + return $config[$key]; + } + return null; + } +} diff --git a/module/VuFind/src/VuFind/Controller/InstallController.php b/module/VuFind/src/VuFind/Controller/InstallController.php index 245ef4aeff3..f77f0a04561 100644 --- a/module/VuFind/src/VuFind/Controller/InstallController.php +++ b/module/VuFind/src/VuFind/Controller/InstallController.php @@ -408,14 +408,17 @@ public function fixdatabaseAction() ->addMessage('Password fields must match.', 'error'); } else { // Connect to database: - $connection = $view->driver . '://' . $view->dbrootuser . ':' - . $this->params()->fromPost('dbrootpass') . '@' - . $view->dbhost; try { - $dbName = ($view->driver == 'pgsql') - ? 'template1' : $view->driver; - $db = $this->getService(\VuFind\Db\AdapterFactory::class) - ->getAdapterFromConnectionString("{$connection}/{$dbName}"); + $dbName = ($view->driver == 'pgsql') ? 'template1' : $view->driver; + $connectionParams = [ + 'driver' => $view->driver, + 'hostname' => $view->dbhost, + 'username' => $view->dbrootuser, + 'password' => $this->params()->fromPost('dbrootpass'), + ]; + $db = $this->serviceLocator->get(\VuFind\Db\AdapterFactory::class)->getAdapterFromArray( + $connectionParams + ['database' => $dbName] + ); } catch (\Exception $e) { $this->flashMessenger() ->addMessage( @@ -451,9 +454,8 @@ public function fixdatabaseAction() foreach ($preCommands as $query) { $db->query($query, $db::QUERY_MODE_EXECUTE); } - $dbFactory = $this->getService(\VuFind\Db\AdapterFactory::class); - $db = $dbFactory->getAdapterFromConnectionString( - $connection . '/' . $view->dbname + $db = $this->getService(\VuFind\Db\AdapterFactory::class)->getAdapterFromArray( + $connectionParams + ['database' => $view->dbname] ); $statements = explode(';', $sql); foreach ($statements as $current) { diff --git a/module/VuFind/src/VuFind/Db/AdapterFactory.php b/module/VuFind/src/VuFind/Db/AdapterFactory.php index 9d5d623f9f2..339ca2d9e4a 100644 --- a/module/VuFind/src/VuFind/Db/AdapterFactory.php +++ b/module/VuFind/src/VuFind/Db/AdapterFactory.php @@ -36,6 +36,7 @@ use Laminas\ServiceManager\Exception\ServiceNotFoundException; use Psr\Container\ContainerExceptionInterface as ContainerException; use Psr\Container\ContainerInterface; +use VuFind\Config\Feature\SecretTrait; /** * Database utility class. May be used as a service or as a standard @@ -49,6 +50,8 @@ */ class AdapterFactory implements \Laminas\ServiceManager\Factory\FactoryInterface { + use SecretTrait; + /** * VuFind configuration * @@ -106,15 +109,19 @@ public function __invoke( */ public function getAdapter($overrideUser = null, $overridePass = null) { - // Parse details from connection string: - if (!isset($this->config->Database->database)) { - throw new \Exception('"database" setting missing'); + if (isset($this->config->Database->database)) { + // Parse details from connection string: + return $this->getAdapterFromConnectionString( + $this->config->Database->database, + $overrideUser, + $overridePass + ); + } else { + return $this->getAdapterFromConfig( + $overrideUser, + $overridePass + ); } - return $this->getAdapterFromConnectionString( - $this->config->Database->database, - $overrideUser, - $overridePass - ); } /** @@ -233,26 +240,68 @@ public function getAdapterFromConnectionString( $username = $overrideUser ?? $username; $password = $overridePass ?? $password; - $driverName = $this->getDriverName($type); - $driverOptions = $this->getDriverOptions($driverName); - - // Set up default options: - $options = [ - 'driver' => $driverName, + return $this->getAdapterFromArray([ + 'driver' => $type, 'hostname' => $host, 'username' => $username, 'password' => $password, 'database' => $dbName, 'use_ssl' => $this->config->Database->use_ssl ?? false, - 'driver_options' => $driverOptions, + 'port' => $port ?? null, + ]); + } + + /** + * Obtain a Laminas\DB connection using the config. + * + * @param string $overrideUser Username override (leave null to use username from config) + * @param string $overridePass Password override (leave null to use password from config) + * + * @return Adapter + */ + public function getAdapterFromConfig($overrideUser = null, $overridePass = null) + { + if (!isset($this->config->Database)) { + throw new \Exception('[Database] Configuration section missing'); + } + $config = $this->config->Database; + return $this->getAdapterFromArray([ + 'driver' => $config->database_driver ?? null, + 'hostname' => $config->database_host ?? null, + 'username' => $overrideUser ?? $config->database_username ?? null, + 'password' => $overridePass ?? $this->getSecretFromConfig($config, 'database_password'), + 'database' => $config->database_name, + 'port' => $config->database_port ?? null, + ]); + } + + /** + * Obtain a Laminas\DB connection using a set of given element. + * + * @param array $config Config array to connect to the DB containing + * driver (ie: mysql), username, password, hostname, database (db name), port + * + * @return Adapter + */ + public function getAdapterFromArray(array $config) + { + $driverName = $this->getDriverName($config['driver']); + + // Set up default options: + $options = [ + 'driver' => $driverName, + 'hostname' => $config['hostname'] ?? null, + 'username' => $config['username'] ?? null, + 'password' => $config['password'] ?? null, + 'database' => $config['database'] ?? null, + 'use_ssl' => $this->config->Database->use_ssl ?? false, + 'driver_options' => $this->getDriverOptions($driverName), ]; - if (!empty($port)) { - $options['port'] = $port; + if (isset($config['port'])) { + $options['port'] = $config['port']; } // Get extra custom options from config: - $extraOptions = isset($this->config->Database->extra_options) - ? $this->config->Database->extra_options->toArray() - : []; + $extraOptions = $this->config?->Database?->extra_options?->toArray() ?? []; // Note: $options takes precedence over $extraOptions -- we don't want users // using extended settings to override values from core settings. return $this->getAdapterFromOptions($options + $extraOptions); diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index 0bdef368d65..40ead397998 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -33,6 +33,7 @@ use DateTimeZone; use Exception; use Laminas\Http\Response; +use VuFind\Config\Feature\SecretTrait; use VuFind\Exception\ILS as ILSException; use VuFind\I18n\Translator\TranslatorAwareInterface; use VuFind\ILS\Logic\AvailabilityStatus; @@ -60,6 +61,7 @@ class Folio extends AbstractAPI implements HttpServiceAwareInterface, TranslatorAwareInterface { + use SecretTrait; use \VuFindHttp\HttpServiceAwareTrait; use \VuFind\I18n\Translator\TranslatorAwareTrait; use \VuFind\Log\LoggerAwareTrait { @@ -283,7 +285,7 @@ protected function renewTenantToken() $this->token = null; $response = $this->performOkapiUsernamePasswordAuthentication( $this->config['API']['username'], - $this->config['API']['password'] + $this->getSecretFromConfig($this->config['API'], 'password') ); $this->token = $this->extractTokenFromResponse($response); $this->sessionCache->folio_token = $this->token; diff --git a/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php index 683d8d7b241..3506b694afa 100644 --- a/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php +++ b/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php @@ -30,6 +30,7 @@ namespace VuFind\Search\Factory; use Psr\Container\ContainerInterface; +use VuFind\Config\Feature\SecretTrait; use VuFindSearch\Backend\BrowZine\Backend; use VuFindSearch\Backend\BrowZine\Connector; use VuFindSearch\Backend\BrowZine\QueryBuilder; @@ -46,6 +47,8 @@ */ class BrowZineBackendFactory extends AbstractBackendFactory { + use SecretTrait; + /** * Logger. * @@ -108,8 +111,9 @@ protected function createBackend(Connector $connector) */ protected function createConnector() { + $token = $this->getSecretFromConfig($this->browzineConfig?->General, 'access_token'); // Validate configuration: - if (empty($this->browzineConfig->General->access_token)) { + if ($token === null) { throw new \Exception('Missing access token in BrowZine.ini'); } if (empty($this->browzineConfig->General->library_id)) { @@ -119,7 +123,7 @@ protected function createConnector() // Create connector: $connector = new Connector( $this->createHttpClient($this->browzineConfig->General->timeout ?? 30), - $this->browzineConfig->General->access_token, + $token, $this->browzineConfig->General->library_id ); $connector->setLogger($this->logger); diff --git a/module/VuFind/src/VuFind/Service/ReCaptchaFactory.php b/module/VuFind/src/VuFind/Service/ReCaptchaFactory.php index f2e24f2b2dd..2935a961b5b 100644 --- a/module/VuFind/src/VuFind/Service/ReCaptchaFactory.php +++ b/module/VuFind/src/VuFind/Service/ReCaptchaFactory.php @@ -34,6 +34,7 @@ use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerExceptionInterface as ContainerException; use Psr\Container\ContainerInterface; +use VuFind\Config\Feature\SecretTrait; use VuFind\I18n\Locale\LocaleSettings; /** @@ -47,6 +48,8 @@ */ class ReCaptchaFactory implements FactoryInterface { + use SecretTrait; + /** * Create an object * @@ -95,7 +98,7 @@ public function __invoke( } $siteKey = $recaptchaConfig['recaptcha_siteKey'] ?? ''; - $secretKey = $recaptchaConfig['recaptcha_secretKey'] ?? ''; + $secretKey = $this->getSecretFromConfig($recaptchaConfig, 'recaptcha_secretKey') ?? ''; $httpClient = $container->get(\VuFindHttp\HttpService::class) ->createClient(); $language = $container->get(LocaleSettings::class)->getUserLocale(); diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php index f4d31a9c152..d43321404ea 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php @@ -34,6 +34,7 @@ use Laminas\Cache\Storage\StorageInterface as CacheAdapter; use Laminas\Config\Config; use Laminas\Session\Container as SessionContainer; +use VuFind\Config\Feature\SecretTrait; use VuFindSearch\Backend\AbstractBackend; use VuFindSearch\Backend\Exception\BackendException; use VuFindSearch\ParamBag; @@ -54,6 +55,8 @@ */ class Backend extends AbstractBackend { + use SecretTrait; + /** * Client user to make the actually requests to the EdsApi * @@ -173,7 +176,7 @@ public function __construct( // Extract key values from configuration: $this->userName = $config->EBSCO_Account->user_name ?? null; - $this->password = $config->EBSCO_Account->password ?? null; + $this->password = $this->getSecretFromConfig($config->EBSCO_Account, 'password'); $this->ipAuth = $config->EBSCO_Account->ip_auth ?? false; $this->profile = $config->EBSCO_Account->profile ?? null; $this->orgId = $config->EBSCO_Account->organization_id ?? null; @@ -757,7 +760,7 @@ public function setAuthManager($authManager) /** * Set the EBSCO backend type. Backend/EDS is used for both EDS and EPF. * - * @param str $backendType 'EDS' or 'EPF' + * @param string $backendType 'EDS' or 'EPF' * * @return void */ From e534075ead5b66cbfebb65f3b6586445158869b3 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Fri, 13 Sep 2024 16:23:21 +0300 Subject: [PATCH 009/139] Fix confirm button title attributes. (#3940) --- .../bootstrap3/templates/_ui/components/confirm-button.phtml | 4 ++-- themes/bootstrap3/templates/checkouts/history.phtml | 4 ++-- themes/bootstrap3/templates/holds/list.phtml | 2 +- .../bootstrap5/templates/_ui/components/confirm-button.phtml | 4 ++-- themes/bootstrap5/templates/checkouts/history.phtml | 4 ++-- themes/bootstrap5/templates/holds/list.phtml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/themes/bootstrap3/templates/_ui/components/confirm-button.phtml b/themes/bootstrap3/templates/_ui/components/confirm-button.phtml index 50e97e3337e..299a1dc633b 100644 --- a/themes/bootstrap3/templates/_ui/components/confirm-button.phtml +++ b/themes/bootstrap3/templates/_ui/components/confirm-button.phtml @@ -48,7 +48,7 @@ $confirmAttrs['id'] = $id; } if ($title = $this->confirmTitle) { - $confirmAttrs['title'] = $title; + $confirmAttrs['title'] = $this->translate($title); } if ($class = $this->confirmClass) { $confirmAttrs['class'] .= " $class"; @@ -68,7 +68,7 @@ $cancelAttrs['id'] = $id; } if ($title = $this->cancelTitle) { - $cancelAttrs['title'] = $title; + $cancelAttrs['title'] = $this->translate($title); } if ($class = $this->cancelClass) { $cancelAttrs['class'] .= " $class"; diff --git a/themes/bootstrap3/templates/checkouts/history.phtml b/themes/bootstrap3/templates/checkouts/history.phtml index 9f2227268bf..e39eafcd2f1 100644 --- a/themes/bootstrap3/templates/checkouts/history.phtml +++ b/themes/bootstrap3/templates/checkouts/history.phtml @@ -52,7 +52,7 @@ 'buttonLabel' => 'loan_history_purge_selected', 'header' => 'loan_history_confirm_purge_selected', 'confirmId' => 'confirm_purge_selected_yes', - 'confirmTitle' => 'bookbag_confirm_empty', + 'confirmTitle' => 'loan_history_confirm_purge_selected', 'cancelClass' => 'confirm_purge_no', ] ) @@ -69,7 +69,7 @@ 'buttonLabel' => 'loan_history_purge_all', 'header' => 'loan_history_confirm_purge_all', 'confirmId' => 'confirm_purge_all_yes', - 'confirmTitle' => 'bookbag_confirm_empty', + 'confirmTitle' => 'loan_history_confirm_purge_all', 'cancelClass' => 'confirm_purge_no', ] ) diff --git a/themes/bootstrap3/templates/holds/list.phtml b/themes/bootstrap3/templates/holds/list.phtml index 4f72b8e963d..462db21bec5 100644 --- a/themes/bootstrap3/templates/holds/list.phtml +++ b/themes/bootstrap3/templates/holds/list.phtml @@ -57,7 +57,7 @@ 'buttonLabel' => 'hold_cancel_all', 'header' => 'confirm_hold_cancel_all_text', 'confirmId' => 'confirm_cancel_all_yes', - 'confirmTitle' => 'bookbag_confirm_empty', + 'confirmTitle' => 'confirm_hold_cancel_all_text', 'cancelClass' => 'confirm_cancel_no', 'ignoreLightbox' => true, ] diff --git a/themes/bootstrap5/templates/_ui/components/confirm-button.phtml b/themes/bootstrap5/templates/_ui/components/confirm-button.phtml index 40345b75757..e3daf7c0a33 100644 --- a/themes/bootstrap5/templates/_ui/components/confirm-button.phtml +++ b/themes/bootstrap5/templates/_ui/components/confirm-button.phtml @@ -48,7 +48,7 @@ $confirmAttrs['id'] = $id; } if ($title = $this->confirmTitle) { - $confirmAttrs['title'] = $title; + $confirmAttrs['title'] = $this->translate($title); } if ($class = $this->confirmClass) { $confirmAttrs['class'] .= " $class"; @@ -68,7 +68,7 @@ $cancelAttrs['id'] = $id; } if ($title = $this->cancelTitle) { - $cancelAttrs['title'] = $title; + $cancelAttrs['title'] = $this->translate($title); } if ($class = $this->cancelClass) { $cancelAttrs['class'] .= " $class"; diff --git a/themes/bootstrap5/templates/checkouts/history.phtml b/themes/bootstrap5/templates/checkouts/history.phtml index 9f2227268bf..e39eafcd2f1 100644 --- a/themes/bootstrap5/templates/checkouts/history.phtml +++ b/themes/bootstrap5/templates/checkouts/history.phtml @@ -52,7 +52,7 @@ 'buttonLabel' => 'loan_history_purge_selected', 'header' => 'loan_history_confirm_purge_selected', 'confirmId' => 'confirm_purge_selected_yes', - 'confirmTitle' => 'bookbag_confirm_empty', + 'confirmTitle' => 'loan_history_confirm_purge_selected', 'cancelClass' => 'confirm_purge_no', ] ) @@ -69,7 +69,7 @@ 'buttonLabel' => 'loan_history_purge_all', 'header' => 'loan_history_confirm_purge_all', 'confirmId' => 'confirm_purge_all_yes', - 'confirmTitle' => 'bookbag_confirm_empty', + 'confirmTitle' => 'loan_history_confirm_purge_all', 'cancelClass' => 'confirm_purge_no', ] ) diff --git a/themes/bootstrap5/templates/holds/list.phtml b/themes/bootstrap5/templates/holds/list.phtml index 4f72b8e963d..462db21bec5 100644 --- a/themes/bootstrap5/templates/holds/list.phtml +++ b/themes/bootstrap5/templates/holds/list.phtml @@ -57,7 +57,7 @@ 'buttonLabel' => 'hold_cancel_all', 'header' => 'confirm_hold_cancel_all_text', 'confirmId' => 'confirm_cancel_all_yes', - 'confirmTitle' => 'bookbag_confirm_empty', + 'confirmTitle' => 'confirm_hold_cancel_all_text', 'cancelClass' => 'confirm_cancel_no', 'ignoreLightbox' => true, ] From 84108874f0572130e446333f5c0414b570d9fc5d Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Fri, 13 Sep 2024 09:48:29 -0400 Subject: [PATCH 010/139] Upgrade PHPUnit. --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index a1b5e01b3da..be5ef65e29b 100644 --- a/composer.json +++ b/composer.json @@ -111,7 +111,7 @@ "phpstan/phpstan": "1.12.2", "phpunit/php-code-coverage": "10.1.16", "phpunit/phpcov": "^9.0", - "phpunit/phpunit": "10.5.32", + "phpunit/phpunit": "10.5.34", "pietercolpaert/hardf": "0.5.0", "squizlabs/php_codesniffer": "3.10.2" }, diff --git a/composer.lock b/composer.lock index d22a3b8f501..24e67857a60 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "40bc33d412e92ab73871dcd09b1bf65f", + "content-hash": "d8e2980eedae649fe224b7e49018beeb", "packages": [ { "name": "ahand/mobileesp", @@ -11470,16 +11470,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.32", + "version": "10.5.34", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f069f46840445d37a4e6f0de8c5879598f9c4327" + "reference": "3c69d315bdf79080c8e115b69d1961c6905b0e18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f069f46840445d37a4e6f0de8c5879598f9c4327", - "reference": "f069f46840445d37a4e6f0de8c5879598f9c4327", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3c69d315bdf79080c8e115b69d1961c6905b0e18", + "reference": "3c69d315bdf79080c8e115b69d1961c6905b0e18", "shasum": "" }, "require": { @@ -11551,7 +11551,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.32" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.34" }, "funding": [ { @@ -11567,7 +11567,7 @@ "type": "tidelift" } ], - "time": "2024-09-04T13:33:39+00:00" + "time": "2024-09-13T05:19:38+00:00" }, { "name": "phrity/net-stream", From 829043e6d3f082061f8c64f3798b56be06fd02f1 Mon Sep 17 00:00:00 2001 From: Maccabee Levine <31278545+maccabeelevine@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:43:19 -0400 Subject: [PATCH 011/139] Auto-select single pickup location for a request group (#3933) --- themes/bootstrap3/js/hold.js | 11 ++++++++++- themes/bootstrap5/js/hold.js | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/themes/bootstrap3/js/hold.js b/themes/bootstrap3/js/hold.js index 2cf2c7c7eac..316c434ffd1 100644 --- a/themes/bootstrap3/js/hold.js +++ b/themes/bootstrap3/js/hold.js @@ -34,11 +34,20 @@ function setUpHoldRequestForm(recordId) { $.each(response.data.locations, function holdPickupLocationEach() { var option = $('