Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

Status: Active » Needs review
FileSize
14.63 KB

How about this? I have also changed the tests slightly in CachedDataUITest, to also test the cancel button on the edit form works correctly.

Looking at the ViewUIConverter, as it already uses the tempstore, could we pass this into the ViewUI so we won't need to make a drupal_container() call in cacheSet. thoughts? We could also, have a better name for this method. Also, thoughts? :)

tim.plunkett’s picture

This conflicts pretty heavily with #1919142: Convert Views UI AJAX forms to use FormInterface, and I keep getting confused since I see code I've removed in that issue :)
I'll take a real look at this over the weekend.

damiankloip’s picture

Assigned: Unassigned » damiankloip
Status: Needs review » Postponed

OK, let's postpone this one on that. This is a pretty small patch anyway, so it can just be re rolled when that issue is in. Probably easier for all involved :)

damiankloip’s picture

Status: Postponed » Needs review
FileSize
17.67 KB

Let's get this moving again, rerolled.

damiankloip’s picture

FileSize
17.67 KB

Should probably use Drupal::service() too.

dawehner’s picture

Great effort!

+++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.phpundefined
@@ -733,6 +733,33 @@ public function getFormProgress() {
+    if (isset($this->locked) && is_object($this->locked) && $this->locked->owner != $GLOBALS['user']->uid) {

Locked is still documented as boolean, though it is actually a TempStore object. If it's a tempstore object, shouldn't this piece of code actually fail because ->owner is a protected property? Additional we could simply check of if ($this->locked instanceof TempStore)

+++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.phpundefined
@@ -733,6 +733,33 @@ public function getFormProgress() {
+    \Drupal::service('user.tempstore')->get('views')->set($this->id(), $this);

Just wondering whether we could inject this into the class? I guess no, because it's used in form state.

tim.plunkett’s picture

$this->locked isn't a TempStore object, it's the result of TempStore::getMetadata(), which is either a stdClass or NULL.

dawehner’s picture

OH, I see, but yeah bool still feels wrong.

damiankloip’s picture

Yeah, I guess we would have seen a few notices if we couldn't access that. I'll change the doc for the locked property.

damiankloip’s picture

#5: 1919700-5.patch queued for re-testing.

damiankloip’s picture

Assigned: damiankloip » Unassigned
FileSize
621 bytes
17.99 KB

Changed the $locked property doc on ViewExecutable.

dawehner’s picture

+++ b/core/modules/views/lib/Drupal/views/Tests/UI/CachedDataUITest.phpundefined
@@ -34,23 +34,31 @@ public function testCacheData() {
+    $this->assertFalse($temp_store->getMetadata('test_view'), 'User tempstore data has been removed.');
...
+    $this->assertFalse($temp_store->getMetadata('test_view'), 'The view is not locked.');

Should we maybe look at the content of the locked object as well?

+++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.phpundefined
@@ -64,7 +64,10 @@ class ViewUI implements ViewStorageInterface {
+   * If this view is locked it will contain the result of
+   * \Drupal\user\TempStore::getMetadata(). Which can be a stdClass or NULL.
+   *
+   * @var stdClass
...
   public $locked;

Thank you!

damiankloip’s picture

Should we maybe look at the content of the locked object as well?

I think these tests are ok how they are, as NULL will be returned if no entry is found for the current user. I'm not sure we need to test the tempstore owner etc.. and the user tempstore tests will be covering that already?

damiankloip’s picture

FileSize
18.08 KB

We can remove that call to views_get_view in the test though I think.

damiankloip’s picture

FileSize
3.45 KB
19.05 KB

OK, Let's help dawehner sleep at night and change the tests :) Check the owner is equal to the lock owner, and that it is equal to NULL when it should be.

dawehner’s picture

Thank you!

+++ b/core/modules/views/lib/Drupal/views/Tests/UI/UITestBase.phpundefined
@@ -28,8 +28,8 @@ protected function setUp() {
+    $this->viewsAdminUser = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions'));

Then we should document this new user variable?

damiankloip’s picture

FileSize
1.98 KB
19.5 KB

Good point, here we go.

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, 1919700-17.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
Issue tags: +VDC

#17: 1919700-17.patch queued for re-testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Perfect

webchick’s picture

Status: Reviewed & tested by the community » Needs work

This all looks like fine clean-up, but that cacheSet() method name is confusing. I was originally going to ask "Why can't Views just do a normal cache()->set() like everyone else?" only to find out that the method has nothing at all to do with setting caches and has everything to do instead with interacting with the user tempstore.

I realize this is a "pre-existing condition" since the function name you're moving away from is called views_ui_cache_set(), but it'd be nice to clean that up as well, since we are in "clean-up" phase after all. :)

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
19.6 KB

Here it is with setTempStore() instead.

xjm’s picture

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/HandlerBase.phpundefined
@@ -835,7 +835,7 @@ public function displayExposedForm($form, &$form_state) {
-    views_ui_cache_set($form_state['view']);
+    $form_state['view']->setTempStore();

+1, this is much nicer.

+++ b/core/modules/views/views_ui/lib/Drupal/views_ui/ViewUI.phpundefined
@@ -64,7 +64,10 @@ class ViewUI implements ViewStorageInterface {
+   * If this view is locked it will contain the result of
+   * \Drupal\user\TempStore::getMetadata(). Which can be a stdClass or NULL.

This doesn't need to be two sentences (nor should it, grammatically speaking).

Also, good tests!

damiankloip’s picture

FileSize
654 bytes
19.6 KB

Ok, we can make that a comma instead.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC. I also like the improvement here.

damiankloip’s picture

FileSize
958 bytes
19.5 KB

Just spotted a typo in one of the asserts. Tiny change.

xjm’s picture

#26: 1919700-26.patch queued for re-testing.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/lib/Drupal/views/Tests/UI/CachedDataUITest.phpundefined
@@ -31,26 +31,34 @@ public static function getInfo() {
+    // Cancel the view edit and make sure the cache is deleted.
+    $this->drupalPost(NULL, array(), t('Cancel'));
+    $this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'User tempstore data has been removed.');
+    // Test we are redirected to the view listing page.
+    $this->assertUrl('admin/structure/views', array(), 'Redirected back to the view listing page.');
+    // The view should not be locked.
+    $this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'The view is not locked.');

Seem to have a duplicate assertion of the view not being locked.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
964 bytes
19.36 KB

Good point, that last assertion is pointless there.

damiankloip’s picture

FileSize
19.33 KB

Rerolled, after unsaved view message text got changed.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC

alexpott’s picture

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

Views UI has moved...

damiankloip’s picture

Status: Needs work » Needs review
FileSize
19.07 KB

Indeed it has...

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Let's wait until it's green.

damiankloip’s picture

#33: 1919700-33.patch queued for re-testing.

damiankloip’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
3.63 KB
21.36 KB

Me and Alex talked about this earlier and decided it would be nice to have an isLocked() method that encapsulates this logic, and change the property to lock instead of locked.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

Nice improvement!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 34acf68 and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

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

xjm’s picture

Title: Replace views_ui_cache_set with a method on the ViewUI object » [Change notice[ Replace views_ui_cache_set with a method on the ViewUI object
Project: Drupal core » Views (for Drupal 7)
Version: 8.x-dev » 8.x-3.x-dev
Component: views_ui.module » Code
Status: Closed (fixed) » Active
Issue tags: +Needs change record
Chris Matthews’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 8.x-3.x-dev » 8.7.x-dev
Component: Code » views_ui.module
Issue summary: View changes

For more information as to why this issue was moved to the Drupal core project, please see issue #3030347: Plan to clean process issue queue

Chris Matthews’s picture

Project: Drupal core » Views (for Drupal 7)
Version: 8.7.x-dev » 7.x-3.x-dev
Component: views_ui.module » Code
Status: Active » Closed (outdated)

Moving back to the contributed Views issue queue and closing as outdated per https://www.drupal.org/project/views/issues/3030347#comment-13023447