Skip to content

Commit b23cfb5

Browse files
Fix for watchdog_exception() deprecation (#954)
1 parent 5be41b8 commit b23cfb5

File tree

10 files changed

+43
-45
lines changed

10 files changed

+43
-45
lines changed

apigee_edge.module

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,9 @@ function apigee_edge_form_user_form_api_connection_validate(array $form, FormSta
869869
'@user_email' => $form_state->getValue('mail'),
870870
'@message' => (string) $exception,
871871
];
872-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
873-
// @phpstan-ignore-next-line
874-
watchdog_exception('apigee_edge', $exception, 'Could not create/update Drupal user: @user_email, because there was no connection to Apigee Edge. @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
872+
873+
$logger = \Drupal::logger('apigee_edge');
874+
Error::logException($logger, $exception, 'Could not create/update Drupal user: @user_email, because there was no connection to Apigee Edge. @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
875875
$form_state->setError($form, t('User registration is temporarily unavailable. Try again later or contact the site administrator.'));
876876
}
877877
}
@@ -950,9 +950,8 @@ function apigee_edge_form_user_register_form_developer_email_validate(array $for
950950
$sendNotifications->set($account->getEmail(), $result);
951951
}
952952
catch (TempStoreException $e) {
953-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
954-
// @phpstan-ignore-next-line
955-
watchdog_exception(__FUNCTION__, $e);
953+
$logger = \Drupal::logger(__FUNCTION__);
954+
Error::logException($logger, $e);
956955
}
957956
}
958957
}

src/Form/AppAnalyticsFormBase.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Drupal\Core\Routing\UrlGeneratorInterface;
3333
use Drupal\Core\TempStore\PrivateTempStoreFactory;
3434
use Drupal\Core\Url;
35+
use Drupal\Core\Utility\Error;
3536
use League\Period\Period;
3637
use Moment\MomentException;
3738
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -379,9 +380,9 @@ protected function generateResponse(array &$form, AppInterface $app, string $met
379380
catch (\Exception $e) {
380381
$this->messenger()
381382
->addError($this->t('Unable to retrieve analytics data. Please try again.'));
382-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
383-
// @phpstan-ignore-next-line
384-
watchdog_exception('apigee_edge', $e);
383+
384+
$logger = \Drupal::logger('apigee_edge');
385+
Error::logException($logger, $e);
385386
}
386387

387388
$date_time_zone = new \DateTimeZone(date_default_timezone_get());

src/JobExecutor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Drupal\Component\Datetime\TimeInterface;
2424
use Drupal\Core\Database\Connection;
2525
use Drupal\Core\Queue\QueueFactory;
26+
use Drupal\Core\Utility\Error;
2627

2728
/**
2829
* Job executor service.
@@ -151,9 +152,8 @@ public function call(Job $job, bool $update = TRUE) {
151152
$job->setStatus($result ? Job::IDLE : Job::FINISHED);
152153
}
153154
catch (\Exception $ex) {
154-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
155-
// @phpstan-ignore-next-line
156-
watchdog_exception('apigee_edge_job', $ex);
155+
$logger = \Drupal::logger('apigee_edge_job');
156+
Error::logException($logger, $ex);
157157
$job->recordException($ex);
158158
$job->setStatus($job->shouldRetry($ex) && $job->consumeRetry() ? Job::RESCHEDULED : Job::FAILED);
159159
}

src/KeyEntityFormEnhancer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use Drupal\Core\Messenger\MessengerTrait;
4141
use Drupal\Core\Render\Element\StatusMessages;
4242
use Drupal\Core\StringTranslation\StringTranslationTrait;
43+
use Drupal\Core\Utility\Error;
4344
use Drupal\key\Form\KeyFormBase;
4445
use Drupal\key\KeyInterface;
4546
use Drupal\key\Plugin\KeyProviderSettableValueInterface;
@@ -349,9 +350,8 @@ public function validateForm(array &$form, FormStateInterface $form_state): void
349350
drupal_flush_all_caches();
350351
}
351352
catch (\Exception $exception) {
352-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
353-
// @phpstan-ignore-next-line
354-
watchdog_exception('apigee_edge', $exception);
353+
$logger = \Drupal::logger('apigee_edge');
354+
Error::logException($logger, $exception);
355355

356356
$form_state->setError($form, $this->t('@suggestion Error message: %response', [
357357
'@suggestion' => $this->createSuggestion($exception, $test_key),

src/Plugin/Field/FieldType/ApigeeEdgeDeveloperIdFieldItem.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Drupal\apigee_edge\Entity\Developer;
2424
use Drupal\Core\Field\FieldItemList;
2525
use Drupal\Core\TypedData\ComputedItemListTrait;
26+
use Drupal\Core\Utility\Error;
2627

2728
/**
2829
* Definition of Apigee Edge Developer ID computed field for User entity.
@@ -52,9 +53,8 @@ protected function computeValue() {
5253
$this->list[0] = $this->createItem(0, $value);
5354
}
5455
catch (\Exception $exception) {
55-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
56-
// @phpstan-ignore-next-line
57-
watchdog_exception('apigee_edge', $exception);
56+
$logger = \Drupal::logger('apigee_edge');
57+
Error::logException($logger, $exception);
5858
}
5959
}
6060

tests/modules/apigee_edge_test_app_keys/apigee_edge_test_app_keys.module

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Apigee\Edge\Exception\ApiException;
99
use Drupal\Component\Utility\Random;
1010
use Drupal\Core\Entity\EntityInterface;
11+
use Drupal\Core\Utility\Error;
1112

1213
/**
1314
* Implements hook_entity_insert().
@@ -36,15 +37,13 @@ function apigee_edge_test_app_keys_developer_app_insert(EntityInterface $entity)
3637
$dacc->create("{$prefix}-{$random->name()}", "{$prefix}-{$random->name()}");
3738
}
3839
catch (ApiException $e) {
39-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
40-
// @phpstan-ignore-next-line
41-
watchdog_exception('apigee_edge', $e, 'Unable to create new API key on Apigee Edge for @app app. !message', ['@app' => $entity->id()]);
40+
$logger = \Drupal::logger('apigee_edge');
41+
Error::logException($logger, $e, 'Unable to create new API key on Apigee Edge for @app app. !message', ['@app' => $entity->id()]);
4242
}
4343
}
4444
catch (ApiException $e) {
45-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
46-
// @phpstan-ignore-next-line
47-
watchdog_exception('apigee_edge', $e, 'Unable to delete auto-generated key of @app app on Apigee Edge. !message', ['@app' => $entity->id()]);
45+
$logger = \Drupal::logger('apigee_edge');
46+
Error::logException($logger, $e, 'Unable to delete auto-generated key of @app app on Apigee Edge. !message', ['@app' => $entity->id()]);
4847
}
4948
}
5049
}

tests/modules/apigee_edge_test_app_keys/src/EventSubscriber/OverrideAppKeysOnGenerate.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Drupal\apigee_edge\Entity\Controller\DeveloperAppCredentialControllerFactoryInterface;
2626
use Drupal\apigee_edge\Event\AppCredentialGenerateEvent;
2727
use Drupal\Component\Utility\Random;
28+
use Drupal\Core\Utility\Error;
2829
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
2930

3031
/**
@@ -89,29 +90,25 @@ public function overrideAppKeyOnGenerate(AppCredentialGenerateEvent $event) {
8990
$credential_controller->addProducts($new_consumer_key, $products);
9091
}
9192
catch (ApiException $e) {
92-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
93-
// @phpstan-ignore-next-line
94-
watchdog_exception('apigee_edge', $e, 'Unable to assign API products to the newly generated API key on Apigee Edge for @app app. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
93+
$logger = \Drupal::logger('apigee_edge');
94+
Error::logException($logger, $e, 'Unable to assign API products to the newly generated API key on Apigee Edge for @app app. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
9595
try {
9696
$credential_controller->delete($new_consumer_key);
9797
}
9898
catch (ApiException $e) {
99-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
100-
// @phpstan-ignore-next-line
101-
watchdog_exception('apigee_edge', $e, 'Unable to delete newly generated API key after API product re-association has failed on Apigee Edge for @app app. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
99+
$logger = \Drupal::logger('apigee_edge');
100+
Error::logException($logger, $e, 'Unable to delete newly generated API key after API product re-association has failed on Apigee Edge for @app app. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
102101
}
103102
}
104103
}
105104
catch (ApiException $e) {
106-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
107-
// @phpstan-ignore-next-line
108-
watchdog_exception('apigee_edge', $e, 'Unable to create new API key on Apigee Edge for @app app. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
105+
$logger = \Drupal::logger('apigee_edge');
106+
Error::logException($logger, $e, 'Unable to create new API key on Apigee Edge for @app app. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
109107
}
110108
}
111109
catch (ApiException $e) {
112-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
113-
// @phpstan-ignore-next-line
114-
watchdog_exception('apigee_edge', $e, 'Unable to delete auto-generated key of @app app on Apigee Edge. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
110+
$logger = \Drupal::logger('apigee_edge');
111+
Error::logException($logger, $e, 'Unable to delete auto-generated key of @app app on Apigee Edge. !message', ['@app' => "{$event->getOwnerId()}:{$event->getAppName()}"]);
115112
}
116113
}
117114

tests/src/Kernel/ApigeeEdgeKernelTestTrait.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace Drupal\Tests\apigee_edge\Kernel;
2222

23+
use Drupal\Core\Utility\Error;
24+
2325
/**
2426
* Provides common functionality for the Apigee Edge kernel test classes.
2527
*/
@@ -35,9 +37,9 @@ trait ApigeeEdgeKernelTestTrait {
3537
*/
3638
protected function logException(\Exception $exception, string $suffix = '') {
3739
$ro = new \ReflectionObject($this);
38-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
39-
// @phpstan-ignore-next-line
40-
watchdog_exception("{$ro->getShortName()}{$suffix}", $exception);
40+
41+
$logger = \Drupal::logger("{$ro->getShortName()}{$suffix}");
42+
Error::logException($logger, $exception);
4143
}
4244

4345
}

tests/src/Kernel/Util/ApigeeEdgeManagementCliServiceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Apigee\Edge\Exception\ClientErrorException;
2323
use Drupal\Core\DependencyInjection\ContainerBuilder;
2424
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
25+
use Drupal\Core\Utility\Error;
2526
use Drupal\KernelTests\KernelTestBase;
2627
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;
2728

@@ -145,9 +146,8 @@ protected function tearDown(): void {
145146
}
146147
}
147148
catch (\Exception $exception) {
148-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
149-
// @phpstan-ignore-next-line
150-
watchdog_exception('apigee_edge', $exception);
149+
$logger = \Drupal::logger('apigee_edge');
150+
Error::logException($logger, $exception);
151151
}
152152

153153
parent::tearDown();

tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Drupal\apigee_edge\Entity\ApiProduct;
2424
use Drupal\apigee_edge\Entity\Developer;
2525
use Drupal\apigee_edge\Entity\DeveloperApp;
26+
use Drupal\Core\Utility\Error;
2627
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;
2728
use Drupal\user\Entity\User;
2829
use Drupal\user\UserInterface;
@@ -299,9 +300,8 @@ protected static function fixUrl(string $url): string {
299300
*/
300301
protected function logException(\Exception $exception, string $suffix = '') {
301302
$ro = new \ReflectionObject($this);
302-
// @todo watchdog_exception() function has been deprecated for Drupal 10.1 https://www.drupal.org/node/2932520
303-
// @phpstan-ignore-next-line
304-
watchdog_exception("{$ro->getShortName()}{$suffix}", $exception);
303+
$logger = \Drupal::logger("{$ro->getShortName()}{$suffix}");
304+
Error::logException($logger, $exception);
305305
}
306306

307307
/**

0 commit comments

Comments
 (0)