Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
exif
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
exif
Commits
b389f34c
Commit
b389f34c
authored
3 years ago
by
git
Committed by
Damien McKenna
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3147405
by Project Update Bot, DamienMcKenna: Automated Drupal 9 compatibility fixes.
parent
f117b7ed
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
exif.drush.inc
+13
-6
13 additions, 6 deletions
exif.drush.inc
src/Controller/ExifSettingsController.php
+3
-3
3 additions, 3 deletions
src/Controller/ExifSettingsController.php
src/ExifContent.php
+4
-2
4 additions, 2 deletions
src/ExifContent.php
with
20 additions
and
11 deletions
exif.drush.inc
+
13
−
6
View file @
b389f34c
...
...
@@ -5,6 +5,7 @@
* Drush extension allowing to run some tasks related to exif.
*/
use
Drupal\Core\File\FileSystemInterface
;
use
Drupal\file\Entity\File
;
use
Drupal\media_entity
\Entity\Media
;
use
Drupal\node\Entity\Node
;
...
...
@@ -285,7 +286,9 @@ function __drush_exif_list_active_types($entity_types = []) {
*/
function
__drush_exif_node_update
(
$type
=
''
)
{
$query
=
"SELECT n.nid FROM
{
node
}
n WHERE n.type = :type"
;
$result
=
db_query
(
$query
,
[
':type'
=>
$type
]);
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
$result
=
\Drupal
::
database
()
->
query
(
$query
,
[
':type'
=>
$type
]);
$count
=
0
;
foreach
(
$result
as
$record
)
{
// Load the node object from the database.
...
...
@@ -309,7 +312,9 @@ function __drush_exif_node_update($type = '') {
*/
function
__drush_exif_file_update
(
$type
=
''
)
{
$query
=
"SELECT n.fid FROM
{
file_managed
}
n WHERE n.type = :type"
;
$result
=
db_query
(
$query
,
[
':type'
=>
$type
]);
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
$result
=
\Drupal
::
database
()
->
query
(
$query
,
[
':type'
=>
$type
]);
$count
=
0
;
foreach
(
$result
as
$record
)
{
// Load the node object from the database.
...
...
@@ -332,7 +337,9 @@ function __drush_exif_file_update($type = '') {
*/
function
__drush_exif_media_update
(
$type
=
''
)
{
$query
=
"SELECT m.mid FROM
{
media
}
m WHERE m.bundle = :type"
;
$result
=
db_query
(
$query
,
[
':type'
=>
$type
]);
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
$result
=
\Drupal
::
database
()
->
query
(
$query
,
[
':type'
=>
$type
]);
$count
=
0
;
foreach
(
$result
as
$record
)
{
// Load the media object from the database.
...
...
@@ -375,7 +382,7 @@ function __drush_exif_entity_import($entity_type, $type, $uid, $field, $file, $l
// Saving file. automatically added to file entity if present.
$file_content
=
file_get_contents
(
$file
);
// Saves a file to the specified destination and creates a database entry.
$file_temp
=
file_save_data
(
$file_content
,
'public://'
.
$title
,
F
ILE_
EXISTS_RENAME
);
$file_temp
=
file_save_data
(
$file_content
,
'public://'
.
$title
,
F
ileSystemInterface
::
EXISTS_RENAME
);
// If not file entity, create associated element.
if
(
$file_temp
&&
$entity_type
!=
'file'
)
{
...
...
@@ -393,7 +400,7 @@ function __drush_exif_entity_import($entity_type, $type, $uid, $field, $file, $l
'revision'
=>
1
,
'status'
=>
TRUE
,
'promote'
=>
0
,
'created'
=>
REQUEST_TIME
,
'created'
=>
\Drupal
::
time
()
->
getRequestTime
()
,
'langcode'
=>
$langcode
,
$field
=>
[
'target_id'
=>
$file_temp
->
id
(),
...
...
@@ -413,7 +420,7 @@ function __drush_exif_entity_import($entity_type, $type, $uid, $field, $file, $l
'uid'
=>
$uid
,
'revision'
=>
1
,
'status'
=>
TRUE
,
'created'
=>
REQUEST_TIME
,
'created'
=>
\Drupal
::
time
()
->
getRequestTime
()
,
'langcode'
=>
$langcode
,
$field
=>
[
'target_id'
=>
$file_temp
->
id
(),
...
...
This diff is collapsed.
Click to expand it.
src/Controller/ExifSettingsController.php
+
3
−
3
View file @
b389f34c
...
...
@@ -87,7 +87,7 @@ class ExifSettingsController extends ControllerBase {
else
{
$message
=
$this
->
t
(
'The vocabulary photography is already created. nothing to do'
);
}
drupal_set_message
(
$message
);
$this
->
messenger
()
->
addStatus
(
$message
);
$response
=
new
RedirectResponse
(
'/admin/config/media/exif/helper'
);
$response
->
send
();
exit
();
...
...
@@ -156,7 +156,7 @@ class ExifSettingsController extends ControllerBase {
catch
(
FieldException
$fe
)
{
$message
=
$this
->
t
(
'An unexpected error was thrown during creation : '
)
.
$fe
->
getMessage
();
}
drupal_set_message
(
$message
);
$this
->
messenger
()
->
addStatus
(
$message
);
$response
=
new
RedirectResponse
(
'/admin/config/media/exif/helper'
);
$response
->
send
();
exit
();
...
...
@@ -230,7 +230,7 @@ class ExifSettingsController extends ControllerBase {
catch
(
FieldException
$fe
)
{
$message
=
$this
->
t
(
'An unexpected error was thrown during creation : '
)
.
$fe
->
getMessage
();
}
drupal_set_message
(
$message
);
$this
->
messenger
()
->
addStatus
(
$message
);
$response
=
new
RedirectResponse
(
'/admin/config/media/exif/helper'
);
$response
->
send
();
exit
();
...
...
This diff is collapsed.
Click to expand it.
src/ExifContent.php
+
4
−
2
View file @
b389f34c
...
...
@@ -2,6 +2,8 @@
namespace
Drupal\exif
;
use
Drupal\Core\File\FileSystemInterface
;
use
Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface
;
use
Drupal
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Component\Utility\Unicode
;
...
...
@@ -385,7 +387,7 @@ class ExifContent {
$cache_key
=
md5
(
$uri
);
if
(
empty
(
$this
->
localCopiesOfRemoteFiles
[
$cache_key
]))
{
// Create unique local file.
if
(
!
(
$this
->
localCopiesOfRemoteFiles
[
$cache_key
]
=
file_unmanaged_copy
(
$uri
,
'temporary://exif_'
.
$cache_key
.
'_'
.
basename
(
$uri
),
F
ILE_
EXISTS_REPLACE
)))
{
if
(
!
(
$this
->
localCopiesOfRemoteFiles
[
$cache_key
]
=
file_unmanaged_copy
(
$uri
,
'temporary://exif_'
.
$cache_key
.
'_'
.
basename
(
$uri
),
F
ileSystemInterface
::
EXISTS_REPLACE
)))
{
// Log error if creating a copy fails - but return an empty array to
// avoid type collision.
\Drupal
::
logger
(
'exif'
)
...
...
@@ -599,7 +601,7 @@ class ExifContent {
$date_datetime
=
DrupalDateTime
::
createFromFormat
(
$dateFormat
->
getPattern
(),
$exif_sanitized_value
);
// Load storage format.
$storage_format
=
$field
->
getFieldDefinition
()
->
getSetting
(
'datetime_type'
)
==
DateTimeItem
::
DATETIME_TYPE_DATE
?
D
ATETIME_
DATE_STORAGE_FORMAT
:
D
ATETIME_
DATETIME_STORAGE_FORMAT
;
->
getSetting
(
'datetime_type'
)
==
DateTimeItem
::
DATETIME_TYPE_DATE
?
D
ateTimeItemInterface
::
DATE_STORAGE_FORMAT
:
D
ateTimeItemInterface
::
DATETIME_STORAGE_FORMAT
;
// Format date to string for storage.
$value
=
$date_datetime
->
format
(
$storage_format
);
// Store value.
...
...
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