There were a lot of database updated when upgrading to 8.4.
All the other updates ran fine, just this one won't run.

azer@wxcv:~/azer/qsdf/staging/webroot$ drush updb
The following updates are pending: 

views module :
Fix table names for revision metadata fields.

Do you wish to run all pending updates? (y/n): y                              
Error: Call to a member function getConfigDependencyKey() on null in /var/www/openupmedia/qsdf/staging/webroot/core/modules/user/src/Plugin/views/filter/Roles.php on line 82 #0 /var/www/openupmedia/qsdf/staging/webroot/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php(47): Drupal\user\Plugin\views\filter\Roles->calculateDependencies()                                                  
#1 [internal function]: Drupal\views\Plugin\views\display\DisplayPluginBase->calculatePluginDependencies(Object(Drupal\user\Plugin\views\filter\Roles), 8)  
#2 /var/www/openupmedia/qsdf/staging/webroot/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php(961): array_walk(Array, Array)               
#3 /var/www/openupmedia/qsdf/staging/webroot/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php(47): Drupal\views\Plugin\views\display\DisplayPluginBase->calculateDependencies()                                                      
#4 /var/www/openupmedia/qsdf/staging/webroot/core/modules/views/src/Entity/View.php(281): Drupal\Core\Config\Entity\ConfigEntityBase->calculatePluginDependencies(Object(Drupal\views\Plugin\views\display\DefaultDisplay))               
#5 /var/www/openupmedia/qsdf/staging/webroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(346): Drupal\views\Entity\View->calculateDependencies()
#6 /var/www/openupmedia/qsdf/staging/webroot/core/modules/views/src/Entity/View.php(291): Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage))                                      
#7 /var/www/openupmedia/qsdf/staging/webroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(434): Drupal\views\Entity\View->preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage))                                             
#8 /var/www/openupmedia/qsdf/staging/webroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(389): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\views\Entity\View))                                                    
#9 /var/www/openupmedia/qsdf/staging/webroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(259): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\views\Entity\View))                                                
#10 /var/www/openupmedia/qsdf/staging/webroot/core/lib/Drupal/Core/Entity/Entity.php(377): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\views\Entity\View))                                                          
#11 /var/www/openupmedia/qsdf/staging/webroot/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(637): Drupal\Core\Entity\Entity->save()               
#12 /var/www/openupmedia/qsdf/staging/webroot/core/modules/views/views.post_update.php(213): Drupal\Core\Config\Entity\ConfigEntityBase->save()             
#13 [internal function]: {closure}(Object(Drupal\views\Entity\View), 'crm_manager_use...')                                                                  
#14 /var/www/openupmedia/qsdf/staging/webroot/core/modules/views/views.post_update.php(214): array_walk(Array, Object(Closure))                             
#15 /var/www/openupmedia/qsdf/staging/webroot/core/includes/update.inc(241): views_post_update_revision_metadata_fields(Array)                              
#16 phar:///usr/local/bin/drush/commands/core/drupal/batch.inc(163): update_invoke_post_update('views_post_upda...', Object(DrushBatchContext))             
#17 phar:///usr/local/bin/drush/commands/core/drupal/batch.inc(111): _drush_batch_worker()                                                                  
#18 phar:///usr/local/bin/drush/includes/batch.inc(98): _drush_batch_command('1005')                                                                        
#19 phar:///usr/local/bin/drush/commands/core/drupal/update.inc(193): drush_batch_command('1005')
#20 phar:///usr/local/bin/drush/commands/core/core.drush.inc(1227): _update_batch_command('1005')                                                           
#21 phar:///usr/local/bin/drush/includes/command.inc(422): drush_core_updatedb_batch_process('1005')                                                        
#22 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)                                                                
#23 phar:///usr/local/bin/drush/includes/command.inc(199): drush_command('1005')                                                                            
#24 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)                                                                      
#25 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()                                                   
#26 phar:///usr/local/bin/drush/includes/startup.inc(458): drush_main()       
#27 phar:///usr/local/bin/drush/includes/startup.inc(365): drush_run_main(false, '/', 'Phar detected. ...')                                                 
#28 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)              
#29 /usr/local/bin/drush(10): require('phar:///usr/loc...')                   
#30 {main}  
CommentFileSizeAuthor
#57 interdiff-pre-8.8.txt926 bytestedbow
#57 2917006-57-pre-8.8.patch2.46 KBtedbow
#57 2917006-57.patch2.49 KBtedbow
#57 interdiff-55-57.txt735 bytestedbow
#55 interdiff-51-55.txt1.65 KBtedbow
#55 2917006-55-test-only.patch1.6 KBtedbow
#55 2917006-55.patch2.49 KBtedbow
#52 2917006-51.patch2.4 KBWim Leers
#52 2917006-51-test_only_FAIL.patch1.5 KBWim Leers
#51 2917006-51.patch2.4 KBtedbow
#51 interdiff-42-51.txt2.29 KBtedbow
#50 views-update-2917006-50.patch1.13 KBsam-elayyoub
#46 views-update-2917006-46.patch2.74 KBsam-elayyoub
#42 interdiff-42.txt704 bytesamateescu
#42 2917006-42.patch907 bytesamateescu
#36 2917006-36.patch726 bytesamateescu
#31 views-update-2917006-8.5.x.patch745 bytesPascal-
#5 2917006-8.4.x.patch745 bytesamateescu
#3 2917006.patch726 bytesamateescu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jodan created an issue. See original summary.

cilefen’s picture

Component: database system » views.module
Priority: Normal » Major
Issue tags: +8.4.0 update
amateescu’s picture

Version: 8.4.0 » 8.4.x-dev
Status: Active » Needs review
FileSize
726 bytes

This patch should help with that error, but the actual problem in your case is that you have view with an (somewhat broken) outdated configuration, meaning that one of its filters is set to use a role that doesn't exist anymore.

Status: Needs review » Needs work

The last submitted patch, 3: 2917006.patch, failed testing. View results

amateescu’s picture

Status: Needs work » Needs review
FileSize
745 bytes

Here's a patch that applies to 8.4.x, the one above was for 8.5.x.

Pascal-’s picture

patch in #5 solved it, thx!

just noticed my views overview was no longer working, but it's working again after applying the patch

jnimchuk’s picture

I have the same/similar issue. But I updated with Update.php not Drush.

Please see: https://www.drupal.org/node/2916612

amateescu’s picture

@jnimchuk, does the patch from #5 work for you as well?

jnimchuk’s picture

Sorry, but the patch doesn't work for me. Here's the message from my log:

Notice: Undefined offset: 1 in Drupal\system\Controller\DbUpdateController->results() (line 413 of /var/www/vhosts/thejdngroup.com/domains/test8.portrevolt.com/core/modules/system/src/Controller/DbUpdateController.php) #0 /var/www/vhosts/thejdngroup.com/domains/test8.portrevolt.com/core/includes/bootstrap.inc(566): _drupal_error_handler_real(8, 'Undefined offse...', '/var/www/vhosts...', 413, Array) #1 /var/www/vhosts/thejdngroup.com/domains/test8.portrevolt.com/core/modules/system/src/Controller/DbUpdateController.php(413): _drupal_error_handler(8, 'Undefined offse...', '/var/www/vhosts...', 413, Array) #2 /var/www/vhosts/thejdngroup.com/domains/test8.portrevolt.com/core/modules/system/src/Controller/DbUpdateController.php(179): Drupal\system\Controller\DbUpdateController->results(Object(Symfony\Component\HttpFoundation\Request)) #3 [internal function]: Drupal\system\Controller\DbUpdateController->handle('results', Object(Symfony\Component\HttpFoundation\Request)) #4 /var/www/vhosts/thejdngroup.com/domains/test8.portrevolt.com/core/lib/Drupal/Core/Update/UpdateKernel.php(110): call_user_func_array(Array, Array) #5 /var/www/vhosts/thejdngroup.com/domains/test8.portrevolt.com/core/lib/Drupal/Core/Update/UpdateKernel.php(73): Drupal\Core\Update\UpdateKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request)) #6 /var/www/vhosts/thejdngroup.com/domains/test8.portrevolt.com/update.php(28): Drupal\Core\Update\UpdateKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #7 {main}.

Pascal-’s picture

patch in #5 fails on my staging and live database, although it worked on my local environment

tried manually saving all my views, which was successful, but doesn't solve the drush updb error
everything does seem to be working, except that I keep getting the error in the first post when doing an updb

kruser’s picture

The patch in #5 didn't have an effect on the error for me either. Looks like I have the same error as #9

Notice: Undefined offset: 1 in Drupal\system\Controller\DbUpdateController->results() (line 413 of /home/www/public_html/core/modules/system/src/Controller/DbUpdateController.php) #0 /home/www/public_html/core/includes/bootstrap.inc(566): _drupal_error_handler_real(8, 'Undefined offse...', '/home/www...', 413, Array) #1 /home/www/public_html/core/modules/system/src/Controller/DbUpdateController.php(413): _drupal_error_handler(8, 'Undefined offse...', '/home/www...', 413, Array) #2 /home/www/public_html/core/modules/system/src/Controller/DbUpdateController.php(179): Drupal\system\Controller\DbUpdateController->results(Object(Symfony\Component\HttpFoundation\Request)) #3 [internal function]: Drupal\system\Controller\DbUpdateController->handle('results', Object(Symfony\Component\HttpFoundation\Request)) #4 /home/www/public_html/core/lib/Drupal/Core/Update/UpdateKernel.php(110): call_user_func_array(Array, Array) #5 /home/www/public_html/core/lib/Drupal/Core/Update/UpdateKernel.php(73): Drupal\Core\Update\UpdateKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request)) #6 /home/www/public_html/update.php(28): Drupal\Core\Update\UpdateKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #7 {main}.
jnimchuk’s picture

Any update on this issue?

Anonymous’s picture

Hi there,

I had this error as well, the issue was a view with a "Missing / broken handler" on some filter.

I found out by updating the function "views_post_update_revision_metadata_fields" in the core views module (File views.post_update.php) to print the current view details when it breaks. (Don't forget to revert your changes if you try).

/**
 * Fix table names for revision metadata fields.
 */
function views_post_update_revision_metadata_fields() {
  // The table names are fixed automatically in
  // \Drupal\views\Entity\View::preSave(), so we just need to re-save all views.
  $views = View::loadMultiple();
  array_walk($views, function (View $view) {
    try {
      $view->save();
    } catch (Exception $e) {
      echo $e->getMessage();
      print_r($view);
    }
  });
}

Hope it will helps,

Cheers

maxilein’s picture

Hi,

what do I do about a Missing / broken handler?
How d I fix that?

tajinder.minhas’s picture

Hi maxilein,

Can you please describe the view on which you are facing such issue. I am not able to replicate this issue on my local, which doing the update.

jnimchuk’s picture

For me the view is failing to update for:

views_post_update_revision_metadata_fields.module

See my previous post #9.

maxilein’s picture

1 pending update
views module

Fix table names for revision metadata fields.

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /update.php/start?id=233&op=do_nojs&op=do
StatusText: Internal Server Error
ResponseText:

The update process was aborted prematurely while running update # in views_post_update_revision_metadata_fields.module. All errors have been logged. You may need to check the watchdog database table manually.

Notice: Undefined offset: 1 in Drupal\system\Controller\DbUpdateController->results() (line 413 of //../web/content/core/modules/system/src/Controller/DbUpdateController.php)
#0 //../web/content/core/includes/bootstrap.inc(566): _drupal_error_handler_real(8, 'Undefined offse...', '/...', 413, Array)
#1 //../web/content/core/modules/system/src/Controller/DbUpdateController.php(413): _drupal_error_handler(8, 'Undefined offse...', '/...', 413, Array)
#2 //../web/content/core/modules/system/src/Controller/DbUpdateController.php(179): Drupal\system\Controller\DbUpdateController->results(Object(Symfony\Component\HttpFoundation\Request))
#3 [internal function]: Drupal\system\Controller\DbUpdateController->handle('results', Object(Symfony\Component\HttpFoundation\Request))
#4 //../web/content/core/lib/Drupal/Core/Update/UpdateKernel.php(110): call_user_func_array(Array, Array)
#5 //../web/content/core/lib/Drupal/Core/Update/UpdateKernel.php(73): Drupal\Core\Update\UpdateKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request))
#6 //../web/content/update.php(28): Drupal\Core\Update\UpdateKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#7 {main}.

chris5156’s picture

I am having exactly this issue updating database tables after upgrading to 8.4.2. Providing my logs here in case they help. Have attempted the fix in #9 but got no extra info from it.

update.php tells me:

1 pending update
views module
Fix table names for revision metadata fields.

On running the updates, it says it has completed "1 of 2" (having said only 1 pending), then fails:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /update.php/start?id=123&op=do_nojs&op=do
StatusText: OK
ResponseText: 
Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /var/sites/c/cbrd.co.uk/public_html/core/lib/Drupal/Core/TypedData/DataDefinition.php on line 30

The error page says:
The update process was aborted prematurely while running update # in views_post_update_revision_metadata_fields.module. All errors have been logged. You may need to check the watchdog database table manually.

And finally the log entry says:
Notice: Undefined offset: 1 in Drupal\system\Controller\DbUpdateController->results() (line 413 of /filepath/public_html/core/modules/system/src/Controller/DbUpdateController.php) #0 /filepath/public_html/core/includes/bootstrap.inc(566): _drupal_error_handler_real(8, 'Undefined offse...', '/filepath...', 413, Array) #1 /filepath/public_html/core/modules/system/src/Controller/DbUpdateController.php(413): _drupal_error_handler(8, 'Undefined offse...', '/filepath...', 413, Array) #2 /filepath/public_html/core/modules/system/src/Controller/DbUpdateController.php(179): Drupal\system\Controller\DbUpdateController->results(Object(Symfony\Component\HttpFoundation\Request)) #3 [internal function]: Drupal\system\Controller\DbUpdateController->handle('results', Object(Symfony\Component\HttpFoundation\Request)) #4 /filepath/public_html/core/lib/Drupal/Core/Update/UpdateKernel.php(110): call_user_func_array(Array, Array) #5 /filepath/public_html/core/lib/Drupal/Core/Update/UpdateKernel.php(73): Drupal\Core\Update\UpdateKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request)) #6 /filepath/public_html/update.php(28): Drupal\Core\Update\UpdateKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #7 {main}.

Pascal-’s picture

Status: Needs review » Needs work
Rick Hood’s picture

Similar problem for me:

drush updb
The following updates are pending:

views module :
  Fix table names for revision metadata fields.

Do you wish to run all pending updates? (y/n): y
Malformed backend packet                                                                                                            [error]
Post updating views                                                                                                                 [ok]
Failed: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "current_user_profile" plugin does not exist. in   [error]
Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of
/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
The command could not be executed successfully (returned: DRUSH_BACKEND_OUTPUT_START>>><<<DRUSH_BACKEND_OUTPUT_END, code: 1)       [error]
Cache rebuild complete.                                                                                                             [ok]
Finished performing updates.

I tracked down the view where the problem is, group member search: /group/1/member-search which has this error after the 8.4.0 upgrade, but not with 8.3.7:

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Component\Plugin\Exception\PluginNotFoundException</em>: The &quot;current_user_profile&quot; plugin does not exist. in <em class="placeholder">Drupal\Core\Plugin\DefaultPluginManager-&gt;doGetDefinition()</em> (line <em class="placeholder">52</em> of <em class="placeholder">core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php</em>). <pre class="backtrace">Drupal\Core\Plugin\DefaultPluginManager-&gt;getDefinition(&#039;current_user_profile&#039;) (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory-&gt;createInstance(&#039;current_user_profile&#039;, Array) (Line: 84)
Drupal\Component\Plugin\PluginManagerBase-&gt;createInstance(&#039;current_user_profile&#039;) (Line: 1111)
Drupal\views\Plugin\views\argument\ArgumentPluginBase-&gt;getPlugin(&#039;argument_default&#039;) (Line: 787)
Drupal\views\Plugin\views\argument\ArgumentPluginBase-&gt;getDefaultArgument() (Line: 1091)
Drupal\views\ViewExecutable-&gt;_buildArguments() (Line: 1265)
Drupal\views\ViewExecutable-&gt;build() (Line: 390)
Drupal\views\Plugin\views\display\PathPluginBase-&gt;execute() (Line: 168)
Drupal\views\Plugin\views\display\Page-&gt;execute() (Line: 1628)
Drupal\views\ViewExecutable-&gt;executeDisplay(&#039;page_ici_connect&#039;, Array) (Line: 78)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer-&gt;doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer-&gt;render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;Drupal\Core\Render\MainContent\{closure}() (Line: 576)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer-&gt;renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber-&gt;onViewRenderArray(Object, &#039;kernel.view&#039;, Object) (Line: 108)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher-&gt;dispatch(&#039;kernel.view&#039;, Object) (Line: 158)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
</pre>
maxilein’s picture

I think the problem exists when a module does not uninstall correctly and leaves somethings in a table ...

nikita_tt’s picture

Try to remove and add (manually) again the filters in View which give an error.

jnimchuk’s picture

I used Drupal 6 for five years before upgrading to version 8. Not once was there an update to core that caused a problem for this long.

This issue was introduced in 8.4; previously no problem.

Will somebody please address this so that we don't have this problem that has lasted months?

Thank you,
John

kruser’s picture

If it's an "HTTP Result Code: 500" error, it's usually a memory issue. Try increasing your PHP memory to 256MB or higher, and run update again. That got it working for me.

tepelena’s picture

Just updated from 8.3.7 to 8.4.4 and I am having the same problem as well.

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /update.php/start?id=5927&op=do_nojs&op=do
StatusText: parsererror
ResponseText: Recoverable fatal error: Argument 1 passed to Drupal\Core\Entity\EntityStorageBase::loadMultiple() must be of the type array, string given, called in /home//public_html/.com/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php on line 396 and defined in Drupal\Core\Entity\EntityStorageBase->loadMultiple() (line 219 of /home//public_html/.com/core/lib/Drupal/Core/Entity/EntityStorageBase.php).



The update process was aborted prematurely while running update # in views_post_update_revision_metadata_fields.module. All errors have been logged.

How can I figure out which view is causing the problem?

Based on this thread and google searches this seems to be a serious problem affecting a lot of users.

cilefen’s picture

@tpelena The error you posted on this update looks different than any other posted on this thread. Is anything logged?

cilefen’s picture

jnimchuk’s picture

Per #24 — increasing the PHP memory to 256M worked for me too.

Thanks Kruser!

gr8tkicks’s picture

I have tried the latest patch with no success (https://www.drupal.org/files/issues/2917006-8.4.x.patch) anyone else have an alternative that works?

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Pascal-’s picture

Status: Needs work » Needs review
catch’s picture

Priority: Major » Critical

Bumping this to critical for visiblity. The update itself isn't the problem, but it's combining with corrupted views to produce the fatal error.

A possible option other than hiding the error would be to try to detect the problem with views in the update itself and correct them before updating.

catch’s picture

Title: Updated from 8.3.7 to 8.4 - drush updb fails the task: Fix table names for revision metadata fields. » Views referencing missing roles fail views_post_update_revision_metadata_fields()
Pascal-’s picture

Could someone explain me why my patch is failing the tests?
It's a plain copy/paste from git diff against the latest 8.5.x core

The error is :fatal: corrupt patch at line 7
Which is an empty line

diff --git a/core/modules/user/src/Plugin/views/filter/Roles.php b/core/modules/user/src/Plugin/views/filter/Roles.php
index a6986f2257..90af5563a9 100644
--- a/core/modules/user/src/Plugin/views/filter/Roles.php
+++ b/core/modules/user/src/Plugin/views/filter/Roles.php
@@ -88,8 +88,9 @@ public function calculateDependencies() {
     }

     foreach ((array) $this->value as $role_id) {
-      $role = $this->roleStorage->load($role_id);
-      $dependencies[$role->getConfigDependencyKey()][] = $role->getConfigDependencyName();
+      if ($role = $this->roleStorage->load($role_id)) {
+               $dependencies[$role->getConfigDependencyKey()][] = $role->getConfigDependencyName();
+         }
     }
     return $dependencies;
   }
amateescu’s picture

Re-uploading the patch from #3 which still applies just fine to 8.6.x and 8.5.x.

Pascal-’s picture

Edit: Just noticed my patch starts? from a different head a6986f2257 instead of a6986f2
Did I start from a wrong project?
Would really help me in future contributions to get this sorted ...

@amateescu #3 is indeed exactly the same as my patch in #31 (didn't notice before)

How is my patch failing and #3 patch passing the tests then?

alexpott’s picture

@Pascal- it looks like line endings are an issue. The patch in #31 has windows line endings. Have a look at https://www.drupal.org/documentation/git/configure for how to configure git so that the correct line endings are used.

catch’s picture

Status: Needs review » Needs work

Discussed briefly with @alexpott.

Let's add an else with a trigger_error() to inform people there's a problem.

I also think we should open a follow-up to potentially remove the roles from the Views when they're missing from the site (or at least to take a firm decision not to do that if we don't want to).

chris5156’s picture

I'm still getting the same issue I described in #18. I'm now running 8.4.5, and have tried the patch but it makes no difference - database updates still fail and I still get the same error.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

amateescu’s picture

Status: Needs work » Needs review
FileSize
907 bytes
704 bytes

Added a trigger_error() as requested above :)

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

That makes sense. Not sure about tests, seems a bit overkill to have a test view/update test for that.

Reminds me of #2925890: Invalid config structures can result in exceptions when saving a config entity, I still have that applied in some projects.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

I definitely think we should have test coverage of this behaviour. I'm not sure it needs to be an update test though. I think we need something to assert that the warning is triggered.

catch’s picture

Issue tags: +Drupal 8 upgrade path
sam-elayyoub’s picture

If it's null then the issue showed up, it's the load() for null is the problem, or the $role_id doesn't have info to load. however, try this patch, another thing if the $role_id is 0, this would give you an array null error, which in this case the error would keep triggering all the way, for every view, so no need to trigger errors for this one.

let me know if this one work.

neclimdul’s picture

There are a lot of style problems with your patch sam. Also, I think we'd want to have the warning though I haven't tried amateescu's patch out. Seems the only complaint was we needed a test.

sam-elayyoub’s picture

@neclimdul can you please share what you see wrong in styles?

neclimdul’s picture

Sorry that was a bit of a drive by comment. I meant coding standards aka code style. Drupal has pretty strict standards(https://www.drupal.org/docs/develop/standards) and even when fixing it in a patch it is worth being careful because there are generally issues to fix code style already created and it can make review harder because it distracts from the notable changes.

  1. +++ b/core/modules/user/src/Plugin/views/filter/Roles.php
    @@ -14,7 +14,8 @@
    -class Roles extends ManyToOne {
    +class Roles extends ManyToOne
    +{
    
    

    Like changing the { placement. Drupal requires them on the same line.

  2. +++ b/core/modules/user/src/Plugin/views/filter/Roles.php
    @@ -88,10 +93,12 @@ public function calculateDependencies() {
    +      // Continue in case of empty role ¶
    

    Also your comment has a space after it and needs a period. Its also a good idea to tell _why_ in your comment instead of stating what the code does. The if and continue already clearly show we're continuing when the role is falsy/empty. But what purpose does that serve? This doubles to help someone reviewing the patch and to the poor soul trying to debug it later.

sam-elayyoub’s picture

Thank you @neclimdul, here's the new patch with error trigger and cleaned up file with --standard=Drupal,DrupalPractice

tedbow’s picture

Status: Needs work » Needs review
FileSize
2.29 KB
2.4 KB

Starting from #42

That patch was RTBC and just needed a test.

I am not sure what #46 was correcting for.

+++ b/core/modules/user/src/Plugin/views/filter/Roles.php
@@ -88,8 +88,12 @@ public function calculateDependencies() {
+        @trigger_error("The {$role_id} role does not exist. You should review and fix the configuration of the {$this->view->id()} view.", E_USER_WARNING);

Was the "@" here intentional?

I couldn't find any other case in core where we use @trigger_error with a E_USER_WARNING though we use @trigger_error with E_USER_DEPRECATED

Removing the "@" and adding a test.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests
FileSize
1.5 KB
2.4 KB

#51 looks great. I wanted to RTBC but went looking for signals that would make me not RTBC. Instead, I found #43 by @Berdir, where he RTBC'd the same set of changes, just without test coverage.

That gives me full confidence to RTBC this :)

Running tests locally show they fail. But rather than expecting a core committer to do the same, I'm just uploading #51 with just the test coverage to prove it fails.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php
@@ -95,4 +95,33 @@ public function testDependencies() {
+   * @expectedException \PHPUnit\Framework\Error\Warning
+   * @expectedExceptionMessage The test_user_role role does not exist. You should review and fix the configuration of the test_user_name view.

We don't use these annotations anymore. We use ->expectException() and ->expectExceptionMessage()

Wim Leers’s picture

Issue tags: +Needs reroll, +Novice

D'oh, yes. Sorry about that.

tedbow’s picture

@alexpott thanks for taking a look at the issue. Fixing #53.

@Wim Leers thanks for the test only patch

Also

+++ b/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php
@@ -95,4 +95,33 @@ public function testDependencies() {
+    try {
+      $view->calculateDependencies();
+    }
+    catch (\Exception $exception) {
+      $this->fail('Exception should not be thrown before the role is deleted.');
+    }

Since we are now using expectException() we no longer need the try catch.

We can just call expectException() after the first call to $view->calculateDependencies(). Therefore if the first call has an exception the test will fail.

alexpott’s picture

+++ b/core/modules/user/tests/src/Kernel/Views/HandlerFilterRolesTest.php
@@ -95,4 +96,28 @@ public function testDependencies() {
+    // Ensure that no exception is thrown before the role is deleted.

Quibbling - but actually no exception is thrown by runtime code. PHPUnit causes warnings to become exceptions. So they can be tested like this. This should be
Ensure no warning is triggered before the role is deleted.

tedbow’s picture

  1. #56 good point. fixed
  2. Here is also a version of the patch pre 8.8 where we can't use $this->expectException()

The last submitted patch, 55: 2917006-55-test-only.patch, failed testing. View results

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

🚢

alexpott’s picture

Version: 8.6.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Crediting @kruser, @jnimchuk for testing the issue and providing feedback
Crediting @catch, @alexpott, @neclimdul for reviews
Crediting @romainlepolh for providing that helped track this down
Crediting @chris5156, @Rick Hood for providing a thorough bug reports

Committed and pushed a90dae47a0 to 9.0.x and 962d2db57e to 8.9.x. Thanks!

Asking other committers for a +1 for backport to 8.8.x

  • alexpott committed a90dae4 on 9.0.x
    Issue #2917006 by tedbow, amateescu, Wim Leers, sam-elayyoub, Pascal-,...

  • alexpott committed 962d2db on 8.9.x
    Issue #2917006 by tedbow, amateescu, Wim Leers, sam-elayyoub, Pascal-,...

  • alexpott committed d8ce1e2 on 8.8.x
    Issue #2917006 by tedbow, amateescu, Wim Leers, sam-elayyoub, Pascal-,...
alexpott’s picture

Status: Patch (to be ported) » Fixed

Discussed with @catch and we agreed to backport this to 8.8.x

Status: Fixed » Closed (fixed)

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

quietone’s picture