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.
Every time I run some tests Simpletest shows me messages from previous tests along with the messages from tests I am running.
Attached patch fixed this problem.
Comment | File | Size | Author |
---|---|---|---|
#30 | simpletest_incorrect_field.patch | 6.46 KB | boombatower |
#28 | simpletest_incorrect_field.patch | 6.51 KB | boombatower |
#24 | simpletest_incorrect_field_4.patch | 4.28 KB | Damien Tournoud |
#17 | simpletest_incorrect_field.patch | 4.28 KB | boombatower |
#13 | test-290316-simpletest-test-id.patch | 1.83 KB | Damien Tournoud |
Comments
Comment #1
boombatower CreditAttribution: boombatower commentedI don't believe I have this issue.
Anyone else confirm?
Comment #2
mustafau CreditAttribution: mustafau commentedI am using PostgreSQL.
Comment #3
boombatower CreditAttribution: boombatower commentedI noticed the field name seemed to be weird some time ago, but forgot the check into it. Appears this was messed up after batch API patch.
has
message_id
instead, even though it was used and intended to be test_id as the field.The following code demonstrates its use
The reason why the major, mysql users, didn't notice is due to the
db_last_insert_id
function. In mysql it looks likehas
message_id
instead, even though it was used and intended to be test_id as the field.The following code demonstrates its use
The reason why the major, mysql users, didn't notice is due to the
db_last_insert_id
function. In mysql it looks likeand doesn't use $field, where as in pgsql:
which does use the $field variable.
The patch fixes the schema.
Comment #4
boombatower CreditAttribution: boombatower commentedDoesn't break tests as I just ran them all.
Comment #5
boombatower CreditAttribution: boombatower commentedUse hook_update?
Comment #6
cwgordon7 CreditAttribution: cwgordon7 commentedThat's not how to do an update function. We want it to just change the name of the column, not re-install the whole table.
Comment #7
boombatower CreditAttribution: boombatower commentedSince the entire table is the single field I would vote for destroying table (needs to be added) and re-creating it. Otherwise the documentation isn't clear on how to edit a field, it only shows how to add table or field. So based on that wouldn't we delete table and recreate? If so I'll just add the delete table to the patch.
Comment #8
boombatower CreditAttribution: boombatower commentedUntested, but added table remove.
Comment #9
cwgordon7 CreditAttribution: cwgordon7 commentedUnfortunately, removing the table will not work, as we can't reset the serial, since the {simpletest} table may already contain entries for lower numbers, which will mess up testing quite a bit.
Comment #10
boombatower CreditAttribution: boombatower commentedNot sure if update is very useful in this case, but results can just be cleared to prevent issue. If this isn't "acceptable" then please come out and state what is commonly used. I think this solution is fine since this is a development version and the simpletest data should be fine to clear.
Comment #11
cwgordon7 CreditAttribution: cwgordon7 commentedJust use db_change_field() please. That's certainly part of what it's meant for, renaming fields.
Comment #12
Damien Tournoud CreditAttribution: Damien Tournoud commentedClarifying the title and bumping to critical.
Comment #13
Damien Tournoud CreditAttribution: Damien Tournoud commentedHere is a test case for this. Tested on MySQL only (passes), and when using a fixed $test_id (fails).
Comment #14
boombatower CreditAttribution: boombatower commenteddb_change_field
http://api.drupal.org/api/function/db_change_field/6
IMPORTANT NOTE: To maintain database portability, you have to explicitly recreate all indices and primary keys that are using the changed field.
When running it that way the removal of primary key gives error since it is autoincrament.
This is somewhat of a waste of time considering the previous solution works and we don't have data we need to maintain so a "perfect" update is rather unnecessary.
Comment #15
Damien Tournoud CreditAttribution: Damien Tournoud commented@boombatower: fair enough. Does the droping/recreating solution works on PostgreSQL? :)
Comment #16
boombatower CreditAttribution: boombatower commentedI don't know why it wouldn't, but someone with PostgreSQL to test would be appreciated. I'll comment the update function and role you test into patch and post it.
Comment #17
boombatower CreditAttribution: boombatower commentedThis patch contains cleaned up test and commented update function.
Comment #18
mustafau CreditAttribution: mustafau commentedsimpletest_update_7000 function also has message_id field in simpletest_test_id table. If it is meant for 6.x to 7.x upgrade we should change that too.
Comment #19
boombatower CreditAttribution: boombatower commentedWon't it just run the schema hook which has the correct schema, it won't even run the update hooks?
And SimpleTest isn't in core as of 6.x.
I'm fairly new to writing updates, but it would seem counter intuitive if you had to update previous updates instead of just main schema.
Comment #20
mustafau CreditAttribution: mustafau commentedsimpletest_update_7000 defines the schema and creates the tables. It does not get definitions from simpletest_schema. The schema inside simpletest_update_7000 should be updated too.
A 6.x to 7.x update is necessary for 6.x installations using Simpletest module in contrib.
simpletest_update_7001 is not necessary for a development version.
Comment #21
boombatower CreditAttribution: boombatower commentedAccording to my understanding of the update API that doesn't make sense. Just to confirm this I installed SimpleTest from fresh Drupal installation and the update hooks are never run.
Meaning that 7000 doesn't need to be changed since it is only used for people running the original schema to update to 7000 version, but on install it expects the hook_schema() to contain the 7000 format.
Same goes for 7001.
As for upgrading from SimpleTest 6.x that isn't an issue since once again there is no data that need to be ported and the 6.x-2.x version of SimpleTest is a copy of 7.x whereas the 6.x-1.x is different and there is no upgrade path, as none is needed.
Lastly an update isn't even useful here since this is dev version and simpletest data can simply be trashed as it doesn't need to be maintained. I don't think we should hold up this bug fix, since this works and is more than sufficient.
Comment #22
Damien Tournoud CreditAttribution: Damien Tournoud commentedLet's not spend too much time on these update functions. By the time we release Drupal 7, Simpletest will probably be renamed to Testing anyway. We only need something that would work for now, during the development cycle.
Let's get this committed. We will change the world a little later.
Comment #23
Dries CreditAttribution: Dries commentedI think 'id' should be written as 'ID'.
Comment #24
Damien Tournoud CreditAttribution: Damien Tournoud commentedMy bad, rerolled.
Comment #25
boombatower CreditAttribution: boombatower commentedHmm...text slips by the eye.
Comment #26
chx CreditAttribution: chx commentedWe do not provide HEAD-HEAD update functions.
Comment #27
Dries CreditAttribution: Dries commented(Minor comment: while we are at it, and when reviewing the code, it occurred to me that we don't really explain very well how IDs are used. I think we can improve the schema definition documentation as well as other places in the code.)
Comment #28
boombatower CreditAttribution: boombatower commented@chx: I thought that was the practice, but seeing the other update function in the file made me wonder. Following your comment I removed both update functions in this patch.
@Dries: Added some documentation to the schema and where the test_id is used to query the results.
Comment #29
Dries CreditAttribution: Dries commentedUnfortunately, this test needs a re-roll. Should be a quick re-roll though.
Comment #30
boombatower CreditAttribution: boombatower commentedRe-rolled.
Comment #31
Dries CreditAttribution: Dries commentedThanks for the re-roll boomba. Tested, reviewed and committed to CVS HEAD.
Comment #32
swentel CreditAttribution: swentel commentedI'm getting notice: Undefined index: test_id all the time, I'm using latest built, did a new install .. but no luck
fwiw: MySQL : 5.0.51a , PHP: 5.2.6 , Apache/2.2.8
When I look into the sessions table I see 'test_id|N;' which well ain't good I think. I'll look into this further before I set this back to active.
Comment #33
swentel CreditAttribution: swentel commentedUpdate:
Delete all the debug info here, it's simply my machine and cpu going wild whenever I start simpletest (even in batch mode). Tested the same distro setup on 2 other machines and everything went fine, phew!
Comment #34
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.