Skip to main content
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

This question is a follow-on from this one about creating managed filescreating managed files. If you look at the question in the link, you'll see that I am writing a drush command to detect all the inline-images in a just-migrated Drupal 8 system, and add them into Drupal as managed images attached to the relevant nodes. To cut a long story short, this bit of code takes the existing file name and creates an entry in Drupal:

$file = entity_create('file'); $file->setFilename($file_name); $file->setFileUri('public://images/'.$file_name); $file->save(); 

This works fine, except that it very irritatingly displays this error message with every file: Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter).uri: The file <em class="placeholder">public://images/rint135_graph4_0.articleimage.PNG</em> already exists. Enter a unique file URI.

Of course the file exists! That is precisely the point! Despite the error message everything seems to work ok, but I would really like to get rid of those error messages. I guess that they are being set by drupal_set_message(), since they include HTML which of course is pointless in drush - but I can't find any way to switch them off.

This question is a follow-on from this one about creating managed files. If you look at the question in the link, you'll see that I am writing a drush command to detect all the inline-images in a just-migrated Drupal 8 system, and add them into Drupal as managed images attached to the relevant nodes. To cut a long story short, this bit of code takes the existing file name and creates an entry in Drupal:

$file = entity_create('file'); $file->setFilename($file_name); $file->setFileUri('public://images/'.$file_name); $file->save(); 

This works fine, except that it very irritatingly displays this error message with every file: Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter).uri: The file <em class="placeholder">public://images/rint135_graph4_0.articleimage.PNG</em> already exists. Enter a unique file URI.

Of course the file exists! That is precisely the point! Despite the error message everything seems to work ok, but I would really like to get rid of those error messages. I guess that they are being set by drupal_set_message(), since they include HTML which of course is pointless in drush - but I can't find any way to switch them off.

This question is a follow-on from this one about creating managed files. If you look at the question in the link, you'll see that I am writing a drush command to detect all the inline-images in a just-migrated Drupal 8 system, and add them into Drupal as managed images attached to the relevant nodes. To cut a long story short, this bit of code takes the existing file name and creates an entry in Drupal:

$file = entity_create('file'); $file->setFilename($file_name); $file->setFileUri('public://images/'.$file_name); $file->save(); 

This works fine, except that it very irritatingly displays this error message with every file: Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter).uri: The file <em class="placeholder">public://images/rint135_graph4_0.articleimage.PNG</em> already exists. Enter a unique file URI.

Of course the file exists! That is precisely the point! Despite the error message everything seems to work ok, but I would really like to get rid of those error messages. I guess that they are being set by drupal_set_message(), since they include HTML which of course is pointless in drush - but I can't find any way to switch them off.

Error message was incomplete
Source Link

This question is a follow-on from this one about creating managed files. If you look at the question in the link, you'll see that I am writing a drush command to detect all the inline-images in a just-migrated Drupal 8 system, and add them into Drupal as managed images attached to the relevant nodes. To cut a long story short, this bit of code takes the existing file name and creates an entry in Drupal:

$file = entity_create('file'); $file->setFilename($file_name); $file->setFileUri('public://images/'.$file_name); $file->save(); 

This works fine, except that it very irritatingly displays this error message with every file: Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter).uri: The file <em class="placeholder">public://images/rint135_graph4_0.articleimage.PNG</em> already exists. Enter a unique file URI.

Of course the file exists! That is precisely the point! Despite the error message everything seems to work ok, but I would really like to get rid of those error messages. I guess that they are being set by drupal_set_message(), since they include HTML which of course is pointless in drush - but I can't find any way to switch them off.

This question is a follow-on from this one about creating managed files. If you look at the question in the link, you'll see that I am writing a drush command to detect all the inline-images in a just-migrated Drupal 8 system, and add them into Drupal as managed images attached to the relevant nodes. To cut a long story short, this bit of code takes the existing file name and creates an entry in Drupal:

$file = entity_create('file'); $file->setFilename($file_name); $file->setFileUri('public://images/'.$file_name); $file->save(); 

This works fine, except that it very irritatingly displays this error message with every file: The file <em class="placeholder">public://images/rint135_graph4_0.articleimage.PNG</em> already exists. Enter a unique file URI.

Of course the file exists! That is precisely the point! Despite the error message everything seems to work ok, but I would really like to get rid of those error messages. I guess that they are being set by drupal_set_message(), since they include HTML which of course is pointless in drush - but I can't find any way to switch them off.

This question is a follow-on from this one about creating managed files. If you look at the question in the link, you'll see that I am writing a drush command to detect all the inline-images in a just-migrated Drupal 8 system, and add them into Drupal as managed images attached to the relevant nodes. To cut a long story short, this bit of code takes the existing file name and creates an entry in Drupal:

$file = entity_create('file'); $file->setFilename($file_name); $file->setFileUri('public://images/'.$file_name); $file->save(); 

This works fine, except that it very irritatingly displays this error message with every file: Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter).uri: The file <em class="placeholder">public://images/rint135_graph4_0.articleimage.PNG</em> already exists. Enter a unique file URI.

Of course the file exists! That is precisely the point! Despite the error message everything seems to work ok, but I would really like to get rid of those error messages. I guess that they are being set by drupal_set_message(), since they include HTML which of course is pointless in drush - but I can't find any way to switch them off.

Source Link

How to stop drush displaying a Drupal error message?

This question is a follow-on from this one about creating managed files. If you look at the question in the link, you'll see that I am writing a drush command to detect all the inline-images in a just-migrated Drupal 8 system, and add them into Drupal as managed images attached to the relevant nodes. To cut a long story short, this bit of code takes the existing file name and creates an entry in Drupal:

$file = entity_create('file'); $file->setFilename($file_name); $file->setFileUri('public://images/'.$file_name); $file->save(); 

This works fine, except that it very irritatingly displays this error message with every file: The file <em class="placeholder">public://images/rint135_graph4_0.articleimage.PNG</em> already exists. Enter a unique file URI.

Of course the file exists! That is precisely the point! Despite the error message everything seems to work ok, but I would really like to get rid of those error messages. I guess that they are being set by drupal_set_message(), since they include HTML which of course is pointless in drush - but I can't find any way to switch them off.