Closed (fixed)
Project:
XML sitemap
Version:
6.x-1.x-dev
Component:
xmlsitemap.module
Priority:
Normal
Category:
Task
Issue tags:
Reporter:
Created:
23 May 2009 at 10:21 UTC
Updated:
3 Jan 2014 at 00:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
hass commentedComment #2
hass commentedComment #3
avpadernoMaybe I am giving the wrong interpretation to something I read, but update function should never renamed; I take it that an update function cannot be deleted.
Are you able to provide an example of Drupal core module that removed an update function from the installation file?
Comment #4
dave reidThe point is that creating empty update functions is pointless and a waste of time. It makes more function calls in the update progress. Anyone who is updating from 5.x-2.x, when the run update.php, all these update update functions will run. What is the point?
What you should do is remove any empty update functions except for the last one, if it's the last update function in the module. It's bad practice to have empty update functions. Drupal core tries to avoid them at all costs.
Comment #5
avpadernoI didn't create empty update functions, but they became empty because the code has been moved to a different update function. This is partially caused from my misunderstanding of how the update functions are called.
I thought Drupal would call only the latest update function (I know it's a silly idea, and I don't know from what I took that idea), so I keep to move the code from a function to another because update functions cannot be renamed.
If there aren't any problems in removing such functions, I will do it.
Comment #6
hass commentedIf you move code to higher update function numbers than there is no problem at all. Core looks only into the system table for the current "schema" version and if your module have a higher version in .install file available - it executes every version that is higher up to the highest available in .install file. It doesn't matter if there are numbers missing or not. Otherwise we would never be able to upgrade to 6200 and 7000 and so on...
Only to note - the numbering 6xxx and 62xx is a drupal rule introduced in D5 if I remember correctly. Prior we haven't had a rule and everyone started at "1" and counted up. It have changed to the core version to make it easier to figure out when if have been added to the code. As you might know core only supports upgrades from the one or two last major versions... so if we are in D8 you can simply remove at least all
hook_update_5xxxupdate hooks without spending hours to figure out when someone have added versionhook_update_4.Comment #7
avpadernoI have changed the code, and committed the changes in CVS.
I think that the documentation, which says (or said) to not rename an update function should be clearer on that. An update function should not be renamed to make its update number lower.
Anyway, this is not a bug report, but a task.
Comment #8
Anonymous (not verified) commentedResetting to reapply the changes.
Comment #9
Anonymous (not verified) commentedComment #10
Anonymous (not verified) commentedThe attached patch removes the empty hook_update_N implementations, resolves #485604: xmlsitemap_term_update_6000() doesn't exist, adds some TODO comments and moves the call to xmlsitemap_flag_sitemap() from a hook_update_N to a hook_enable and a hook_disable function to avoid complaint of missing function in the update process.
Comment #11
avpadernoAs long as I can see, the patch is renaming the update functions, which is not allowed.
The answer to the question why are we deleting all the rows of the table is that the content of the table is being deleted because the primary key is being changed with an auto-incremental field; being this the case, the only way to give to the primary key the correct value is to re-populate the table.
Comment #12
avpadernoThe part of the patch that is wrong is the following:
The update #6112 is renamed 6107; this means that who already had installed a beta version, would not see any new update until you don't use an update number greater than 6112 again. As I am talking of a beta version, the case doesn't fall into the inter-dev update (and the consequent silliness).
Talking of inter-dev update, a question comes in: if the inter-dev updates are not supported (which is not the case of other modules), why would a developer increase the update number of the functions? It would be enough to create a unique update function that would do all the update tasks necessary. The inter-dev updates are not supported; therefore, using a different update function each times would not make sense, as who install the latest development version is forced to uninstall the older one, without to even make an update.
Comment #13
Anonymous (not verified) commentedI will check the patch. I didn't mean to change the numbers.
Re: Intra-dev updates:
Drupal core doesn't even support intra-dev updates. Dave already explained it elsewhere. It isn't possible to time all changes to -dev so that upgrading is always possible. In the instance of the code reset, the poor sole who tries to execute update.php is just out of luck. There is and will not be an update path that he can follow other than to start fresh. The instructions I give at #379854-128: The site map is not being populated are the only instructions to follow to ensure that installing a new -dev will work. Executing update.php will never be guaranteed to work on code that is as heavily maintained as this one is being maintained.
Comment #14
Anonymous (not verified) commentedThat isn't true. Just dropping the key, adding the serial column and declaring it the primary key is enough. The database engine handles the update of the column for all rows.
Comment #15
Anonymous (not verified) commentedRe: #12. The patch file is correct, the hook_update_N didn't change from 6112 to 6107. Before the diff portion you copied you will see
It only appeared to change the N because of the way the diff formatted the output.
Comment #16
avpadernoIt's not what happened to me when I tested the update function; the SQL query that adds the new primary key doesn't update the existing rows.
It's enough to see the code for the following Drupal core function:
Comment #17
Anonymous (not verified) commentedThe attached patch has been committed to CVS.