[development] important reminder: do not use API functions in update code
gabor at hojtsy.hu
Tue Dec 4 15:05:51 UTC 2007
On Dec 4, 2007 3:29 PM, Gábor Hojtsy <gabor at hojtsy.hu> wrote:
> Take system_update_6027 for example, which we try to fix at
> http://drupal.org/node/197500 .
> - it calls _block_rehash() (note the underscore, not even a public
> API function!)
> - _block_rehash() uses drupal_save_record(), which uses the most up
> to date schema from system_schema()
> Now what happens if the schema is changed in a later update in Drupal
> 6? (ie. > 6027 but < 7000). Well, system_update_6027() becomes broken,
> because its _block_rehash() call tries to use the latest schema (as in
> after all Drupal 6 updates are run), but all Drupal 6 updates are not
> run yet.
A similar example is system_update_1005() which is still in
system.install in the name of letting enterprising folks try to update
their 4.7 sites to 6.0. Well, it uses some API functions, namely:
(db_ functions and variable_ functions are mostly taken to be usable
So guess which one of the above breaks in a Drupal 6. Out of pure
luck, only menu_rebuild() (at least in my testing), as at
system_update_1005(), the menu system is far from being in the state
where it is expected in Drupal 6.
So why isn't this a critical bug? Well, this is in pre 5.0 update
code, and we officially only support updates from 5.x. So why are pre
5.x update functions still in Drupal 6? Nobody suggested to remove
them yet (although we removed pre 4.7 update code). Let's discuss!
More information about the development