Commit b65dcc01 authored by mikelutz's avatar mikelutz Committed by bojanz

Issue #3089178 by mikelutz: Make the build pass against 8.8 without deprecation suppression

parent e3ac4535
......@@ -17,5 +17,8 @@
"drupal/token": "^1.0",
"commerceguys/intl": "^1.0.0"
},
"require-dev": {
"drupal/mailsystem": "^4.1"
},
"minimum-stability": "dev"
}
......@@ -368,3 +368,18 @@ function commerce_product_type_labels() {
return EntityHelper::extractLabels($product_types);
}
/**
* Implements hook_config_schema_info_alter().
*
* This method provides a compatibility layer to allow new config schemas to be
* used with older versions of Drupal.
*/
function commerce_product_config_schema_info_alter(&$definitions) {
if (!isset($definitions['field.widget.settings.entity_reference_autocomplete']['mapping']['match_limit'])) {
$definitions['field.widget.settings.entity_reference_autocomplete']['mapping']['match_limit'] = [
'type' => 'integer',
'label' => 'Maximum number of autocomplete suggestions.',
];
}
}
......@@ -66,6 +66,7 @@ content:
weight: 4
settings:
match_operator: CONTAINS
match_limit: 10
size: 60
placeholder: ''
third_party_settings: { }
......
......@@ -18,6 +18,7 @@ content:
weight: 0
settings:
match_operator: CONTAINS
match_limit: 10
size: 60
placeholder: ''
third_party_settings: { }
......
......@@ -7,10 +7,19 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Form\FormState;
// @codingStandardsIgnoreStart
// @todo remove this BC layer once support for Drupal 8.7 is sunsetted
if (interface_exists('\Drupal\Core\Security\TrustedCallbackInterface')) {
interface TrustedCallbackInterface extends \Drupal\Core\Security\TrustedCallbackInterface {}
}
else {
interface TrustedCallbackInterface {}
}
// @codingStandardsIgnoreStop
/**
* Provides #lazy_builder callbacks.
*/
class ProductLazyBuilders {
class ProductLazyBuilders implements TrustedCallbackInterface {
/**
* The entity type manager.
......@@ -96,4 +105,11 @@ class ProductLazyBuilders {
return $this->formBuilder->buildForm($form_object, $form_state);
}
/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return ['addToCartForm'];
}
}
......@@ -6,6 +6,7 @@ use Drupal\commerce_store\StoreCreationTrait;
use Drupal\Tests\block\Traits\BlockCreationTrait;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\commerce\Traits\CommerceBrowserTestTrait;
use Drupal\Tests\commerce\Traits\DeprecationSuppressionTrait;
/**
* Provides a base class for Commerce functional tests.
......@@ -15,6 +16,7 @@ abstract class CommerceBrowserTestBase extends BrowserTestBase {
use BlockCreationTrait;
use StoreCreationTrait;
use CommerceBrowserTestTrait;
use DeprecationSuppressionTrait;
/**
* The store entity.
......@@ -51,6 +53,7 @@ abstract class CommerceBrowserTestBase extends BrowserTestBase {
* {@inheritdoc}
*/
protected function setUp() {
$this->setErrorHandler();
parent::setUp();
$this->store = $this->createStore();
......@@ -62,6 +65,14 @@ abstract class CommerceBrowserTestBase extends BrowserTestBase {
$this->drupalLogin($this->adminUser);
}
/**
* {@inheritdoc}
*/
protected function tearDown() {
parent::tearDown();
$this->restoreErrorHandler();
}
/**
* Gets the permissions for the admin user.
*
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\commerce\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\commerce\Traits\DeprecationSuppressionTrait;
/**
* Tests module uninstallation.
......@@ -11,6 +12,24 @@ use Drupal\Tests\BrowserTestBase;
*/
class UninstallTest extends BrowserTestBase {
use DeprecationSuppressionTrait;
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->setErrorHandler();
parent::setUp();
}
/**
* {@inheritdoc}
*/
protected function tearDown() {
parent::tearDown();
$this->restoreErrorHandler();
}
/**
* {@inheritdoc}
*/
......
......@@ -4,12 +4,14 @@ namespace Drupal\Tests\commerce\Kernel;
use Drupal\commerce_store\StoreCreationTrait;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\Tests\commerce\Traits\DeprecationSuppressionTrait;
/**
* Provides a base class for Commerce kernel tests.
*/
abstract class CommerceKernelTestBase extends EntityKernelTestBase {
use DeprecationSuppressionTrait;
use StoreCreationTrait;
/**
......@@ -45,6 +47,7 @@ abstract class CommerceKernelTestBase extends EntityKernelTestBase {
*/
protected function setUp() {
parent::setUp();
$this->setErrorHandler();
if (\Drupal::entityTypeManager()->hasDefinition('path_alias')) {
$this->installEntitySchema('path_alias');
......@@ -60,4 +63,12 @@ abstract class CommerceKernelTestBase extends EntityKernelTestBase {
\Drupal::entityTypeManager()->getStorage('commerce_store')->markAsDefault($this->store);
}
/**
* {@inheritdoc}
*/
protected function tearDown() {
$this->restoreErrorHandler();
parent::tearDown();
}
}
......@@ -45,7 +45,7 @@ class MailHandlerThemeTest extends CommerceKernelTestBase {
parent::setUp();
$this->installConfig(['mailsystem']);
\Drupal::service('theme_handler')->install(['commerce_test_theme']);
\Drupal::service('theme_installer')->install(['commerce_test_theme']);
$this->mailHandler = $this->container->get('commerce.mail_handler');
$this->user = $this->createUser(['mail' => 'customer@example.com']);
......
<?php
namespace Drupal\Tests\commerce\Traits;
/**
* Enables suppression of select deprecation messages during testing.
*
* This trait creates a custom error handler able to suppress a specific set
* of deprecation errors, while allowing the rest to surface. It's useful to
* ignore certain errors temporarily, such as those from dependencies, or those
* whose fix has been intentionally postponed until a support is dropped for
* legacy drupal versions.
*
* @package Drupal\Tests\commerce\Traits
*/
trait DeprecationSuppressionTrait {
/**
* Sets an error handler to suppress specified deprecation messages.
*/
protected function setErrorHandler() {
$previous_error_handler = set_error_handler(function ($severity, $message, $file, $line, $context) use (&$previous_error_handler) {
$skipped_deprecations = [
// @see https://www.drupal.org/project/address/issues/3089266
"Render #post_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was Drupal\address\Plugin\Field\FieldFormatter\AddressDefaultFormatter::postRender. Support for this callback implementation is deprecated in 8.8.0 and will be removed in Drupal 9.0.0. See https://www.drupal.org/node/2966725",
"There is no `base theme` property specified in the mailsystem_test_theme.info.yml file. The optionality of the `base theme` property is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. All Drupal 8 themes must add `base theme: stable` to their *.info.yml file for them to continue to work as-is in future versions of Drupal. Drupal 9 requires the `base theme` property to be specified. See https://www.drupal.org/node/3066038",
];
if (!in_array($message, $skipped_deprecations, TRUE)) {
return $previous_error_handler($severity, $message, $file, $line, $context);
}
}, E_USER_DEPRECATED);
}
/**
* Restores the original error handler.
*/
protected function restoreErrorHandler() {
restore_error_handler();
}
}
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