Unverified Commit d3c9b8ed authored by JeroenT's avatar JeroenT Committed by wundo

Issue #3042586 by yogen.prasad, ChaseOnTheWeb, JeroenT, thalles, arpitr:...

Issue #3042586 by yogen.prasad, ChaseOnTheWeb, JeroenT, thalles, arpitr: Drupal 9 Deprecated Code Report
parent e9353227
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
*/ */
use Drupal\captcha\Entity\CaptchaPoint; use Drupal\captcha\Entity\CaptchaPoint;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link; use Drupal\Core\Link;
...@@ -253,12 +252,10 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_ ...@@ -253,12 +252,10 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_
$captcha_element['challenge'] = [ $captcha_element['challenge'] = [
'#type' => 'item', '#type' => 'item',
'#title' => t('Enabled challenge'), '#title' => t('Enabled challenge'),
'#markup' => t('<a href="@change">change</a>', [ '#markup' => $captcha_point->toLink(t('change'), 'edit-form', [
'@change' => $captcha_point->url('edit-form', [ 'query' => \Drupal::destination()
'query' => Drupal::destination() ->getAsArray(),
->getAsArray(), ])->toString(),
]),
]),
]; ];
} }
else { else {
...@@ -267,7 +264,7 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_ ...@@ -267,7 +264,7 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_
'#markup' => Link::fromTextAndUrl( '#markup' => Link::fromTextAndUrl(
t('Place a CAPTCHA here for untrusted users.'), t('Place a CAPTCHA here for untrusted users.'),
Url::fromRoute('captcha_point.add', [], [ Url::fromRoute('captcha_point.add', [], [
'query' => Drupal::destination() 'query' => \Drupal::destination()
->getAsArray() + ['form_id' => $form_id], ->getAsArray() + ['form_id' => $form_id],
]) ])
)->toString(), )->toString(),
...@@ -317,7 +314,7 @@ function captcha_validate_strict_equality($solution, $response) { ...@@ -317,7 +314,7 @@ function captcha_validate_strict_equality($solution, $response) {
* TRUE when case insensitive equal, FALSE otherwise. * TRUE when case insensitive equal, FALSE otherwise.
*/ */
function captcha_validate_case_insensitive_equality($solution, $response) { function captcha_validate_case_insensitive_equality($solution, $response) {
return Unicode::strtolower($solution) === Unicode::strtolower($response); return mb_strtolower($solution) === mb_strtolower($response);
} }
/** /**
...@@ -347,7 +344,7 @@ function captcha_validate_ignore_spaces($solution, $response) { ...@@ -347,7 +344,7 @@ function captcha_validate_ignore_spaces($solution, $response) {
* TRUE when equal (ignoring spaces), FALSE otherwise. * TRUE when equal (ignoring spaces), FALSE otherwise.
*/ */
function captcha_validate_case_insensitive_ignore_spaces($solution, $response) { function captcha_validate_case_insensitive_ignore_spaces($solution, $response) {
return preg_replace('/\s/', '', Unicode::strtolower($solution)) === preg_replace('/\s/', '', Unicode::strtolower($response)); return preg_replace('/\s/', '', mb_strtolower($solution)) === preg_replace('/\s/', '', mb_strtolower($response));
} }
/** /**
......
...@@ -9,6 +9,7 @@ namespace Drupal\image_captcha\Controller; ...@@ -9,6 +9,7 @@ namespace Drupal\image_captcha\Controller;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\Url;
/** /**
* Description of CaptchaImageRefresh. * Description of CaptchaImageRefresh.
...@@ -43,7 +44,7 @@ class CaptchaImageRefresh extends ControllerBase { ...@@ -43,7 +44,7 @@ class CaptchaImageRefresh extends ControllerBase {
->condition('csid', $captcha_sid, '=') ->condition('csid', $captcha_sid, '=')
->execute(); ->execute();
$result['data'] = [ $result['data'] = [
'url' => \Drupal::url('image_captcha.generator', ['session_id' => $captcha_sid, 'timestamp' => \Drupal::time()->getRequestTime()]), 'url' => Url::fromRoute('image_captcha.generator', ['session_id' => $captcha_sid, 'timestamp' => \Drupal::time()->getRequestTime()])->toString(),
'token' => $captcha_token, 'token' => $captcha_token,
'sid' => $captcha_sid, 'sid' => $captcha_sid,
]; ];
......
...@@ -72,10 +72,10 @@ class ImageCaptchaSettingsForm extends ConfigFormBase { ...@@ -72,10 +72,10 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
// First some error checking. // First some error checking.
$setup_status = _image_captcha_check_setup(FALSE); $setup_status = _image_captcha_check_setup(FALSE);
if ($setup_status & IMAGE_CAPTCHA_ERROR_NO_GDLIB) { if ($setup_status & IMAGE_CAPTCHA_ERROR_NO_GDLIB) {
drupal_set_message($this->t( $this->messenger()->addError($this->t(
'The Image CAPTCHA module can not generate images because your PHP setup does not support it (no <a href="!gdlib" target="_blank">GD library</a> with JPEG support).', 'The Image CAPTCHA module can not generate images because your PHP setup does not support it (no <a href="!gdlib" target="_blank">GD library</a> with JPEG support).',
['!gdlib' => 'http://php.net/manual/en/book.image.php'] ['!gdlib' => 'http://php.net/manual/en/book.image.php']
), 'error'); ));
// It is no use to continue building the rest of the settings form. // It is no use to continue building the rest of the settings form.
return $form; return $form;
} }
......
...@@ -41,7 +41,7 @@ class LongIdForm extends FormBase { ...@@ -41,7 +41,7 @@ class LongIdForm extends FormBase {
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
// Display result. // Display result.
foreach ($form_state->getValues() as $key => $value) { foreach ($form_state->getValues() as $key => $value) {
drupal_set_message($key . ': ' . $value); $this->messenger()->addMessage($key . ': ' . $value);
} }
} }
......
...@@ -37,7 +37,7 @@ class CaptchaPointDeleteForm extends EntityConfirmFormBase { ...@@ -37,7 +37,7 @@ class CaptchaPointDeleteForm extends EntityConfirmFormBase {
*/ */
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete(); $this->entity->delete();
drupal_set_message($this->t('Captcha point %label has been deleted.', ['%label' => $this->entity->label()])); $this->messenger()->addMessage($this->t('Captcha point %label has been deleted.', ['%label' => $this->entity->label()]));
$form_state->setRedirectUrl($this->getCancelUrl()); $form_state->setRedirectUrl($this->getCancelUrl());
} }
......
...@@ -45,7 +45,7 @@ class CaptchaPointDisableForm extends EntityConfirmFormBase { ...@@ -45,7 +45,7 @@ class CaptchaPointDisableForm extends EntityConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->disable(); $this->entity->disable();
$this->entity->save(); $this->entity->save();
drupal_set_message($this->t('Captcha point %label has been disabled.', ['%label' => $this->entity->label()])); $this->messenger()->addMessage($this->t('Captcha point %label has been disabled.', ['%label' => $this->entity->label()]));
$form_state->setRedirect('captcha_point.list'); $form_state->setRedirect('captcha_point.list');
} }
......
...@@ -45,7 +45,7 @@ class CaptchaPointEnableForm extends EntityConfirmFormBase { ...@@ -45,7 +45,7 @@ class CaptchaPointEnableForm extends EntityConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->enable(); $this->entity->enable();
$this->entity->save(); $this->entity->save();
drupal_set_message($this->t('Captcha point %label has been enabled.', ['%label' => $this->entity->label()])); $this->messenger()->addMessage($this->t('Captcha point %label has been enabled.', ['%label' => $this->entity->label()]));
$form_state->setRedirect('captcha_point.list'); $form_state->setRedirect('captcha_point.list');
} }
......
...@@ -101,12 +101,12 @@ class CaptchaPointForm extends EntityForm { ...@@ -101,12 +101,12 @@ class CaptchaPointForm extends EntityForm {
$status = $captcha_point->save(); $status = $captcha_point->save();
if ($status == SAVED_NEW) { if ($status == SAVED_NEW) {
drupal_set_message($this->t('Captcha Point for %form_id form was created.', [ $this->messenger()->addMessage($this->t('Captcha Point for %form_id form was created.', [
'%form_id' => $captcha_point->getFormId(), '%form_id' => $captcha_point->getFormId(),
])); ]));
} }
else { else {
drupal_set_message($this->t('Captcha Point for %form_id form was updated.', [ $this->messenger()->addMessage($this->t('Captcha Point for %form_id form was updated.', [
'%form_id' => $captcha_point->getFormId(), '%form_id' => $captcha_point->getFormId(),
])); ]));
} }
......
...@@ -234,7 +234,7 @@ class CaptchaSettingsForm extends ConfigFormBase { ...@@ -234,7 +234,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
$config->set('enable_stats', $form_state->getValue('enable_stats')); $config->set('enable_stats', $form_state->getValue('enable_stats'));
$config->set('log_wrong_responses', $form_state->getValue('log_wrong_responses')); $config->set('log_wrong_responses', $form_state->getValue('log_wrong_responses'));
$config->save(); $config->save();
drupal_set_message($this->t('The CAPTCHA settings have been saved.'), 'status'); $this->messenger()->addStatus($this->t('The CAPTCHA settings have been saved.'));
parent::submitForm($form, $form_state); parent::submitForm($form, $form_state);
} }
...@@ -249,7 +249,7 @@ class CaptchaSettingsForm extends ConfigFormBase { ...@@ -249,7 +249,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
*/ */
public function clearCaptchaPlacementCacheSubmit(array $form, FormStateInterface $form_state) { public function clearCaptchaPlacementCacheSubmit(array $form, FormStateInterface $form_state) {
$this->cacheBackend->delete('captcha_placement_map_cache'); $this->cacheBackend->delete('captcha_placement_map_cache');
drupal_set_message($this->t('Cleared the CAPTCHA placement cache.')); $this->messenger()->addMessage($this->t('Cleared the CAPTCHA placement cache.'));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment