Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
who wants it can we have it?
Comment | File | Size | Author |
---|---|---|---|
#8 | 1801242-title-upgrade.patch | 3.84 KB | drzraf |
#3 | Screenshot-before-replace.png | 161.58 KB | chriscalip |
#3 | Screenshot-after-process-watchdogs.png | 388.02 KB | chriscalip |
Comments
Comment #1
chriscalip CreditAttribution: chriscalip commentedOr even just a way to programmatically update node entity bundles (content types) from traditional title to fieldable title; right now the switch process is entwined with the batch api process..
Comment #2
plachWhat about title_field_replacement_init()?
Comment #3
chriscalip CreditAttribution: chriscalip commentedThat was initially what i was thinking about and i took the time to profile this code and here's my findings.
I wanted to programmatically replace the action of "Replace title with a field instance"
See: Screenshot-before-replace.png
-- setting the bundle settings from traditional node title to more flexible fieldable title.
-- update the nodes belonging to that bundle from traditional node title to fieldable title.
-- i profiled the process of updating a page content type . with about 40 nodes and this function got called about 75 times.
See: Screenshot-after-process-watchdogs.png
Comment #4
chriscalip CreditAttribution: chriscalip commentedI am slowly putting in more information as I dig deeper.
-- setting the bundle settings from traditional node title to more flexible fieldable title.
The drush extension can make use of
title_field_replacement_toggle($form['#entity_type'], $form['#bundle'], $form['#field_name']);
update the nodes belonging to that bundle from traditional node title to fieldable title.
currently checking if title_field_replacement_init() would be suitable for a drush extension context instead of entry point via the batch api specifically.. title_field_replacement_batch_set.
Comment #5
chriscalip CreditAttribution: chriscalip commented@plach
You were right drush extension can make use of title_field_replacement_init(). Also in terms of improving our contributed modules i'd like to share my findings and possible recommendations:
-- update the nodes belonging to that bundle from traditional node title to fieldable title.
title_field_replacement_init()
In every process we have the advantage of having contextual information that user wants to update a specific bundle. The process could take advantage of user intention parameter value $bundle
By changing code From
To :
This would be a significant performance booster and less memory requirements because the process is only loading nodes belonging to that bundle.
Comment #6
plachThe reason for not going that way is that not every entity type supports bundle conditions, for instance taxonomy terms do not. However I think the version you are using is outdated, see the one I linked in #2.
Comment #7
q0rban CreditAttribution: q0rban commentedHere's a drush command that I wrote for a custom project to upgrade node titles to Title module fields. It could pretty easily be adapted to work with other entity types as well, I think.
Comment #8
drzraf CreditAttribution: drzraf commentedThe exact version of q0rban attached as a patch
But I noticed a bunch of these:
Undefined property: stdClass::$original file.field.inc:265
what does not happen using the browser.
Other than that it appears to work well.
Thanks.
Comment #9
drzraf CreditAttribution: drzraf commentedThe notice was unrelated, after applying the patch from #985642: Remove file_attach_load() from file_field_update() the title replacement processed quietly.
Comment #10
drzraf CreditAttribution: drzraf commentedping ?
Comment #11
DamienMcKennaDon't forget to update the issue to "needs review" after you upload a patch ;-)
Comment #12
PolIt would be a very nice to have indeed.
Comment #13
PolPatch tested and working.
Comment #14
alex_optim+1
Comment #15
pifagorComment #17
pifagorComment #19
douggreen CreditAttribution: douggreen as a volunteer and at Tag1 Consulting commentedHow was this RTBC and committed. AFAICT, this is broken because title_content_types() doesn't exist and never existed.
And ideally, this would not hard code 'node' but take the entity type as an argument.