Skip to content

Conversation

@peterjaap
Copy link
Contributor

Did some preliminary work but contains a bug;

bin/magento indexer:set-mode realtime design_config_grid -l

So far so good:

diff --git a/app/etc/config.php b/app/etc/config.php
index 394877a..42a851e 100644
--- a/app/etc/config.php
+++ b/app/etc/config.php
@@ -426,7 +426,7 @@ return [
             'elasticsuite_thesaurus'
         ],
         'realtime' => [
-
+            'design_config_grid'
         ]
     ]
 ];

However, on running it again, the code unsets the value if it exists, and then re-adds it, causing an associative array to appear;

bin/magento indexer:set-mode realtime design_config_grid -l
diff --git a/app/etc/config.php b/app/etc/config.php
index 394877a..43553e8 100644
--- a/app/etc/config.php
+++ b/app/etc/config.php
@@ -426,7 +426,7 @@ return [
             'elasticsuite_thesaurus'
         ],
         'realtime' => [
-
+            1 => 'design_config_grid'
         ]
     ]
 ];

Drawing a blank on how to avoid this..

@fredden
Copy link

fredden commented Nov 10, 2022

@peterjaap consider using array_values() to reset the keys in the array after the unset() call.
(I used this earlier today when I'd set some values in an array null and then removed them with array_filter(); the default is that there were gaps in the keys, which lead to a similar situation to what you're describing here.)

@peterjaap
Copy link
Contributor Author

peterjaap commented Nov 20, 2022

@fredden thanks, that worked!

@pykettk we now have one problem left. When we switch an indexer to a different mode, it'll say;

Index mode for Indexer Design Config Grid has not been changed

But the app/etc/config.php has been updated accordingly. When I run a change again (doesn't matter which way), it'll say:

Index mode for Indexer Design Config Grid was changed from 'Update by Schedule' to 'Update on Save'

Apparently it's not caching since with all caches off it also displays this behavior;

$ bin/magento indexer:set-mode realtime design_config_grid -l
Index mode for Indexer Design Config Grid was changed from 'Update on Save' to 'Update by Schedule'
$ bin/magento indexer:set-mode realtime design_config_grid -l
Index mode for Indexer Design Config Grid was changed from 'Update by Schedule' to 'Update on Save'
$ bin/magento indexer:set-mode realtime design_config_grid -l
Index mode for Indexer Design Config Grid has not been changed

So the change-message always is lagging behind one command. Maybe this is because we run $result = parent::execute($input, $output); at the top of the execute() method, which displays those messages?

@pykettk
Copy link
Owner

pykettk commented Nov 20, 2022

@peterjaap I'll probably not be able to look into this over the coming week. I've got some time free next Monday so I'll set some time aside to do so then 🙂

@pykettk
Copy link
Owner

pykettk commented Dec 24, 2022

It's been a lot longer than I had originally intended but I've finally been able to look into this. I've confirmed that the behaviour is correct but the messaging is not. Your suggestion of it being the result of calling the parent function at the top of ours seems to be correct from my initial testing, @peterjaap - thanks for the input!

From testing a couple of solution ideas, it seems like we may have to re-implement the entire execute() function and modify the output that way in order to remove the delay in the messaging 😞 It's not ideal but probably isn't the end of the world - we're creating a preference for that function anyway and it's probably unlikely to change in the core 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants