Problem/Motivation

Using tempnam() in PHP7.1 can result in PHP warnings if it falls back to the system temporary directory. This is the case for some of our tests.

exception: [Notice] Line 651 of core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php:
tempnam(): file created in the system's temporary directorytempnam('temporary://', 'vi_') (Line: 651)
Drupal\config_translation\Tests\ConfigTranslationUiTest->testPluralConfigStringsSourceElements() (Line: 958)
Drupal\simpletest\TestBase->run(Array) (Line: 752)
simpletest_script_run_one_test('378', 'Drupal\config_translation\Tests\ConfigTranslationUiTest') (Line: 66)

See https://bugs.php.net/bug.php?id=69489

Proposed resolution

Don't use temporary:// as the stream wrapper is not defined.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#4 2842942-4.patch6.92 KBalexpott
#3 2842942-2.patch4.83 KBalexpott

Comments

alexpott created an issue. See original summary.

alexpott’s picture

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new4.83 KB
alexpott’s picture

StatusFileSize
new6.92 KB

Missed one and the problem is that tempnam() just does not support streams so all the calls are bogus - they're never going to end up in Drupal's temp directory. I've reviewed all the tempnam() usage in core and after this patch it all looks good to me.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. It's a straight 1 for 1 switch and 7.1 is indirectly providing test coverage for us now, even if it was silently failing before.

  • catch committed 8872b0d on 8.3.x
    Issue #2842942 by alexpott: Fix tempnam() usage in PHP7.1
    

  • catch committed 7097e66 on 8.2.x
    Issue #2842942 by alexpott: Fix tempnam() usage in PHP7.1
    
    (cherry...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.3.x and cherry-picked to 8.2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.