I've installed ip2country in a Drupal 8 site (think it's the latest dev: 8.x-1.8+2-dev).

When using drush to run Drupal updates, I get the following:

PHP Fatal error: Call to undefined function variable_del() in /var/www/site/docroot/modules/contrib/ip2country/ip2country.install on line 132

However, there is no update showing in the drush updb status. I think there is 2 issues here:

1) ip2country_update_8000 should have a different number, according to the docs:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...

2 digits for sequential counting, starting with 01. Note that the x000 number can never be used: the lowest update number that will be recognized and run for major version x is x001.

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...

2) variable_del has been removed in Drupal 8, so should be replaced.

This seems to be converting variables from D7 to D8. Does this need to be done in a different way?

Comments

smaz created an issue. See original summary.

tr’s picture

That entire update should be removed - Drupal no longer uses hook_update_N() to update between major versions, so update.php and drush updb are almost obsolete. (The Migrate module and other related modules are used instead, and there is support for those in ip2country). I removed that entire update hook locally a long time ago but never pushed the change - I'll try to commit some pending changes like this in the next few days.

ramdas gaikar’s picture

Hi smaz,

The patch is attached for the above issue.

ramdas gaikar’s picture

Status: Active » Needs review
tr’s picture

Status: Needs review » Active

No, the patch in #3 is just wrong, don't use it. Those aren't state variables, they're configuration variables. As I said in #2, the whole update 8000 function just needs to be removed, and I've already done this locally so a patch here won't be considered.

matsbla’s picture

StatusFileSize
new49.26 KB

I just made an install of ip2country on Drupal 8..1.10 some few days ago, and now tried to update to Drupal 8.2 - I still get warning that it is not possible to update!

matsbla’s picture

StatusFileSize
new1.87 KB

Patch to remove update 8000 function

matsbla’s picture

Status: Active » Needs review
StatusFileSize
new1.87 KB
matsbla’s picture

Priority: Normal » Critical
StatusFileSize
new25.75 KB

Currently it is not possible to upgrade to Drupal 8.2 because of this bug, so increase priority to critical.

vlad.dancer’s picture

Status: Needs review » Reviewed & tested by the community

+1 RTBC.
Installed drupal 8.2, installed ip2country, applied the patch from #8, run drush updb - result no updates as designed.

shreya shetty’s picture

May be we should use Drupal::config() instead of Drupal::state() .Refer this State Api is only used when you dont want your configuration to travel between instances

shreya shetty’s picture

StatusFileSize
new2.14 KB
sdstyles’s picture

Status: Reviewed & tested by the community » Needs work

Installing module this error is thrown Call to undefined function update_variables_to_config()

vlad.dancer’s picture

@sdstyles, have you done this steps:

Installed drupal 8.2, installed ip2country, applied the patch from #8, run drush updb - result no updates as designed.

alex.bukach’s picture

Status: Needs work » Reviewed & tested by the community

+1 RTBC for #8.

@Shreya As mentioned above, "That entire update should be removed". Why do you think it we might need that values to travel between the sites?

@sdstyles I believe there's something wrong, the patch #8 removes call to update_variables_to_config(), so you cannot get the error mentioned.

sdstyles’s picture

StatusFileSize
new2.54 KB

Yes, I removed the hook_update_8001() to get ride of this error.
Seems those hook updates were intended to be an upgrade path from 7.x to 8.x in development process, the second hook_update is also useless so I removed it too.
See the patch that I used.

shaisamuel’s picture

Can #8 be committed and updated to a new version? It's been ages since an update...

tr’s picture

Version: 8.x-1.8 » 8.x-1.x-dev
Status: Reviewed & tested by the community » Fixed

The obsolete hook_update_N() functions have been commented out pending #2917888: Create migration templates. When that issue is resolved they will be removed completely.

  • TR committed 8926938 on 8.x-1.x
    Issue #2729983: Remove obsolete hook_update_N() functions.
    

  • TR committed a134759 on 8.x-1.x
    Issue #2729983: Remove obsolete hook_update_N() functions.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ker688@gmail.com’s picture

I have same issue now, why not release a new version before that pending issue resolved?

gogowitsch’s picture

I use Composer. To follow a best practice, I used the --prefer-stable option and moved away from using the dev version.

Unfortunately, that lead me to the ^1.8 version constraint and thus to this issue. I second comment #22: Please release a new version. Thanks!

zetxek’s picture

2019 and this keeps on causing issues...

turpentyne’s picture

I too am running into this issue. I have just updated Drupal to 8.7.10, using composer. I have IP2Country installed, version 8.x-1.8

Due to some server limitations, I'm trying to update modules via the admin panel. When I do database update, I get an error:

Message
Error: Call to undefined function variable_del() in ip2country_update_8000() (line 132 of /var/lib/nginx/sitename/web/modules/ip2country/ip2country.install) #0 /var/lib/nginx/sitename/web/core/includes/update.inc(183): ip2country_update_8000(Array) #1 /var/lib/nginx/sitename/web/core/includes/batch.inc(295): update_do_one('ip2country', 8000, Array, Array) #2 /var/lib/nginx/sitename/web/core/includes/batch.inc(137): _batch_process() #3 /var/lib/nginx/sitename/web/core/includes/batch.inc(93): _batch_do() #4 /var/lib/nginx/sitename/web/core/modules/system/src/Controller/DbUpdateController.php(186): _batch_page(Object(Symfony\Component\HttpFoundation\Request)) #5 [internal function]: Drupal\system\Controller\DbUpdateController->handle('start', Object(Symfony\Component\HttpFoundation\Request)) #6 /var/lib/nginx/sitename/web/core/lib/Drupal/Core/Update/UpdateKernel.php(115): call_user_func_array(Array, Array) #7 /var/lib/nginx/sitename/web/core/lib/Drupal/Core/Update/UpdateKernel.php(76): Drupal\Core\Update\UpdateKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request)) #8 /var/lib/nginx/sitename/web/update.php(28): Drupal\Core\Update\UpdateKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #9 {main}.

smaz’s picture

For those having issues & using composer, you could apply the patch from #16 via composer:
https://github.com/cweagans/composer-patches#usage