- Issue created by @larowlan
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Found this via π HEAD broken with asserts enabled Active .
Quoting myself from there:
π±
This suggests that assertions are disabled on CI somehow?!? We ran into this months ago IIRC.
That would be a crucial thing to restore on CI π¬
β #3500109-6: HEAD broken with asserts enabled β
Both
\XbConfigEntityHttpApiTest::testPattern()
and\PropSourceEndpointTest()
cause\Drupal\experience_builder\ClientSideRepresentation::renderPreviewIfAny()
to be executed.I'm shocked that this somehow regressed. π€ͺ
β #3500109-7: HEAD broken with asserts enabled β
Note: this would also mean that core's
\Drupal\jsonapi\EventSubscriber\ResourceResponseValidator::onResponse()
will never actually verify JSON:API response shape compliance, and the same thing would be true for XB's OpenAPI request + response body OpenAPI compliance validation (see\Drupal\experience_builder\EventSubscriber\ApiMessageValidatorBase::isProd()
)! π±π±π± - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
On my local development environment, the same thing is happening! π± Because even this does not fail:
diff --git a/index.php b/index.php index 750dc282dc2..f7d7ccccd60 100644 --- a/index.php +++ b/index.php @@ -11,6 +11,8 @@ use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; +assert(TRUE === FALSE); + $autoloader = require_once 'autoload.php'; $kernel = new DrupalKernel('prod', $autoloader);
So let's investigate:
$ php -i | grep assert zend.assertions => 1 => 1 assert.active => On => On assert.bail => Off => Off assert.callback => no value => no value assert.exception => On => On assert.warning => On => On
(same exact values when I look at
<?php phpinfo();
FWIW, so same settings for CLI and non-CLI)yet:
ini_get('zend.assertions') === '1' ini_get('assert.exception') === '1' ini_get('assert.active') === '0'
π¬
This is apparently caused by #3186524: Fix htaccess files for PHP 8 β . I probably had an override for that in my
settings.local.php
previously and lost it at some point.Yep:
diff --git a/.htaccess b/.htaccess index 1ac01a117b2..1dc9fce4c81 100644 --- a/.htaccess +++ b/.htaccess @@ -30,7 +30,7 @@ AddType image/webp .webp # Drupal\Core\DrupalKernel::bootEnvironment() for settings that can be # changed at runtime. <IfModule mod_php.c> - php_value assert.active 0 + #php_value assert.active 0 </IfModule> # Requires mod_expires to be enabled.
causes things to fail as expected.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Aha, I had been relying on the original
example.settings.local.php
for a long time, but π Fix deprecated assert_options() function usage for PHP 8.3 Needs review removed the enabling of assertions at the end of 2023.Restoring those 2 lines:
assert_options(ASSERT_ACTIVE, TRUE); assert_options(ASSERT_EXCEPTION, TRUE);
β¦ makes things work as expected again.
Recently, during a reinstall of Drupal core, I had upgraded my
settings.local.php
to match the latest upstream one and hence lost the above. I wrongly assumed it'd continue to do the same things π¬ At least there's sanity again β I thought I was failing massively for never having noticed assertions were actually turned off for the entirety of the last >6 months of XB development! π»π€ͺNow let's fix this.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Looks like π Fix deprecated assert_options() function usage for PHP 8.3 Needs review not only broke having assertions enabled for Drupal developers on their local dev environments (in combination with #3186524: Fix htaccess files for PHP 8 β 2 years prior), but β¦ it also removed
// Web tests are to be conducted with runtime assertions active. assert_options(ASSERT_ACTIVE, TRUE); // Force assertion failures to be thrown as exceptions. assert_options(ASSERT_EXCEPTION, TRUE);
β¦ π±
That'd explain why tests are not failing on GitLab CI either!
Apparently there is a CR for this for Drupal 10.3: https://www.drupal.org/node/3391611 β , but that states that only adding
ini_set('zend.assertions', 1);
is sufficient. But it is not! π¬ At least not on PHP 8.3.15 (the latest).
It is not sufficient because
# Most of the following PHP settings cannot be changed at runtime. See # sites/default/default.settings.php and # Drupal\Core\DrupalKernel::bootEnvironment() for settings that can be # changed at runtime. <IfModule mod_php.c> php_value assert.active 0 </IfModule>
overrides it from its default of
1
. π€ͺSo this is a critical core bug, because Drupal core's
.htaccess
prevents the very intent of π Fix deprecated assert_options() function usage for PHP 8.3 Needs review as documented in https://www.drupal.org/node/3391611 β . π - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Apparently there is a core issue for this: π Remove mentions of assert.active from .htaccess Needs work .
Bumped it to critical and explained why: #3398033-31: Fix deprecated assert.active directive β .
- First commit to issue fork.
- π¬π§United Kingdom longwave UK
The MR is no good, enabling them in PHPUnit isn't the problem, it's in the site under test that we need to do it.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
YAY: https://git.drupalcode.org/project/experience_builder/-/jobs/4039450 β thanks, @longwave!
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Let's merge this to make CI tests fail explicitly, so that the title of π Improve or remove ComponentSourceInterface::getClientSideInfo() Active becomes a reality.
-
wim leers β
committed ed2bb7f3 on 0.x authored by
longwave β
Issue #3500110 by wim leers, longwave, larowlan: CI: PHP asserts not...
-
wim leers β
committed ed2bb7f3 on 0.x authored by
longwave β