Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293522

Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\serialization\EventSubscriber\UserRouteAlterSubscriber->onRoutingAlterAddFormats()

$
0
0

Problem/Motivation

Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\serialization\EventSubscriber\UserRouteAlterSubscriber->onRoutingAlterAddFormats() (line 55 of core/modules/serialization/src/EventSubscriber/UserRouteAlterSubscriber.php).

The deprecation notice can occur if some other code has altered and removed the _format requirement on one of the 'user.login_status.http', 'user.login.http', 'user.logout.http', or 'user.pass.http' routes.

Steps to reproduce

Have another module alter one of the routes to remove _format requirement. The other module has to come before the serialization module.

See the proposed test case in the merge request.

Steps to reproduce issue,

1. Create custom module having the logic to alter the Route.
2. Altering RouteSubscriberBase as below.

<?php

namespace Drupal\custom_module\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 *
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * Disable access to cohesion entities if assets have not been imported
   * or "Use Site studio" option is set to 'disable'
   * {@inheritdoc}.
   */
  protected function alterRoutes(RouteCollection $collection) {

    if ($route = $collection->get('user.pass.http')) {
      $route->setRequirements([]);
      $route->setRequirement('_access', 'FALSE');
    }
  }

}

3. Clear the cache, Access the route user/password
4. Getting below error

Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\serialization\EventSubscriber\UserRouteAlterSubscriber->onRoutingAlterAddFormats() (line 55 of /var/www/html/docroot/core/modules/serialization/src/EventSubscriber/UserRouteAlterSubscriber.php)
#0 /var/www/html/docroot/core/includes/bootstrap.inc(164): _drupal_error_handler_real(8192, 'explode(): Pass...', '/var/www/html/d...', 55)
#1 [internal function]: _drupal_error_handler(8192, 'explode(): Pass...', '/var/www/html/d...', 55)
#2 /var/www/html/docroot/core/modules/serialization/src/EventSubscriber/UserRouteAlterSubscriber.php(55): explode('|', NULL)

Proposed resolution

Apply merge request.

Remaining tasks

#17
Update proposed resolution
Needs review.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.


Viewing all articles
Browse latest Browse all 293522

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>