Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
220
Merge Requests
220
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
8872b0dd
Commit
8872b0dd
authored
Jan 12, 2017
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2842942
by alexpott: Fix tempnam() usage in PHP7.1
parent
6b342913
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
10 deletions
+22
-10
core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
.../config_translation/src/Tests/ConfigTranslationUiTest.php
+2
-2
core/modules/locale/src/Form/ExportForm.php
core/modules/locale/src/Form/ExportForm.php
+15
-3
core/modules/locale/src/Tests/LocaleExportTest.php
core/modules/locale/src/Tests/LocaleExportTest.php
+2
-2
core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
+1
-1
core/modules/locale/src/Tests/LocalePluralFormatTest.php
core/modules/locale/src/Tests/LocalePluralFormatTest.php
+1
-1
core/modules/system/src/Tests/Theme/TwigTransTest.php
core/modules/system/src/Tests/Theme/TwigTransTest.php
+1
-1
No files found.
core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php
View file @
8872b0dd
...
@@ -648,7 +648,7 @@ public function testPluralConfigStringsSourceElements() {
...
@@ -648,7 +648,7 @@ public function testPluralConfigStringsSourceElements() {
foreach
(
$languages
as
$langcode
=>
$data
)
{
foreach
(
$languages
as
$langcode
=>
$data
)
{
// Import a .po file to add a new language with a given number of plural forms
// Import a .po file to add a new language with a given number of plural forms
$name
=
tempnam
(
'temporary://'
,
$langcode
.
'_'
)
.
'.po'
;
$name
=
\
Drupal
::
service
(
'file_system'
)
->
tempnam
(
'temporary://'
,
$langcode
.
'_'
)
.
'.po'
;
file_put_contents
(
$name
,
$this
->
getPoFile
(
$data
[
'plurals'
]));
file_put_contents
(
$name
,
$this
->
getPoFile
(
$data
[
'plurals'
]));
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
array
(
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
array
(
'langcode'
=>
$langcode
,
'langcode'
=>
$langcode
,
...
@@ -684,7 +684,7 @@ public function testPluralConfigStrings() {
...
@@ -684,7 +684,7 @@ public function testPluralConfigStrings() {
// First import a .po file with multiple plural forms.
// First import a .po file with multiple plural forms.
// This will also automatically add the 'sl' language.
// This will also automatically add the 'sl' language.
$name
=
tempnam
(
'temporary://'
,
"sl_"
)
.
'.po'
;
$name
=
\
Drupal
::
service
(
'file_system'
)
->
tempnam
(
'temporary://'
,
"sl_"
)
.
'.po'
;
file_put_contents
(
$name
,
$this
->
getPoFile
(
4
));
file_put_contents
(
$name
,
$this
->
getPoFile
(
4
));
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
array
(
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
array
(
'langcode'
=>
'sl'
,
'langcode'
=>
'sl'
,
...
...
core/modules/locale/src/Form/ExportForm.php
View file @
8872b0dd
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
Drupal\locale\Form
;
namespace
Drupal\locale\Form
;
use
Drupal\Component\Gettext\PoStreamWriter
;
use
Drupal\Component\Gettext\PoStreamWriter
;
use
Drupal\Core\File\FileSystemInterface
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Language\LanguageInterface
;
use
Drupal\Core\Language\LanguageInterface
;
...
@@ -23,14 +24,24 @@ class ExportForm extends FormBase {
...
@@ -23,14 +24,24 @@ class ExportForm extends FormBase {
*/
*/
protected
$languageManager
;
protected
$languageManager
;
/**
* The file system service.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected
$fileSystem
;
/**
/**
* Constructs a new ExportForm.
* Constructs a new ExportForm.
*
*
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* The language manager.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* The file system service.
*/
*/
public
function
__construct
(
LanguageManagerInterface
$language_manager
)
{
public
function
__construct
(
LanguageManagerInterface
$language_manager
,
FileSystemInterface
$file_system
)
{
$this
->
languageManager
=
$language_manager
;
$this
->
languageManager
=
$language_manager
;
$this
->
fileSystem
=
$file_system
;
}
}
/**
/**
...
@@ -38,7 +49,8 @@ public function __construct(LanguageManagerInterface $language_manager) {
...
@@ -38,7 +49,8 @@ public function __construct(LanguageManagerInterface $language_manager) {
*/
*/
public
static
function
create
(
ContainerInterface
$container
)
{
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
return
new
static
(
$container
->
get
(
'language_manager'
)
$container
->
get
(
'language_manager'
),
$container
->
get
(
'file_system'
)
);
);
}
}
...
@@ -147,7 +159,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
...
@@ -147,7 +159,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$item
=
$reader
->
readItem
();
$item
=
$reader
->
readItem
();
if
(
!
empty
(
$item
))
{
if
(
!
empty
(
$item
))
{
$uri
=
tempnam
(
'temporary://'
,
'po_'
);
$uri
=
$this
->
fileSystem
->
tempnam
(
'temporary://'
,
'po_'
);
$header
=
$reader
->
getHeader
();
$header
=
$reader
->
getHeader
();
$header
->
setProjectName
(
$this
->
config
(
'system.site'
)
->
get
(
'name'
));
$header
->
setProjectName
(
$this
->
config
(
'system.site'
)
->
get
(
'name'
));
$header
->
setLanguageName
(
$language_name
);
$header
->
setLanguageName
(
$language_name
);
...
...
core/modules/locale/src/Tests/LocaleExportTest.php
View file @
8872b0dd
...
@@ -43,7 +43,7 @@ protected function setUp() {
...
@@ -43,7 +43,7 @@ protected function setUp() {
public
function
testExportTranslation
()
{
public
function
testExportTranslation
()
{
// First import some known translations.
// First import some known translations.
// This will also automatically add the 'fr' language.
// This will also automatically add the 'fr' language.
$name
=
tempnam
(
'temporary://'
,
"po_"
)
.
'.po'
;
$name
=
\
Drupal
::
service
(
'file_system'
)
->
tempnam
(
'temporary://'
,
"po_"
)
.
'.po'
;
file_put_contents
(
$name
,
$this
->
getPoFile
());
file_put_contents
(
$name
,
$this
->
getPoFile
());
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
array
(
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
array
(
'langcode'
=>
'fr'
,
'langcode'
=>
'fr'
,
...
@@ -62,7 +62,7 @@ public function testExportTranslation() {
...
@@ -62,7 +62,7 @@ public function testExportTranslation() {
$this
->
assertRaw
(
'msgstr "lundi"'
,
'French translations present in exported file.'
);
$this
->
assertRaw
(
'msgstr "lundi"'
,
'French translations present in exported file.'
);
// Import some more French translations which will be marked as customized.
// Import some more French translations which will be marked as customized.
$name
=
tempnam
(
'temporary://'
,
"po2_"
)
.
'.po'
;
$name
=
\
Drupal
::
service
(
'file_system'
)
->
tempnam
(
'temporary://'
,
"po2_"
)
.
'.po'
;
file_put_contents
(
$name
,
$this
->
getCustomPoFile
());
file_put_contents
(
$name
,
$this
->
getCustomPoFile
());
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
array
(
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
array
(
'langcode'
=>
'fr'
,
'langcode'
=>
'fr'
,
...
...
core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
View file @
8872b0dd
...
@@ -369,7 +369,7 @@ public function testCreatedLanguageTranslation() {
...
@@ -369,7 +369,7 @@ public function testCreatedLanguageTranslation() {
* (optional) Additional options to pass to the translation import form.
* (optional) Additional options to pass to the translation import form.
*/
*/
public
function
importPoFile
(
$contents
,
array
$options
=
array
())
{
public
function
importPoFile
(
$contents
,
array
$options
=
array
())
{
$name
=
tempnam
(
'temporary://'
,
"po_"
)
.
'.po'
;
$name
=
\
Drupal
::
service
(
'file_system'
)
->
tempnam
(
'temporary://'
,
"po_"
)
.
'.po'
;
file_put_contents
(
$name
,
$contents
);
file_put_contents
(
$name
,
$contents
);
$options
[
'files[file]'
]
=
$name
;
$options
[
'files[file]'
]
=
$name
;
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
$options
,
t
(
'Import'
));
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
$options
,
t
(
'Import'
));
...
...
core/modules/locale/src/Tests/LocalePluralFormatTest.php
View file @
8872b0dd
...
@@ -351,7 +351,7 @@ public function testPluralEditExport() {
...
@@ -351,7 +351,7 @@ public function testPluralEditExport() {
* Additional options to pass to the translation import form.
* Additional options to pass to the translation import form.
*/
*/
public
function
importPoFile
(
$contents
,
array
$options
=
array
())
{
public
function
importPoFile
(
$contents
,
array
$options
=
array
())
{
$name
=
tempnam
(
'temporary://'
,
"po_"
)
.
'.po'
;
$name
=
\
Drupal
::
service
(
'file_system'
)
->
tempnam
(
'temporary://'
,
"po_"
)
.
'.po'
;
file_put_contents
(
$name
,
$contents
);
file_put_contents
(
$name
,
$contents
);
$options
[
'files[file]'
]
=
$name
;
$options
[
'files[file]'
]
=
$name
;
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
$options
,
t
(
'Import'
));
$this
->
drupalPostForm
(
'admin/config/regional/translate/import'
,
$options
,
t
(
'Import'
));
...
...
core/modules/system/src/Tests/Theme/TwigTransTest.php
View file @
8872b0dd
...
@@ -209,7 +209,7 @@ protected function installLanguages() {
...
@@ -209,7 +209,7 @@ protected function installLanguages() {
$this
->
assertRaw
(
'"edit-languages-'
.
$langcode
.
'-weight"'
,
'Language code found.'
);
$this
->
assertRaw
(
'"edit-languages-'
.
$langcode
.
'-weight"'
,
'Language code found.'
);
// Import the custom .po contents for the language.
// Import the custom .po contents for the language.
$filename
=
tempnam
(
'temporary://'
,
"po_"
)
.
'.po'
;
$filename
=
\
Drupal
::
service
(
'file_system'
)
->
tempnam
(
'temporary://'
,
"po_"
)
.
'.po'
;
file_put_contents
(
$filename
,
$contents
);
file_put_contents
(
$filename
,
$contents
);
$options
=
array
(
$options
=
array
(
'files[file]'
=>
$filename
,
'files[file]'
=>
$filename
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment