Commit 492b7a18 authored by catch's avatar catch
Browse files

Issue #2473875 by znerol, alexpott, andypost, kim.pepper, amit.drupal,...

Issue #2473875 by znerol, alexpott, andypost, kim.pepper, amit.drupal, raman.b, martin107, joachim: Convert uses of $_SESSION to symfony session retrieved from the request
parent fdfc5c6e
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -11,10 +11,11 @@ parameters:
    # @default 100
    gc_divisor: 100
    #
    # Set session lifetime (in seconds), i.e. the time from the user's last
    # visit to the active session may be deleted by the session garbage
    # collector. When a session is deleted, authenticated users are logged out,
    # and the contents of the user's $_SESSION variable is discarded.
    # Set session lifetime (in seconds), i.e. the grace period for session
    # data. Sessions are deleted by the session garbage collector after one
    # session lifetime has elapsed since the user's last visit. When a session
    # is deleted, authenticated users are logged out, and the contents of the
    # user's session is discarded.
    # @default 200000
    gc_maxlifetime: 200000
    #
+3 −3
Original line number Diff line number Diff line
@@ -10,9 +10,9 @@
 * A policy allowing delivery of cached pages when there is no session open.
 *
 * Do not serve cached pages to authenticated users, or to anonymous users when
 * $_SESSION is non-empty. $_SESSION may contain status messages from a form
 * submission, the contents of a shopping cart, or other user-specific content
 * that should not be cached and displayed to other users.
 * the user's session is non-empty. The user's session may contain status
 * messages from a form submission, the contents of a shopping cart, or other
 * user-specific content that should not be cached and displayed to other users.
 */
class NoSessionOpen implements RequestPolicyInterface {

+3 −2
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ function big_pipe_test_page_top(array &$page_top) {
  // Ensure this hook is invoked on every page load.
  $page_top['#cache']['max-age'] = 0;

  if (\Drupal::request()->query->get('trigger_session')) {
    $_SESSION['big_pipe_test'] = TRUE;
  $request = \Drupal::request();
  if ($request->query->get('trigger_session')) {
    $request->getSession()->set('big_pipe_test', TRUE);
  }
}
+13 −5
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
use Drupal\Core\Url;
use Drupal\user\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Link;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

@@ -118,6 +119,9 @@ public static function getLogLevelClassMap() {
   * Messages are truncated at 56 chars.
   * Full-length messages can be viewed on the message details page.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The request.
   *
   * @return array
   *   A render array as expected by
   *   \Drupal\Core\Render\RendererInterface::render().
@@ -125,9 +129,9 @@ public static function getLogLevelClassMap() {
   * @see Drupal\dblog\Form\DblogClearLogConfirmForm
   * @see Drupal\dblog\Controller\DbLogController::eventDetails()
   */
  public function overview() {
  public function overview(Request $request) {

    $filter = $this->buildFilterQuery();
    $filter = $this->buildFilterQuery($request);
    $rows = [];

    $classes = static::getLogLevelClassMap();
@@ -316,12 +320,16 @@ public function eventDetails($event_id) {
  /**
   * Builds a query for database log administration filters based on session.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The request.
   *
   * @return array|null
   *   An associative array with keys 'where' and 'args' or NULL if there were
   *   no filters set.
   */
  protected function buildFilterQuery() {
    if (empty($_SESSION['dblog_overview_filter'])) {
  protected function buildFilterQuery(Request $request) {
    $session_filters = $request->getSession()->get('dblog_overview_filter', []);
    if (empty($session_filters)) {
      return;
    }

@@ -331,7 +339,7 @@ protected function buildFilterQuery() {

    // Build query.
    $where = $args = [];
    foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) {
    foreach ($session_filters as $key => $filter) {
      $filter_where = [];
      foreach ($filter as $value) {
        $filter_where[] = $filters[$key]['where'];
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public function getCancelUrl() {
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $_SESSION['dblog_overview_filter'] = [];
    $this->getRequest()->getSession()->remove('dblog_overview_filter');
    $this->connection->truncate('watchdog')->execute();
    $this->messenger()->addStatus($this->t('Database log cleared.'));
    $form_state->setRedirectUrl($this->getCancelUrl());
Loading