Fix deprecated assert.active directive

Created on 31 October 2023, about 1 year ago
Updated 12 June 2024, 5 months ago

Problem/Motivation

There's override of the setting https://git.drupalcode.org/project/drupal/-/blob/8f50a5caaf9585f15825dee... which is deprecated in PHP 8.3. Core no longer use this setting after πŸ“Œ Fix deprecated assert_options() function usage for PHP 8.3 Needs review , but a correct value is helpful to users who are setting up a development environment.

Steps to reproduce

- run apache2+mop_php
- check logs for value override, may need versole logging enabled
- make sure there's no deprecation message

Proposed resolution

Replace the assert.active directive with the zend.assertions directive.
Default value should be 0 (available but skipped), but able to be set to 1 (active) with settings.local.php.
Production sites can set the value to -1 (unavailable) in php.ini for maximum performance. Drupal cannot change the setting in that case.

Remaining tasks

- review
- commit

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 1 hour ago

Created by

πŸ‡«πŸ‡·France andypost

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @andypost
  • πŸ‡«πŸ‡·France andypost

    at CLI side

    /var/www/html/web $ php -v
    PHP 8.3.0RC5 (cli) (built: Oct 24 2023 23:57:57) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.3.0RC5, Copyright (c) Zend Technologies
        with Zend OPcache v8.3.0RC5, Copyright (c), by Zend Technologies
    /var/www/html/web $ php -dassert.active=0 -r 'echo 1;'
    PHP Deprecated:  PHP Startup: assert.active INI setting is deprecated in Unknown on line 0
    1
  • Merge request !5201Remove mentions of assert.active #3398033 β†’ (Open) created by andypost
  • Pipeline finished with Success
    about 1 year ago
    Total: 650s
    #42063
  • Status changed to Needs review about 1 year ago
  • Status changed to RTBC about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Searched for assert.active in .htaccess and 1 instance has been replaced.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Tagging for release notes because this should go in 'changes to site owner managed files'.

    Also tagging for a change record update because the one linked doesn't explicitly mention .htaccess yet.

  • Status changed to Needs work about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    I agree with removing assert.active, but not with removing the documentation for adding PHP settings. I relied heavily on this documentation to get my sites working when I started out with Drupal.

  • Pipeline finished with Success
    11 months ago
    Total: 730s
    #68925
  • Pipeline finished with Success
    11 months ago
    Total: 620s
    #68933
  • Pipeline finished with Success
    11 months ago
    Total: 643s
    #68939
  • Pipeline finished with Success
    11 months ago
    Total: 575s
    #68942
  • Status changed to Needs review 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    I restored the PHP settings documentation to the 11.x branch. I don't think assertions should be enabled by default in 10.x because they are used in contrib projects, so I added a merge request for 10.x that replaces assert.active with zend.assertions.

  • Pipeline finished with Success
    11 months ago
    Total: 724s
    #69162
  • Pipeline finished with Success
    11 months ago
    Total: 736s
    #69161
  • Status changed to RTBC 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Don't see any issue with leaving the comments. Think this missed 10.2 though.

  • Pipeline finished with Success
    11 months ago
    Total: 754s
    #70649
  • Pipeline finished with Failed
    11 months ago
    Total: 493s
    #70660
  • Pipeline finished with Canceled
    11 months ago
    Total: 75s
    #70669
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    Darren Oh β†’ changed the visibility of the branch 3398033-remove-assert.active to hidden.

  • Pipeline finished with Success
    11 months ago
    Total: 532s
    #70667
  • Status changed to Needs review 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    I don't think a default setting for assertions should be removed in Drupal 10. I switched the merge request for 10.2.x to 11.x and changed zend.assertions to a value that can be overridden in settings.local.php. Also updated the change record.

  • Status changed to Needs work 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Think 10.3 should be fine. But MR has a test failure now.

  • Pipeline finished with Failed
    11 months ago
    Total: 1299s
    #70671
  • Status changed to Needs review 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    Didn't realize files in the sites folder were scaffolded.

  • Pipeline finished with Success
    11 months ago
    Total: 502s
    #70682
  • πŸ‡«πŸ‡·France andypost

    Not sure it makes sense to have this sessions in .htaccess and setting.php as well

    I'd just removed this lines

  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    settings.local.php has a different value for development environments.

  • Status changed to Needs work 9 months ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Left a comment on the MR

  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    We should just replace the deprecated setting with the correct setting and stop trying to remove something that helps users set up a development environment correctly. Recommending a correct setting for php.ini is compatible with showing how to override it temporarily in the example settings.local.php.

  • πŸ‡·πŸ‡ΊRussia Chi

    assert.active takes precedence over zend.assertions. Does it mean all tests running on Apache does not check for assertions? If so I would consider this as a bug.

  • Status changed to Needs review 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    Chi, we have always disabled checking for assertions in Apache by default, with the option to enable checking in settings.local.php. Please review.

  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida
  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida
  • πŸ‡·πŸ‡ΊRussia Chi

    If zend_assertions is set to prod mode, in php.ini this statement in .htaccess

    + php_value zend.assertions 0

    causes the following warning in Apache error log

    [php:warn] [pid 176] [client 172.29.0.254:50836] PHP Warning: zend.assertions may be completely enabled or disabled only in php.ini in Unknown on line

  • πŸ‡ΊπŸ‡ΈUnited States darren oh Lakeland, Florida

    The default value is 1, so if an administrator sets it to -1 they can also remove the line from .htaccess.

  • πŸ‡·πŸ‡ΊRussia Chi

    The default value is 1

    The default value may be set by Linux distributions or hosting providers. They don't know much about Drupal requirements.

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    The recommended php config for production has zend.assertions at -1, and I think this will be pretty commonly installed. And so you have that warning message logged for every request. My 2 cents is that setting zend.assertions is something that should be documented for developers to do, rather than happening out-of-the-box

  • Pipeline finished with Failed
    8 months ago
    Total: 170s
    #126471
  • Pipeline finished with Success
    8 months ago
    Total: 616s
    #126475
  • Status changed to RTBC 5 months ago
  • πŸ‡«πŸ‡·France andypost

    Looks ready to go, comments make sense, thank you!

  • Status changed to Needs work 5 months ago
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    I think the change record needs updating. We're no longer setting in .htaccess and we appear to be recommending managing this in your php.ini. The Cr should explain the intricacies here.

Production build 0.71.5 2024