Upgrading Drupal 7.43 to 8 error: Source database is Drupal version 8 but version 7 was selected

I am new to Drupal, but I am trying to upgrade a site with the version 7.43 to 8, flowing these steps: https://www.drupal.org/docs/8/upgrade/upgrade-using-web-browser

After installing the Migrate modules and defining the source site, I have the following error message:

Source database is Drupal version 8 but version 7 was selected.

In my old site’s database, the drupal_version table is empty.

Any help?

Drupal 8 Image moving to another location when entity update

I have an image field in my content type and when I upload image it will save to a location as expected. Now I want to move that saved image to another location when entity inserting or updating process. Can anyone help?

I tried using image->save($ newlocation) but when the entity loading it will give an error as can’t find source image.

Migrating Drupal 7 input formats to Drupal 8.6.x causes errors

I am trying to write custom migrations to migrate my Drupal 7 website to Drupal 8. I am currently using Drupal 8.6.7 and Drupal 7.61 for a copy of the production website.

So far I have set up the D8 website with composer (docroot is path/to/web) (https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies )

I have always used Drush for maintenance actions on the D7 site and I am using Drush 9 for most of the actions including the migrations on the D8 site.

I have installed the most relevant modules in the D8 site so that I can start the migration, most notably all the D8 equivalents of the modules I used in the text formats/filters as well as migrate_plus, migrate_tools and migrate_upgrade.

The migration files are generated with the Drush command:

drush @dev migrate-upgrade "$  LEGACYDB" "$  LEGACYURL" --configure-only --migration-prefix=osn_custom_ 

So far I have successfully migrated the users and their roles so I have some knowledge on how migrations work.

The problem I am currently working on is the migration of a custom content type called ‘classified’. This type has a default Drupal 7 body field and a field ‘field_image’. So quite ordinary.

When I use the default generated migration file, it looks like everything is migrated, but the text is not visible. After research I found this is caused by the fact that the input format is set to the D7 code (in my case 2 aka ‘full html’) while there is no filter code in D8 that is called ‘2’. (src: https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#d7_to_d8 ).

I decided that I might as well convert 2 to ‘basic html’ and use the D8 configuration and not migrate the D7 text filters at all.

I created a migration lookup plugin with a static map that converts all D7 codes to the preferred D8 code. It might work well, but I am running into the problem that I can’t get the migration plugin to work with the migration of the ‘classified’ migration configuration. So I decided to simplify it and set the format to a default value ‘basic_html’.

Here is what I tried in the migrate_plus.migration.osn_custom_d7_node_classified.yml The code snippets below only show the body configuration, because the other field configurations are generated with the drush command and not altered.

body: body 

the default. Content is migrated, input format is set to ‘2’.

According to this: https://www.drupal.org/docs/8/api/migrate-api/migrate-process-plugins/migrate-process-overview#nested

and this: https://medium.com/drupal-stories-an-insiders-view/migrate-api-custom-drupal-to-drupal-migration-3bab05da4686

and this: https://www.phase2technology.com/blog/drupal-8-migrations

it should be done like this:

  'body/format':      plugin: default_value     default_value: basic_html    'body/value': body 

However, this results in the following error:

[error]  InvalidArgumentException: Placeholders must have a trailing [] if they are to be expanded with an array of values. in Drupal\Core\Database\Connection->expandArguments() (line 729 of /Users/helma/Sites/OSND8/dev/web/core/lib/Drupal/Core/Database/Connection.php).  [error]  Placeholders must have a trailing [] if they are to be expanded with an array of values. (/Users/helma/Sites/OSND8/dev/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:783) 

I have no clue what is wrong and what I should do instead. I also don’t know how to debug this to find out what it’s expecting.

Can someone please give me some pointers?

How do I delete files attached with media entity in drupal 8.4.2?


drupal 8.4.2

custom media solution


I can not delete files permanently which created as media entity.


  1. Created an image media entity.
  2. /admin/content/files claims status permanent and used in 2 places.
  3. After deleting newly created media entity from UI /admin/content/media.
  4. /admin/content/files says status permanent and used in 1 places.

Even cron run after 6 hours (as described in file settings) file still exist on the server.

Is there any safest or best way to delete those unused file permanently?

preprocess function not running on theme drupal 8

I am trying to query my database and return a number to store in a twig template called node–course.html.twig

So I started by writing the function completionCheck() in class FormaRegis.php

<?php  namespace Drupal\docebo_login;  use Drupal\docebo_login\FormaEntity;   class FormaRegis extends FormaEntity {       public $  ID;    public function setID($  ID) {     $  this->ID = $  ID;   }    public function getID() {     return $  this->ID;   }      public function __construct() {         parent::__construct();     }    public function rowBase() {        if (parent::accessCheck()) {          $  sql = "SELECT * FROM learning_courseuser                   WHERE idUser = " . $  _SESSION['public_area_idst'] .                  " AND idCourse = " . $  this->ID. " ";         return $  sql;        } else {              return "";        }      }      public function completionCheck() {         $  check = false;           if (parent::accessCheck()) {             $  sql = "SELECT count(*) FROM learning_courseuser                     WHERE DATE_FORMAT(CURDATE(),'%d/%m/%Y') = DATE_FORMAT(date_complete,'%d/%m/%Y')                     AND idUser =  " . $  _SESSION['public_area_idst'];              return $  sql;           }           else {             return "";           }      }  } 

and in a page called FormaEntity.php I wrote this function

public function getCCresult() {    if ($  this->completionCheck() == "") {       \Drupal\Core\Database\Database::setActiveConnection();       return false;    }     $  result = $  this->connection->query($  this->completionCheck())->fetch();      \Drupal\Core\Database\Database::setActiveConnection();     if ($  result > 5 ) {      $  check = "fail";    }    else {      $  check = "pass";    }     return $  check; } 

Then in FormaNotification.php I wrote function completionCheck()

<?php  namespace Drupal\docebo_login;  use Drupal\docebo_login\FormaEntity;  class FormaNotification extends FormaEntity {      public function __construct() {         parent::__construct();     }      public function getResult() {           return parent::accessCheck();     }      public function completionCheck() {           return parent::getCCresult();     }  } 

Then finally, in my .theme file I added the function mytheme_preprocess_node_course(&$ variables)

function mytheme_preprocess_node_course (&$  variables) {    $  noti = new FormaNotification();    if ($  noti->completionCheck() == "fail") {       $  variables['creditCheck'] = "yes";   }   else {     $  variables['creditCheck'] = "no";   }  } 

But when I visit the any page that uses the node–course.html.twig and use {{ kint(creditCheck) }}, it says that the variable in NULL. I am not sure what I am doing wrong. If anyone can point me in the right direction that would be great.

get drupal 7 apachesolr module to work with solr 5.5

I upgraded my drupal apachesolr search module from 1.8 to 1.11 and I also upgrade the apachesolr version from version 4.10 to 5.5, and managed to upgrade the index folder so that it can be used for 5.5 solr search. But once I change the drupal apache solr URL to connect to the new 5.5 solr search, it ask me to reindex everything again. Is there a way to avoid this step?

Why drupal 7.63 update disabled my custom module?

I have a strange problem: I created custom module, named Media Track, that creates a field type. It worked fine since drupal 7.56 version. Now, I updated to drupal 7.63, all other modules I created are visible in module list, but this module disappeared. Field tuype is still in database, but is not active ’cause the module doesn’t exists in module list. The module as located in sites/all/modules. What can I try to do?