Closed (fixed)
Project:
Metatag
Version:
8.x-1.x-dev
Component:
User interface
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Oct 2015 at 19:23 UTC
Updated:
18 Oct 2019 at 21:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
damienmckennaNeed to fix this before beta1.
Comment #3
damienmckennaComment #4
damienmckennaComment #5
damienmckennaThis will need an update script to clean up values for existing records.
Comment #6
damienmckennaI've updated the issue summary to describe the changes that need to be made so that it matches the D7 UX.
Comment #7
larowlanWorking on a test.
Comment #8
michelleThis patch does two things:
1) Excludes any tag from the flattening process if it matches the default of that field. This will exclude the tag from being serialized/saved.
2) Only falls back to default if the tag doesn't exist in the serialized string.
It does not address doing a mass updating of existing nodes.
Comment #14
damienmckennaI've disabled the drupalci tests as they were triggering unrelated errors: #2581469: Metatag tests all failing with "Undefined variable: classes"
Comment #15
michelleI'm going to work on the script this morning. Figured I'd better put my name on it since there's a lot of cooks in this kitchen. ;)
Comment #16
michelleAfter 4 hours of beating my head against this, I finally found a doc page that was my Rosetta Stone and gave me the start I needed to get this going. There is (obviously) more work to be done and I'll get to that tomorrow. This is the in-progress code:
Comment #17
michelleOk, I added an .install file to the patch that contains the update. I've tested it and it's working on the client data and leaving behind only the expected overridden values so I think it's good. But, it's one doozy of an update function including deleting and changing data in the table so it would be good to have more eyes on it. I especially don't know if this will cause any performance issues on sites with a huge amount of nodes. I couldn't think of a better way to make mass changes.
Comment #18
damienmckennaExcellent, thanks Michelle.
One small thing - it needs to use the batch API wrapper (sandbox) to avoid timeouts for large sites (or slow sites).
Comment #19
michelleOk, I'll work on that a bit later today. Need to spend some time on "C" before getting back to "M" again. :)
Comment #20
michelle"small thing"... Ha... Brainbendy thing figuring out how to make nested foreach loops work with the sandboxing. Finally realized I could stuff the sandbox during the foreaches and then run the actual database code on the sandbox array. 3 hours later, I _almost_ have it working but it's only processing 834 of 839 records and then running out of records. So something is wrong somewhere. Going to post the code in case anyone else feels like having a look and I'll pick it up again tomorrow.
Comment #21
michelleOk, I updated the update hook to use the sandbox. Let's give this patch a whirl.
Comment #23
larowlanI don't this belongs in the widget. What if I build a new widget? I need to duplicate this logic. What if I submit via REST?.
I think this belongs in
MetatagFieldItem::preSave().Comment #24
larowlanTest for the bug part of this is in #2563637: Write tests for the 8.x-1.x functionality (commented out).
So once that's in, this issue should uncomment that assert.
Comment #25
michelleOk, I moved the default checking logic to the pre-save. I also discovered there's another problem with this UI of blank==overridden in that editing a node would override all the defaults since the defaults weren't automatically filled in on node edit. This patch makes sure they are all filled in when you edit a node. I still am not happy with that UI choice but I got it working.
I did not address the test as that hasn't yet been committed and I didn't want this dependent on another patch.
Comment #27
michelleMissed a newline at the end of the .install file. See comment #25 for the rest on this patch.
Comment #29
damienmckennaThis splits the update script in two - one for deleting records that match the defaults, one for removing the defaults. It also turns on the tests that larowan wrote.
Comment #31
larowlanNice! the test passes for the overridden/default - but shows some warnings in the widget.
Working on fix.
tests++
Comment #32
larowlanRight so the fail is because the default value form in field ui doesn't yet have default values
tests++
working on detecting that and fixing
Comment #33
larowlanFixes the default value issue.
Also removes the call to \Drupal in the constructor in favour of DI.
Do we have an issue for adding an interface for MetatagManager? Type-hinting a concrete implementation makes me feel dirty. If not, I'll add a new issue.
Comment #34
larowlanAdded #2593141: Add a MetatagManagerInterface to avoid type-hinting concrete implementation
Comment #35
damienmckennaRerolled, and it's throwing an exception.
Comment #36
damienmckennaNo, this patch isn't throwing an exception, the current HEAD is. Dangit.
Comment #37
damienmckennaCommitted. Thanks everyone!
Comment #40
damienmckenna