On D9.3 and have recently updated to Metatag 8.x-1.18 and have just started to get this error.

Notice: Trying to get property 'build_info' of non-object in Drupal\views\Plugin\views\cache\CachePluginBase->generateResultsKey() (line 199 of /home/XXXXX/public_html/core/modules/views/src/Plugin/views/cache/CachePluginBase.php)

Followed by:

Error: Call to a member function getCurrentPage() on null in Drupal\views\Plugin\views\cache\CachePluginBase->generateResultsKey() (line 220 of /home/XXXXX/public_html/core/modules/views/src/Plugin/views/cache/CachePluginBase.php)

No idea what has caused this but started happening post Metatag module upgrade.

Issue is that Views no longer displays any preview result output.

Comments

Stephen Ollman created an issue. See original summary.

stephen ollman’s picture

Title: View preview broken after Mteatag upgrade » View preview broken after Metatag upgrade
stephen ollman’s picture

Ok uninstalling 'Metatag Views' resolves my issue and views preview returns.

I re-installed 'Metatag Views' and it broke again, so the problem certainly lies with this module.

stephen ollman’s picture

Issue summary: View changes
Iker Pérez’s picture

Had the same problem upgrading yesterday and only got it back working downgrading to version 1.16, so I believe the error was introduced in version 1.17.

eugene bocharov’s picture

I see the problem too. On views preview the \Drupal\views\Plugin\views\cache\None plugin is used and it doesn't contain view object.
I'd suggest to not wrap 'none' cache plugin at all in the \Drupal\metatag_views\MetatagViewsCachePluginManager.
Something like this

  public function createInstance($plugin_id, array $configuration = []) {
    $plugin = $this->viewsPluginManager->createInstance($plugin_id, $configuration);
    return $plugin_id === 'none' ? $plugin : $this->wrap($plugin);
  }
eugene bocharov’s picture

Version: 8.x-1.18 » 8.x-1.x-dev
Status: Active » Needs review
oxy86’s picture

Same problem here on D9.3 and Metatag 1.18 when Metatag Views submodule is installed. Uninstalling the submodule or downgrading to 1.6 solves the problem. I will test the patch in #6 and report back.

oxy86’s picture

Hello, the patch from #6 solved the problem for me (Drupal 9.3 with Metatag 1.18 and metatag_views enabled). Thanks, Eugene!

thomas kaisuka’s picture

StatusFileSize
new186.8 KB

Same here, uninstalling the metatag_views sub module solved the issue. Optionally to avoid losing configurations, just downgrade to version1.16.

Using Drupal 9.3

matthijs’s picture

Status: Needs review » Reviewed & tested by the community

Seems to work fine, thx!

glynster’s picture

@Eugene Bocharov patch works and resolves the issue RTBC +1 using Drupal 9.3

glynster’s picture

Seems I spoke a little too soon. We are getting WOD on view pages:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function __wakeup() on null in Drupal\metatag_views\MetatagViewsCacheWrapper->__wakeup() (line 398 of modules/contrib/metatag/metatag_views/src/MetatagViewsCacheWrapper.php).

If I force clear the cache it works and then refresh it breaks again.

Once I uninstall metatag_views the issue goes away.

Using Drupal 9.3

mahmoud barhouma’s picture

#6 patch resolved problem

eugene bocharov’s picture

Thank you @glynster for testing. Obviously, getInstance() should be modified as well to avoid the problem on wakeup. Can you try this patch?

wells’s picture

Patch in #15 resolves the issue for me as well, including for views data cached into and retrieved from memcache (i.e., using __sleep and __wakeup).

ahmad abbad’s picture

As #13 mentioned there's an issue with metatag_views

The website encountered an unexpected error. Please try again later.
Error: Call to a member function __wakeup() on null in Drupal\metatag_views\MetatagViewsCacheWrapper->__wakeup() (line 398 of modules/contrib/metatag/metatag_views/src/MetatagViewsCacheWrapper.php).
oxy86’s picture

Patch in #15 resolved the issue for me as well (Drupal 9.3, metatag 8.x-1.18 with Metatag: Views enabled).

eugene bocharov’s picture

Just hiding #6 patch to avoid confusing, as it cause a problem at wakeup. #15 should be used instead.

glynster’s picture

@Eugene Bocharov confirmed your new patch #15 works like a charm using Drupal 9.3! RTBC +1

glynster’s picture

@Eugene Bocharov seems there is still an issue:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function __wakeup() on null in Drupal\metatag_views\MetatagViewsCacheWrapper->__wakeup() (line 398 of modules/contrib/metatag/metatag_views/src/MetatagViewsCacheWrapper.php).
eugene bocharov’s picture

I think the problem on wakeup is another issue with MetatagViewsCacheWrapper, not related to borken preview, that we try to solve here. Patch #15 prevents using of wrapper MetatagViewsCacheWrapper on none cache plugin. So it can't lead to the error in MetatagViewsCacheWrapper which is not used on preview.

In the other hand, if we'll take a look at the MetatagViewsCacheWrapper::__sleep()

  /**
   * {@inheritdoc}
   */
  public function __sleep() {
    return $this->plugin->__sleep();
  }

we can see, that property MetatagViewsCacheWrapper::plugin woun't be saved during serialization because of the fact that wrapping plugin $this->plugin obviously doesn't have property $plugin. And therefore it doesn't exist on wakeup. I suppose that __sleep and __wakeup should be removed from MetatagViewsCacheWrapper, then it will use ones from DependencySerializationTrait.
But we probably need a separate issue to target this issue.

damienmckenna’s picture

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you all.

Anonymous’s picture

I found this thread when seeking out a resolution to the problem I was having with Watchdog.

1. A page refresh would no longer update the list of Watchdog entries. It would typically need me to clear the cache before the most recent entries would be shown in the view.
2. The ability to delete all Watchdog entries was broken - I could click on Delete, then on Confirm, but the entries would not be removed from the view. However, they would be removed if I then cleared the cache.

After uninstalling the Metatag Views module the Watchdog view is back working as expected.

I've not installed the dev release yet, but hopefully the patch in that will also resolve the above issues.

wells’s picture

@Janner interesting... I started noticing that behavior in the watchdog view recently as well but hadn't made the connection. It is always resolved for me with a cache rebuild though and I can't reliably reproduce it. Are you able to reproduce or does it happen (seemingly) randomly?

Anonymous’s picture

The issue with the Watchdog entries was consistent for me. It took either a manual cache clear or the regular cron to make newer entries appear or the deleted ones to be removed.

I see that an issue with a view created by the Simplenews module has also been linked with this issue here, so it's possible that the reach may be greater than is already realised.

See https://www.drupal.org/project/simplenews/issues/3255498

Anonymous’s picture

oxy86’s picture

I've also noticed the same problem in the watchdog view (deleted log entries kept appearing until a manual drush cr) but could not imagine there is a connection with this issue of Metatag Views 8.x-1.18.
After applying the patch in #15, the issue has been resolved and the watchdog view works as expected.
I agree with @Janner about the potential reach of this issue. This strange watchdog behavior shows that it's not about broken view preview only.

ansam dweik’s picture

Thanks, Patch #15 solved my problem.

Anonymous’s picture

Title: View preview broken after Metatag upgrade » Metatag Views breaks Views previews and some Views pages
Version: 8.x-1.x-dev » 8.x-1.18
Priority: Normal » Major
baltazarz3’s picture

Confirmed, patch #15 solved the problem. My watchdog table was broken too, just like #30.

damienmckenna’s picture

So is this working correctly for everyone with the current dev release or are there still problems? Besides the Search API problem.

wells’s picture

Previews and watchdog are working normally for me from the dev release.

damienmckenna’s picture

Excellent, thank you.

selinav’s picture

Thank you patch #15 works.

_renify_’s picture

It works when im using this code

public function createInstance($plugin_id, array $configuration = []) {
    return $this->viewsPluginManager->createInstance($plugin_id, $configuration);
  }

public function getInstance(array $options) {
    /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $plugin */
    return $this->viewsPluginManager->getInstance($options);
  }
damienmckenna’s picture

This fix was released in 8.x-1.19, please update your sites accordingly. If you are still having problems with Views please open a new issue. Thank you.

Status: Fixed » Closed (fixed)

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