Closed (fixed)
Project:
Title
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Oct 2012 at 17:28 UTC
Updated:
3 Nov 2021 at 14:37 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
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 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 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 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 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 commentedThe exact version of q0rban attached as a patch
But I noticed a bunch of these:
Undefined property: stdClass::$original file.field.inc:265what does not happen using the browser.
Other than that it appears to work well.
Thanks.
Comment #9
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 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
pifagor commentedComment #17
pifagor commentedComment #19
douggreen 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.