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?
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 2729983-16.patch | 2.54 KB | sdstyles |
| #9 | Screenshot from 2016-10-05 17-50-12.png | 25.75 KB | matsbla |
| #8 | 2729983-remove-update-8000.patch | 1.87 KB | matsbla |
| #6 | Screenshot from 2016-10-05 17-35-20.png | 49.26 KB | matsbla |
| #3 | ip2country_update_8000_causing_issues_with_Drupal_upgrades-2729983-3.patch | 1.94 KB | ramdas gaikar |
Comments
Comment #2
tr commentedThat 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.
Comment #3
ramdas gaikar commentedHi smaz,
The patch is attached for the above issue.
Comment #4
ramdas gaikar commentedComment #5
tr commentedNo, 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.
Comment #6
matsbla commentedI 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!
Comment #7
matsbla commentedPatch to remove update 8000 function
Comment #8
matsbla commentedComment #9
matsbla commentedCurrently it is not possible to upgrade to Drupal 8.2 because of this bug, so increase priority to critical.
Comment #10
vlad.dancer+1 RTBC.
Installed drupal 8.2, installed ip2country, applied the patch from #8, run drush updb - result no updates as designed.
Comment #11
shreya shetty commentedMay 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
Comment #12
shreya shetty commentedComment #13
sdstyles commentedInstalling module this error is thrown
Call to undefined function update_variables_to_config()Comment #14
vlad.dancer@sdstyles, have you done this steps:
Comment #15
alex.bukach commented+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.Comment #16
sdstyles commentedYes, 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.
Comment #17
shaisamuel commentedCan #8 be committed and updated to a new version? It's been ages since an update...
Comment #18
tr commentedThe obsolete hook_update_N() functions have been commented out pending #2917888: Create migration templates. When that issue is resolved they will be removed completely.
Comment #22
ker688@gmail.com commentedI have same issue now, why not release a new version before that pending issue resolved?
Comment #23
gogowitsch commentedI use Composer. To follow a best practice, I used the
--prefer-stableoption 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!
Comment #24
zetxek commented2019 and this keeps on causing issues...
Comment #25
turpentyne commentedI 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}.
Comment #26
smazFor those having issues & using composer, you could apply the patch from #16 via composer:
https://github.com/cweagans/composer-patches#usage