Skip to content
Snippets Groups Projects
Commit b389f34c authored by git's avatar git Committed by Damien McKenna
Browse files

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
......@@ -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, FILE_EXISTS_RENAME);
$file_temp = file_save_data($file_content, 'public://' . $title, FileSystemInterface::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(),
......
......@@ -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();
......
......@@ -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), FILE_EXISTS_REPLACE))) {
if (!($this->localCopiesOfRemoteFiles[$cache_key] = file_unmanaged_copy($uri, 'temporary://exif_' . $cache_key . '_' . basename($uri), FileSystemInterface::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 ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT;
->getSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE ? DateTimeItemInterface::DATE_STORAGE_FORMAT : DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
// Format date to string for storage.
$value = $date_datetime->format($storage_format);
// Store value.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment