Commit 1ac261d2 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Issue #3295625 by longwave, catch: Remove deprecated code from FormattableMarkup

parent eda8ea4c
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -233,13 +233,8 @@ protected static function placeholderFormat($string, array $args) {
          break;

        default:
          // Deprecate support for random variables that won't be replaced.
          if (ctype_alpha($key[0]) && strpos($string, $key) === FALSE) {
            @trigger_error(sprintf('Support for keys without a placeholder prefix is deprecated in Drupal 9.1.0 and will be removed in Drupal 10.0.0. Invalid placeholder (%s) with string: "%s"', $key, $string), E_USER_DEPRECATED);
          }
          else {
          // Warn for random variables that won't be replaced.
          trigger_error(sprintf('Invalid placeholder (%s) with string: "%s"', $key, $string), E_USER_WARNING);
          }
          // No replacement possible therefore we can discard the argument.
          unset($args[$key]);
          break;
+1 −10
Original line number Diff line number Diff line
@@ -99,17 +99,8 @@ public function providerTestUnexpectedPlaceholder() {
      // Ensure that where the placeholder is located in the string is
      // irrelevant.
      ['placeholder', ['placeholder' => 'replaced'], E_USER_WARNING, 'Invalid placeholder (placeholder) with string: "placeholder"'],
      ['No replacements', ['foo' => 'bar'], E_USER_WARNING, 'Invalid placeholder (foo) with string: "No replacements"'],
    ];
  }

  /**
   * @group legacy
   */
  public function testNoReplacementUnsupportedVariable() {
    $this->expectDeprecation('Support for keys without a placeholder prefix is deprecated in Drupal 9.1.0 and will be removed in Drupal 10.0.0. Invalid placeholder (foo) with string: "No replacements"');
    $markup = new FormattableMarkup('No replacements', ['foo' => 'bar']);
    // Cast it to a string which will generate the deprecation notice.
    $output = (string) $markup;
  }

}