Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
search_api_attachments
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
search_api_attachments
Commits
a7dcab95
Commit
a7dcab95
authored
2 years ago
by
Christopher Gadd
Committed by
Ismaeil Abouljamal
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3255205
: Indexing fails due to missing locale
parent
bd95d157
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!8
Issue #3255205: Indexing fails due to missing locale
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/search_api_attachments/TikaExtractor.php
+10
-7
10 additions, 7 deletions
src/Plugin/search_api_attachments/TikaExtractor.php
with
10 additions
and
7 deletions
src/Plugin/search_api_attachments/TikaExtractor.php
+
10
−
7
View file @
a7dcab95
...
...
@@ -33,10 +33,14 @@ class TikaExtractor extends TextExtractorPluginBase {
$java
=
$this
->
configuration
[
'java_path'
];
// UTF-8 multibyte characters will be stripped by escapeshellargs() for the
// default C-locale.
// So temporarily set the locale to UTF-8 so that the filepath remains
// valid.
// So temporarily set the locale to UTF-8 if available so that the filepath
// remains valid.
// Attempt to use en_US.UTF-8 first, and fallback to C.UTF-8, since
// en_US.UTF-8 is more widespread, while C.UTF-8 may be present otherwwise.
$backup_locale
=
setlocale
(
LC_CTYPE
,
'0'
);
setlocale
(
LC_CTYPE
,
'en_US.UTF-8'
);
$preferred_locales
=
[
'en_US.UTF-8'
,
'C.UTF-8'
];
$new_locale
=
setlocale
(
LC_CTYPE
,
$preferred_locales
)
?:
$backup_locale
;
$param
=
''
;
if
(
$file
->
getMimeType
()
!=
'audio/mpeg'
)
{
$param
=
' -Dfile.encoding=UTF8 -cp '
.
escapeshellarg
(
$tika
);
...
...
@@ -51,12 +55,11 @@ class TikaExtractor extends TextExtractorPluginBase {
}
// Restore the locale.
setlocale
(
LC_CTYPE
,
$backup_locale
);
// Support UTF-8 commands:
// @see http://www.php.net/manual/en/function.shell-exec.php#85095
shell_exec
(
"LANG=en_US.utf-8"
);
// Support UTF-8 encoded filenames
$cmd
=
'export LANG='
.
$new_locale
.
'; '
.
$cmd
;
$output
=
shell_exec
(
$cmd
);
if
(
is_null
(
$output
))
{
throw
new
\Exception
(
'Tika Ex
c
tractor is not available.'
);
throw
new
\Exception
(
'Tika Extractor is not available.'
);
}
return
$output
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment