diff --git a/lib/AtomFeed.php b/lib/AtomFeed.php index 042adbd1..7bd56075 100644 --- a/lib/AtomFeed.php +++ b/lib/AtomFeed.php @@ -83,7 +83,7 @@ class AtomFeed extends Feed{ $oldEntries[] = $obj; } } - catch(Exception $ex){ + catch(Exception){ // Invalid XML return true; } diff --git a/lib/Core.php b/lib/Core.php index f55686d1..5557b660 100644 --- a/lib/Core.php +++ b/lib/Core.php @@ -41,7 +41,7 @@ if($GLOBALS['User'] === null){ $session->Create($httpBasicAuthLogin); $GLOBALS['User'] = $session->User; } - catch(Exception $ex){ + catch(Exception){ // Do nothing } } diff --git a/lib/Ebook.php b/lib/Ebook.php index d7992b84..dbcfb6b3 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -113,7 +113,7 @@ class Ebook{ $this->TextSinglePageSizeUnit = $sizes[$factor] ?? ''; $this->TextSinglePageUrl = $this->Url . '/text/single-page'; } - catch(Exception $ex){ + catch(Exception){ // Single page file doesn't exist, just pass } diff --git a/lib/HttpInput.php b/lib/HttpInput.php index 4a043504..60f3b48d 100644 --- a/lib/HttpInput.php +++ b/lib/HttpInput.php @@ -100,7 +100,7 @@ class HttpInput{ try{ return intval($var); } - catch(\Exception $ex){ + catch(Exception){ return $default; } } @@ -117,7 +117,7 @@ class HttpInput{ try{ return floatval($var); } - catch(\Exception $ex){ + catch(Exception){ return $default; } } diff --git a/lib/Library.php b/lib/Library.php index 60b1587a..0a9528da 100644 --- a/lib/Library.php +++ b/lib/Library.php @@ -132,7 +132,7 @@ class Library{ try{ return apcu_fetch('tag-' . $tag) ?? []; } - catch(Safe\Exceptions\ApcuException $ex){ + catch(Safe\Exceptions\ApcuException){ return []; } } @@ -168,12 +168,12 @@ class Library{ try{ $results = apcu_fetch($variable); } - catch(Safe\Exceptions\ApcuException $ex){ + catch(Safe\Exceptions\ApcuException){ Library::RebuildCache(); try{ $results = apcu_fetch($variable); } - catch(Safe\Exceptions\ApcuException $ex){ + catch(Safe\Exceptions\ApcuException){ // We can get here if the cache is currently rebuilding from a different process. // Nothing we can do but wait, so wait 20 seconds before retrying sleep(20); @@ -181,7 +181,7 @@ class Library{ try{ $results = apcu_fetch($variable); } - catch(Safe\Exceptions\ApcuException $ex){ + catch(Safe\Exceptions\ApcuException){ // Cache STILL rebuilding... give up silently for now } } @@ -224,7 +224,7 @@ class Library{ $ebooks[] = new Ebook($ebookWwwFilesystemPath); } - catch(\Exception $ex){ + catch(\Exception){ // An error in a book isn't fatal; just carry on. } } @@ -443,7 +443,7 @@ class Library{ $val = apcu_fetch($lockVar); return; } - catch(Safe\Exceptions\ApcuException $ex){ + catch(Safe\Exceptions\ApcuException){ apcu_store($lockVar, true); } @@ -508,7 +508,7 @@ class Library{ $authors[$authorPath][] = $ebook; } - catch(\Exception $ex){ + catch(\Exception){ // An error in a book isn't fatal; just carry on. } } diff --git a/lib/Log.php b/lib/Log.php index f268aed9..4fc68c1a 100644 --- a/lib/Log.php +++ b/lib/Log.php @@ -29,7 +29,7 @@ class Log{ try{ $fp = fopen($this->LogFilePath, 'a+'); } - catch(\Exception $ex){ + catch(Exception $ex){ self::WriteErrorLogEntry('Couldn\'t open log file: ' . $this->LogFilePath . '. Exception: ' . vds($ex)); return; } diff --git a/lib/Manual.php b/lib/Manual.php index 439bed0b..4ec7a694 100644 --- a/lib/Manual.php +++ b/lib/Manual.php @@ -19,7 +19,7 @@ class Manual{ return null; } } - catch(\Exception $ex){ + catch(Exception){ return null; } } diff --git a/lib/NewsletterSubscription.php b/lib/NewsletterSubscription.php index 34d0ae79..f1ea4810 100644 --- a/lib/NewsletterSubscription.php +++ b/lib/NewsletterSubscription.php @@ -38,7 +38,7 @@ class NewsletterSubscription extends PropertiesBase{ try{ $this->User = User::GetByEmail($this->User->Email); } - catch(Exceptions\InvalidUserException $ex){ + catch(Exceptions\InvalidUserException){ // User doesn't exist, create the user $this->User->Create(); } diff --git a/lib/OpdsNavigationFeed.php b/lib/OpdsNavigationFeed.php index bdb7cca6..f427c577 100644 --- a/lib/OpdsNavigationFeed.php +++ b/lib/OpdsNavigationFeed.php @@ -31,7 +31,7 @@ class OpdsNavigationFeed extends OpdsFeed{ } } } - catch(Exception $ex){ + catch(Exception){ // XML parsing failure } } diff --git a/lib/Payment.php b/lib/Payment.php index 00309d38..500d5f5a 100644 --- a/lib/Payment.php +++ b/lib/Payment.php @@ -40,7 +40,7 @@ class Payment extends PropertiesBase{ where UserId = ? ', [$this->User->Name, $this->User->UserId]); } - catch(Exceptions\InvalidUserException $ex){ + catch(Exceptions\InvalidUserException){ // User doesn't exist, create it now $this->User->Create(); } diff --git a/lib/PollVote.php b/lib/PollVote.php index b050a37c..3105f7a2 100644 --- a/lib/PollVote.php +++ b/lib/PollVote.php @@ -61,7 +61,7 @@ class PollVote extends PropertiesBase{ $vote = PollVote::Get($this->PollItem->Poll->UrlName, $this->UserId); $error->Add(new Exceptions\PollVoteExistsException($vote)); } - catch(Exceptions\InvalidPollVoteException $ex){ + catch(Exceptions\InvalidPollVoteException){ // User hasn't voted yet, carry on } @@ -81,7 +81,7 @@ class PollVote extends PropertiesBase{ $this->User = User::GetByEmail($email); $this->UserId = $this->User->UserId; } - catch(Exceptions\InvalidUserException $ex){ + catch(Exceptions\InvalidUserException){ // Can't validate patron email - do nothing for now, // this will be caught later when we validate the vote during creation. // Save the email in the User object in case we want it later, diff --git a/lib/RssFeed.php b/lib/RssFeed.php index ad5a7e75..9fba0acd 100644 --- a/lib/RssFeed.php +++ b/lib/RssFeed.php @@ -78,7 +78,7 @@ class RssFeed extends Feed{ $oldEntries[] = $obj; } } - catch(Exception $ex){ + catch(Exception){ // Invalid XML return true; } diff --git a/scripts/process-pending-payments b/scripts/process-pending-payments index 87c57869..f3d8a098 100755 --- a/scripts/process-pending-payments +++ b/scripts/process-pending-payments @@ -105,7 +105,7 @@ try{ try{ $toggleButton = $driver->wait(20, 250)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::xpath('//button[contains(@class, "button-toggle")]'))); } - catch(Exception $ex){ + catch(Exception){ $log->Write('Error: Couldn\'t find donation.'); continue; } @@ -147,7 +147,7 @@ try{ $payment->User = null; } } - catch(Exception $ex){ + catch(Exception){ // Anonymous donations don't have these elements present and will throw an exception $payment->User = null; } @@ -172,7 +172,7 @@ try{ try{ $payment->Create(); } - catch(Exceptions\PaymentExistsException $ex){ + catch(Exceptions\PaymentExistsException){ // Payment already exists, just continue $log->Write('Donation already in database.'); continue; @@ -217,7 +217,7 @@ try{ try{ $patron->AlternateName = trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Attribution Text"]]'))->getText()); } - catch(Exception $ex){ + catch(Exception){ } $log->Write('Adding donor as patron ...'); diff --git a/www/bulk-downloads/collection.php b/www/bulk-downloads/collection.php index 8a79e3a7..605efbf0 100644 --- a/www/bulk-downloads/collection.php +++ b/www/bulk-downloads/collection.php @@ -20,7 +20,7 @@ $collection = []; try{ $collection = apcu_fetch('bulk-downloads-' . $class); } -catch(Safe\Exceptions\ApcuException $ex){ +catch(Safe\Exceptions\ApcuException){ $result = Library::RebuildBulkDownloadsCache(); $collection = $result[$class]; } diff --git a/www/bulk-downloads/download.php b/www/bulk-downloads/download.php index 59c88204..a7fb3395 100644 --- a/www/bulk-downloads/download.php +++ b/www/bulk-downloads/download.php @@ -32,7 +32,7 @@ try{ header('Content-Disposition: attachment; filename="' . basename($path) . '"'); exit(); } -catch(Exceptions\LoginRequiredException $ex){ +catch(Exceptions\LoginRequiredException){ if(isset($_SERVER['HTTP_REFERER'])){ Template::RedirectToLogin(true, $_SERVER['HTTP_REFERER']); } @@ -48,10 +48,10 @@ catch(Exceptions\LoginRequiredException $ex){ } } } -catch(Exceptions\InvalidPermissionsException $ex){ +catch(Exceptions\InvalidPermissionsException){ http_response_code(403); } -catch(Exceptions\InvalidFileException $ex){ +catch(Exceptions\InvalidFileException){ Template::Emit404(); } diff --git a/www/bulk-downloads/get.php b/www/bulk-downloads/get.php index 69351734..45c0b371 100644 --- a/www/bulk-downloads/get.php +++ b/www/bulk-downloads/get.php @@ -21,7 +21,7 @@ try{ try{ $collections = apcu_fetch('bulk-downloads-collections'); } - catch(Safe\Exceptions\ApcuException $ex){ + catch(Safe\Exceptions\ApcuException){ $result = Library::RebuildBulkDownloadsCache(); $collections = $result['collections']; } @@ -45,7 +45,7 @@ try{ try{ $collections = apcu_fetch('bulk-downloads-authors'); } - catch(Safe\Exceptions\ApcuException $ex){ + catch(Safe\Exceptions\ApcuException){ $result = Library::RebuildBulkDownloadsCache(); $collections = $result['authors']; } @@ -62,13 +62,10 @@ try{ } } } -catch(Exceptions\InvalidUserException $ex){ - $exception = new Exceptions\InvalidPatronException(); -} -catch(Exceptions\InvalidAuthorException $ex){ +catch(Exceptions\InvalidAuthorException){ Template::Emit404(); } -catch(Exceptions\InvalidCollectionException $ex){ +catch(Exceptions\InvalidCollectionException){ Template::Emit404(); } diff --git a/www/ebooks/author.php b/www/ebooks/author.php index 7c3966f0..2e9db621 100644 --- a/www/ebooks/author.php +++ b/www/ebooks/author.php @@ -23,7 +23,7 @@ try{ $author = strip_tags($ebooks[0]->AuthorsHtml); $authorUrl = Formatter::ToPlainText($ebooks[0]->AuthorsUrl); } -catch(Exceptions\InvalidAuthorException $ex){ +catch(Exceptions\InvalidAuthorException){ Template::Emit404(); } ?> 'Ebooks by ' . $author, 'feedUrl' => str_replace('/ebooks/', '/authors/', $authorUrl), 'feedTitle' => 'Standard Ebooks - Ebooks by ' . $author, 'highlight' => 'ebooks', 'description' => 'All of the Standard Ebooks ebooks by ' . $author]) ?> diff --git a/www/ebooks/ebook.php b/www/ebooks/ebook.php index 94b49747..4eec0f54 100644 --- a/www/ebooks/ebook.php +++ b/www/ebooks/ebook.php @@ -43,7 +43,7 @@ try{ try{ $ebook = apcu_fetch('ebook-' . $wwwFilesystemPath); } - catch(Safe\Exceptions\ApcuException $ex){ + catch(Safe\Exceptions\ApcuException){ $ebook = new Ebook($wwwFilesystemPath); } @@ -106,7 +106,7 @@ catch(Exceptions\SeeOtherEbookException $ex){ header('Location: ' . $ex->Url); exit(); } -catch(Exceptions\InvalidEbookException $ex){ +catch(Exceptions\InvalidEbookException){ Template::Emit404(); } ?> strip_tags($ebook->TitleWithCreditsHtml) . ' - Free ebook download', 'ogType' => 'book', 'coverUrl' => $ebook->DistCoverUrl, 'highlight' => 'ebooks', 'description' => 'Free epub ebook download of the Standard Ebooks edition of ' . $ebook->Title . ': ' . $ebook->Description]) ?> diff --git a/www/ebooks/index.php b/www/ebooks/index.php index cc398f4f..ddb8b5e4 100644 --- a/www/ebooks/index.php +++ b/www/ebooks/index.php @@ -120,7 +120,7 @@ try{ $feedTitle = 'Standard Ebooks - Ebooks in the ' . Formatter::ToPlainText($collectionName) . ' ' . $collectionType; } } -catch(Exceptions\InvalidCollectionException $ex){ +catch(Exceptions\InvalidCollectionException){ Template::Emit404(); } ?> $pageTitle, 'feedUrl' => $feedUrl, 'feedTitle' => $feedTitle, 'highlight' => 'ebooks', 'description' => $pageDescription]) ?> diff --git a/www/feeds/atom/search.php b/www/feeds/atom/search.php index 4140b162..fc2214cb 100644 --- a/www/feeds/atom/search.php +++ b/www/feeds/atom/search.php @@ -11,7 +11,7 @@ try{ $ebooks = Library::Search($query); } } -catch(\Exception $ex){ +catch(\Exception){ http_response_code(500); include(WEB_ROOT . '/404.php'); exit(); diff --git a/www/feeds/collection.php b/www/feeds/collection.php index 9494a82f..f470bea5 100644 --- a/www/feeds/collection.php +++ b/www/feeds/collection.php @@ -29,7 +29,7 @@ if($type === 'atom'){ try{ $feeds = apcu_fetch('feeds-index-' . $type . '-' . $class); } -catch(Safe\Exceptions\ApcuException $ex){ +catch(Safe\Exceptions\ApcuException){ $feeds = Library::RebuildFeedsCache($type, $class); } ?> $ucType . ' Ebook Feeds by ' . $ucTitle, 'description' => 'A list of available ' . $ucType . ' feeds of Standard Ebooks ebooks by ' . $lcTitle . '.']) ?> diff --git a/www/feeds/download.php b/www/feeds/download.php index 7b247849..05f05487 100644 --- a/www/feeds/download.php +++ b/www/feeds/download.php @@ -70,14 +70,14 @@ try{ exit(); } -catch(Exceptions\LoginRequiredException $ex){ +catch(Exceptions\LoginRequiredException){ header('WWW-Authenticate: Basic realm="Enter your Patrons Circle email address and leave the password empty."'); http_response_code(401); } -catch(Exceptions\InvalidPermissionsException $ex){ +catch(Exceptions\InvalidPermissionsException){ http_response_code(403); } -catch(Exceptions\InvalidFileException $ex){ +catch(Exceptions\InvalidFileException){ Template::Emit404(); } diff --git a/www/feeds/get.php b/www/feeds/get.php index 4c9304f8..5d2038b0 100644 --- a/www/feeds/get.php +++ b/www/feeds/get.php @@ -48,7 +48,7 @@ try{ $feedUrl = '/' . $name . '/' . $target; } -catch(Exceptions\InvalidCollectionException $ex){ +catch(Exceptions\InvalidCollectionException){ Template::Emit404(); } ?> $title, 'feedTitle' => $feedTitle, 'feedUrl' => $feedUrl, 'description' => $description]) ?> diff --git a/www/feeds/opds/search.php b/www/feeds/opds/search.php index ad9467e8..63977697 100644 --- a/www/feeds/opds/search.php +++ b/www/feeds/opds/search.php @@ -11,7 +11,7 @@ try{ $ebooks = Library::Search($query); } } -catch(\Exception $ex){ +catch(\Exception){ http_response_code(500); exit(); } diff --git a/www/feeds/rss/search.php b/www/feeds/rss/search.php index 0650af4d..b23cfb9c 100644 --- a/www/feeds/rss/search.php +++ b/www/feeds/rss/search.php @@ -11,7 +11,7 @@ try{ $ebooks = Library::Search($query); } } -catch(\Exception $ex){ +catch(\Exception){ http_response_code(500); include(WEB_ROOT . '/404.php'); exit(); diff --git a/www/newsletter/subscriptions/confirm.php b/www/newsletter/subscriptions/confirm.php index 6aea7988..7edb7ca5 100644 --- a/www/newsletter/subscriptions/confirm.php +++ b/www/newsletter/subscriptions/confirm.php @@ -16,6 +16,6 @@ try{ http_response_code(303); header('Location: ' . $subscription->Url); } -catch(Exceptions\InvalidNewsletterSubscriptionException $ex){ +catch(Exceptions\InvalidNewsletterSubscriptionException){ Template::Emit404(); } diff --git a/www/newsletter/subscriptions/delete.php b/www/newsletter/subscriptions/delete.php index 2d3041bb..830f3afe 100644 --- a/www/newsletter/subscriptions/delete.php +++ b/www/newsletter/subscriptions/delete.php @@ -18,11 +18,11 @@ try{ exit(); } } -catch(Exceptions\InvalidRequestException $ex){ +catch(Exceptions\InvalidRequestException){ http_response_code(405); exit(); } -catch(Exceptions\InvalidNewsletterSubscriptionException $ex){ +catch(Exceptions\InvalidNewsletterSubscriptionException){ if($requestType == WEB){ Template::Emit404(); } diff --git a/www/newsletter/subscriptions/get.php b/www/newsletter/subscriptions/get.php index ae617110..da78295a 100644 --- a/www/newsletter/subscriptions/get.php +++ b/www/newsletter/subscriptions/get.php @@ -39,7 +39,7 @@ try{ http_response_code(201); } } -catch(Exceptions\SeException $ex){ +catch(Exceptions\SeException){ Template::Emit404(); } diff --git a/www/newsletter/subscriptions/post.php b/www/newsletter/subscriptions/post.php index e4f326bb..51b5a947 100644 --- a/www/newsletter/subscriptions/post.php +++ b/www/newsletter/subscriptions/post.php @@ -74,7 +74,7 @@ try{ header('Location: /newsletter/subscriptions/success'); } } -catch(Exceptions\NewsletterSubscriptionExistsException $ex){ +catch(Exceptions\NewsletterSubscriptionExistsException){ // Subscription exists. if($requestType == WEB){ // If we're accessing from the web, update the subscription, diff --git a/www/polls/get.php b/www/polls/get.php index 151554f5..c153c375 100644 --- a/www/polls/get.php +++ b/www/polls/get.php @@ -20,13 +20,13 @@ try{ try{ PollVote::Get($poll->UrlName, $GLOBALS['User']->UserId); } - catch(Exceptions\SeException $ex){ + catch(Exceptions\SeException){ // User has already voted $canVote = true; } } } -catch(Exceptions\SeException $ex){ +catch(Exceptions\SeException){ Template::Emit404(); } diff --git a/www/polls/votes/get.php b/www/polls/votes/get.php index a70b1cea..20d52c58 100644 --- a/www/polls/votes/get.php +++ b/www/polls/votes/get.php @@ -17,7 +17,7 @@ try{ session_unset(); } } -catch(Exceptions\SeException $ex){ +catch(Exceptions\SeException){ Template::Emit404(); } diff --git a/www/polls/votes/index.php b/www/polls/votes/index.php index c79d9888..284fad64 100644 --- a/www/polls/votes/index.php +++ b/www/polls/votes/index.php @@ -6,7 +6,7 @@ $poll = new Poll(); try{ $poll = Poll::GetByUrlName(HttpInput::Str(GET, 'pollurlname', false)); } -catch(Exceptions\SeException $ex){ +catch(Exceptions\SeException){ Template::Emit404(); } diff --git a/www/polls/votes/new.php b/www/polls/votes/new.php index 4bebcfe1..33129c0f 100644 --- a/www/polls/votes/new.php +++ b/www/polls/votes/new.php @@ -29,7 +29,7 @@ try{ // Vote was found, don't allow another vote throw new Exceptions\PollVoteExistsException($vote); } - catch(Exceptions\InvalidPollVoteException $ex){ + catch(Exceptions\InvalidPollVoteException){ // Vote was not found, user is OK to vote } @@ -38,10 +38,10 @@ try{ session_unset(); } } -catch(Exceptions\LoginRequiredException $ex){ +catch(Exceptions\LoginRequiredException){ Template::RedirectToLogin(); } -catch(Exceptions\InvalidPollException $ex){ +catch(Exceptions\InvalidPollException){ Template::Emit404(); } catch(Exceptions\PollVoteExistsException $ex){ diff --git a/www/webhooks/github.php b/www/webhooks/github.php index 4c7b0d56..d7ec1515 100644 --- a/www/webhooks/github.php +++ b/www/webhooks/github.php @@ -133,7 +133,7 @@ try{ // "Success, no content" http_response_code(204); } -catch(Exceptions\InvalidCredentialsException $ex){ +catch(Exceptions\InvalidCredentialsException){ // "Forbidden" http_response_code(403); } @@ -149,7 +149,7 @@ catch(Exceptions\WebhookException $ex){ // "Client error" http_response_code(400); } -catch(Exceptions\NoopException $ex){ +catch(Exceptions\NoopException){ // We arrive here because a special case required us to take no action for the request, but execution also had to be interrupted. // For example, we received a request for a known repo for which we must ignore requests. diff --git a/www/webhooks/postmark.php b/www/webhooks/postmark.php index a1fa430c..c1c978e4 100644 --- a/www/webhooks/postmark.php +++ b/www/webhooks/postmark.php @@ -79,7 +79,7 @@ try{ // "Success, no content" http_response_code(204); } -catch(Exceptions\InvalidCredentialsException $ex){ +catch(Exceptions\InvalidCredentialsException){ // "Forbidden" $log->Write('Invalid key: ' . ($_SERVER['HTTP_X_SE_KEY'] ?? '')); http_response_code(403); diff --git a/www/webhooks/zoho.php b/www/webhooks/zoho.php index d2f9d101..99e6ebc8 100644 --- a/www/webhooks/zoho.php +++ b/www/webhooks/zoho.php @@ -56,7 +56,7 @@ try{ // "Success, no content" http_response_code(204); } -catch(Exceptions\InvalidCredentialsException $ex){ +catch(Exceptions\InvalidCredentialsException){ // "Forbidden" $log->Write('Couldn\'t validate POST data.'); http_response_code(403);