Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When updating the acquia_contenthub module, we found that running our test suite against 5.6.32 and below caused php fatal errors. Test output below.
The crux of the issue is use statements for traits contain the same name as the traits in WebTestBase namespace. Not sure why this doesn't fail in php7, but so far its only in php 5.6
$ php core/scripts/run-tests.sh --php /home/travis/.phpenv/shims/php --verbose --url http://localhost:8080 acquia_contenthub
Drupal test run
---------------
Tests to be run:
- Drupal\acquia_contenthub\Tests\FieldClearingNodeTest
- Drupal\acquia_contenthub\Tests\IntegrationTest
- Drupal\acquia_contenthub\Tests\NodeFormTest
- Drupal\acquia_contenthub\Tests\ParagraphsTest
- Drupal\acquia_contenthub\Tests\TaxonomyTermTest
- Drupal\Tests\acquia_contenthub\Unit\ContentHubEntitiesTrackingTest
- Drupal\Tests\acquia_contenthub\Unit\ContentHubEntityDependencyTest
- Drupal\Tests\acquia_contenthub\Unit\ContentHubEntityEmbedHandlerTest
- Drupal\Tests\acquia_contenthub\Unit\Controller\ContentHubExportQueueControllerTest
- Drupal\Tests\acquia_contenthub\Unit\Controller\ContentHubReindexTest
- Drupal\Tests\acquia_contenthub\Unit\Encoder\ContentHubCdfEncoderTest
- Drupal\Tests\acquia_contenthub\Unit\EntityManagerTest
- Drupal\Tests\acquia_contenthub\Unit\Form\NodeFormTest
- Drupal\Tests\acquia_contenthub\Unit\Form\NodeTypePreviewImageFormTest
- Drupal\Tests\acquia_contenthub\Unit\ImportEntityManagerTest
- Drupal\Tests\acquia_contenthub\Unit\Normalizer\ContentEntityNormalizerTest
- Drupal\Tests\acquia_contenthub\Unit\Normalizer\ContentEntityViewModesExtractorTest
- Drupal\Tests\acquia_contenthub\Unit\Plugin\QueueWorker\ContentHubImportQueueBaseTest
- Drupal\Tests\acquia_contenthub\Unit\QueueItem\ImportQueueItemTest
- Drupal\Tests\acquia_contenthub\Unit\Session\ContentHubUserSessionTest
Test run started:
Friday, March 2, 2018 - 06:09
Test summary
------------
Drupal\acquia_contenthub\Tests\FieldClearingNodeTest 45 passes 1 exceptions 9 messages
PHP Fatal error: Cannot use Drupal\Tests\node\Traits\ContentTypeCreationTrait as ContentTypeCreationTrait because the name is already in use in /home/travis/build/drupal/docroot/core/modules/simpletest/src/WebTestBase.php on line 22
Fatal error: Cannot use Drupal\Tests\node\Traits\ContentTypeCreationTrait as ContentTypeCreationTrait because the name is already in use in /home/travis/build/drupal/docroot/core/modules/simpletest/src/WebTestBase.php on line 22
Proposed resolution
Rename the remaining traits so they don't conflict.
Remaining tasks
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2949449-traits-webtestbase-fatal-php56-3.patch | 1.88 KB | japerry |
Comments
Comment #2
japerryComment #3
japerryThis patch fixes the problem, it looks like BaseBlockCreationTrait already has this fix, so I applied it to the other traits that conflict.
Comment #4
dawehnerGood catch!
Comment #5
alexpottCommitted and pushed a843845587 to 8.6.x and 30fa28410a to 8.5.x. Thanks!
Comment #6
tacituseu CreditAttribution: tacituseu commented@alexpott: commit message got lost (only "-m").
Comment #8
alexpottCommitted and pushed bf9db4f0f3 to 8.6.x and 3ffdb9b2b5 to 8.5.x. Thanks!