Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading from D7 throws PHP notices on update.php #95

Closed
quicksketch opened this issue Aug 8, 2022 · 6 comments · Fixed by #96 or #107
Closed

Upgrading from D7 throws PHP notices on update.php #95

quicksketch opened this issue Aug 8, 2022 · 6 comments · Fixed by #96 or #107

Comments

@quicksketch
Copy link
Member

When upgrading from Drupal 7, Metatag module throws a PHP notice when it tries to load metatag.settings config before values are defined.

Warning: array_filter() expects parameter 1 to be array, null given in metatag_get_info() (line 2030 of /var/www/html/web/modules/contrib/metatag/metatag.module).

image

@quicksketch
Copy link
Member Author

I filed a PR at #96 that prevents metatag from modifying install.php and update.php pages. This seems like it's a good idea because update.php can easily have situations where metatag's settings aren't as expected, not only when updating from Drupal 7 but even updates for metatag if we were to ever refactor the metatag.settings.json organization.

@quicksketch
Copy link
Member Author

I found this error can still occur because metatag_get_info() can be called from metatag_permission_info(), or other hooks that might accidentally be invoked during an update hook.

@laryn
Copy link
Member

laryn commented Nov 15, 2022

I am seeing this on an attempt to upgrade a D7 site as well:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows.
Path: https://app/core/update.php?op=selection&token=etc&id=12836&op=do_nojs&op=do StatusText:
Internal Server Error
ResponseText: TypeError: array_filter(): Argument #1 ($array) must be of type array, null given in array_filter()
(line 2036 of /app/backdrop/modules/metatag/metatag.module).

Temporary workaround is to split line 2036 up from this:

$enabled_tags = array_filter(config_get('metatag.settings', 'enabled_tags'));

to this:

$enabled_tags = config_get('metatag.settings', 'enabled_tags');
if (is_array($enabled_tags)) {
  $enabled_tags = array_filter($enabled_tags);
}
else {
  $enabled_tags = array();
}      

@herbdool
Copy link
Contributor

herbdool commented Dec 9, 2022

Just saw this too on a dry run. I did something similar:

$enabled_tags_config = config_get('metatag.settings', 'enabled_tags');
$enabled_tags = is_array($enabled_tags_config) ? array_filter($enabled_tags_config) : [];

Probably makes sense to make this permanent since even regularly can't assume the variable is an array.

@herbdool
Copy link
Contributor

I added a second PR. Perhaps both could be useful? @quicksketch

@mazzech
Copy link

mazzech commented Dec 26, 2022

I am trying to update from 1.x-1.22.1 to 1.x-1.22.2 (or later, same effect). The site was never a Drupal site, but a vanilla Backdrop installation back then.

After the update I loose all my configuration, and can't add new settings per Content type or whatever entity. I wonder if this is the same mistake as for the D7 upgrade....?

BTW, unistalling/reinstall the modulel solves the problem, but I loose the all the site's meta content entered by an SEO specialist.

[UPDATE 07012023] The conflict was because of an incompatibility with an older i18n module version, in the meantime I could upgrade without loosing the content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants