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.
sid is primary key so mostly md5(microtime()) is the same and second insert failed with
'UserBlocksUnitTests', 'exception',
'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ''3886465a51d1dfce61c06aa04f332ecd'' for key 1',
'Uncaught exception', 'PDOStatement->execute()', 1691,
'/home/drupaltesting/web/public/sites/drupaltesting.deekayen.net/files/checkout/includes/database/database.inc'
This happens in modules\user\user.test
$this->insertSession();
$this->insertSession();
...
private function insertSession(array $fields = array()) {
$fields += array(
'uid' => 0,
'sid' => md5(microtime()),
'timestamp' => REQUEST_TIME,
);
Comment | File | Size | Author |
---|---|---|---|
#11 | 503496_uniqid.patch | 591 bytes | deekayen |
#7 | 503496-sid.patch | 697 bytes | boombatower |
Comments
Comment #1
andypostI cant understand a logic of test.
Comment #2
andypostMore descriptive title
modules\user\user.test
testWhosOnlineBlock()
Comment #3
Damien Tournoud CreditAttribution: Damien Tournoud commentedOn which OS / hardware are you running this test?
I agree that inserting rows into the database is really not a good method for testing the who's online block... it will fail for non DB session.inc, and session.inc is supposed to remain pluggable.
Comment #4
andypostStable error when using php-apc - on debian 5 (apache2 php 5.2.6)
Comment #5
deekayen CreditAttribution: deekayen commentedI got the error on Ubuntu 8.04 Hardy with eaccelerator 0.9.5.3 and PHP 5.2.4 Suhosin.
Comment #6
andypostSuppose using md5(microtime()) is not a good random generator mainly.
Comment #7
boombatower CreditAttribution: boombatower commentedTest still passes locally and would seem to solve problem.
Comment #8
Dave ReidI think this was my test. :) Let's change it to md5(mt_rand()) and see if that fixes it.
Comment #9
boombatower CreditAttribution: boombatower commentedFix cross-post.
Comment #10
andypostLooks good for me. Need some reviews except mine...
Comment #11
deekayen CreditAttribution: deekayen commentedHow about using the PHP function actually intended for unique IDs:
md5(uniqid(mt_rand(), true))
Comment #12
boombatower CreditAttribution: boombatower commentedLooks great. Lets not hold up PIFR any longer, eh?
Comment #13
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks!