The realname static cache retains old data after user updated, for example:

realname_pattern = '[user:name-raw]'

    $user1 = user_load($uid);
    $realname1 = $user1->realname;

    // Update user name.
    $user1->name = 'bar';
    user_save($user1);

    // Reload the user.
    $user2 = user_load($uid);
    $realname2 = $user2->realname;

or

    $wrapper1 = entity_metadata_wrapper('user', $uid);
    $realname1 = $wrapper1->label();

    // Update user name.
    $wrapper1->name = $this->randomName();
    $wrapper1->save();

    // Reload the user.
    $wrapper2 = entity_metadata_wrapper('user', $uid);
    $realname2 = $wrapper2->label();

result: $realname1 == $realname2
expect: $realname1 != $realname2

Comments

edwardaa created an issue. See original summary.

edaa’s picture

Assigned: edaa » Unassigned
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, reset_cache_for_updated_user.patch, failed testing.

The last submitted patch, reset_cache_for_updated_user.patch, failed testing.

The last submitted patch, reset_cache_for_updated_user.patch, failed testing.

The last submitted patch, reset_cache_for_updated_user.patch, failed testing.

The last submitted patch, reset_cache_for_updated_user.patch, failed testing.

edaa’s picture

Version: 7.x-1.x-dev » 7.x-1.2

Extra field test failed on 7.x-1.x, change the version to 7.x-1.2

edaa’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, reset_cache_for_updated_user.patch, failed testing.

The last submitted patch, reset_cache_for_updated_user.patch, failed testing.

The last submitted patch, reset_cache_for_updated_user.patch, failed testing.

The last submitted patch, reset_cache_for_updated_user.patch, failed testing.

hass’s picture

Version: 7.x-1.2 » 7.x-1.x-dev

Patches are always applied against dev.

hass’s picture

Status: Needs work » Needs review

Fixed the failing tests.

Please write a test for this bug!

edaa’s picture

StatusFileSize
new1.88 KB

Added test for user update hook

edaa’s picture

Issue summary: View changes
edaa’s picture

StatusFileSize
new2.36 KB

Add more test for user update via entity_metadata_wrapper.

Status: Needs review » Needs work

The last submitted patch, 20: reset_cache_updated_user-2620882-20.patch, failed testing.

The last submitted patch, 20: reset_cache_updated_user-2620882-20.patch, failed testing.

The last submitted patch, 20: reset_cache_updated_user-2620882-20.patch, failed testing.

The last submitted patch, 20: reset_cache_updated_user-2620882-20.patch, failed testing.

edaa’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 20: reset_cache_updated_user-2620882-20.patch, failed testing.

The last submitted patch, 20: reset_cache_updated_user-2620882-20.patch, failed testing.

The last submitted patch, 20: reset_cache_updated_user-2620882-20.patch, failed testing.

The last submitted patch, 20: reset_cache_updated_user-2620882-20.patch, failed testing.

edaa’s picture

Status: Needs work » Needs review
StatusFileSize
new294 bytes
new2.69 KB

Add entity test dependency.

Status: Needs review » Needs work

The last submitted patch, 30: reset_cache_updated_user-2620882-30.patch, failed testing.

The last submitted patch, 30: reset_cache_updated_user-2620882-30.patch, failed testing.

The last submitted patch, 30: reset_cache_updated_user-2620882-30.patch, failed testing.

The last submitted patch, 30: reset_cache_updated_user-2620882-30.patch, failed testing.

The last submitted patch, 18: reset_cache_updated_user-18.patch, failed testing.

edaa’s picture

Status: Needs work » Needs review
StatusFileSize
new2.78 KB

Clean up the test, now it should work.

Status: Needs review » Needs work

The last submitted patch, 36: reset_cache_updated_user-2620882-36.patch, failed testing.

The last submitted patch, 36: reset_cache_updated_user-2620882-36.patch, failed testing.

The last submitted patch, 36: reset_cache_updated_user-2620882-36.patch, failed testing.

The last submitted patch, 36: reset_cache_updated_user-2620882-36.patch, failed testing.

edaa’s picture

Status: Needs work » Needs review
StatusFileSize
new1.59 KB

The test is passed locally, seems that testbot is failed to enable entity module, remove the entity test dependency.

hass’s picture

You also need to add entity as dependency to the test. See this example:

public static function getInfo() {
    return array(
      'name' => 'Realname basic tests',
      'description' => 'Test basic functionality of Realname module.',
      'group' => 'Realname',
      'dependencies' => array('entity'),
    );
  }
edaa’s picture

Issue summary: View changes
StatusFileSize
new2.7 KB

Thanks! now it's a full patch including test for the entity metadata wrapper.

Status: Needs review » Needs work

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

edaa’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

edaa’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

The last submitted patch, 43: reset_cache_updated_user-2620882-42.patch, failed testing.

edaa’s picture

Status: Needs work » Needs review
StatusFileSize
new2.7 KB

testbot seems not hpaay, re-add same patch.

Status: Needs review » Needs work

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

edaa’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

hass’s picture

Try adding the test_dependency, too.

edaa’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

The last submitted patch, 58: reset_cache_updated_user-2620882-58.patch, failed testing.

edaa’s picture

Status: Needs work » Needs review
StatusFileSize
new3.03 KB

thanks, add test_dependencies[] = entity

Status: Needs review » Needs work

The last submitted patch, 74: reset_cache_updated_user-2620882-74.patch, failed testing.

The last submitted patch, 74: reset_cache_updated_user-2620882-74.patch, failed testing.

The last submitted patch, 74: reset_cache_updated_user-2620882-74.patch, failed testing.

The last submitted patch, 74: reset_cache_updated_user-2620882-74.patch, failed testing.

edaa’s picture

drupalci.org error:

cd /var/www/html && sudo -u www-data php /var/www/html/scripts/run-tests.sh --php /opt/phpenv/shims/php --url http://localhost/checkout --color --color --concurrency 31 --php /opt/phpenv/shims/php --directory sites/all/modules/realname

ERROR: No valid tests were specified.

However testbot does not recognize test_dependencies[] = entity and the entity module not downloaded.

edaa’s picture

Status: Needs work » Needs review
StatusFileSize
new3.64 KB

as per #1670936-2: Testbot does not detect/download additional dependencies:

Note that the testbot only sees/re-calculates dependencies in named releases. Both of your own project and dependencies (it will always depend on the latest named release, not the -dev snapshot).

So, make sure that the test class has a dependencies => array('i18n_menu') in the getInfo() array then the testbot should ignore the tests for the moment and after commiting and releasing a new version, it should get picked up and he should start running those tests.

Added a new realname_entity.test for user update test via entity_metadata_wrapper.

hass’s picture

The very last idea I have is that someone may have a duplicate module on d.o and the tedtbot is confused. Try test_dependency with "entity:entity". If it still fails we need to open a case with testbot team.

edaa’s picture

Are you meaning add test_dependencies = entity:entity to realname.info?

edaa’s picture

StatusFileSize
new3.04 KB

Added test_dependencies = entity:entity to realname.info

Status: Needs review » Needs work

The last submitted patch, 83: reset_cache_updated_user-2620882-83.patch, failed testing.

The last submitted patch, 83: reset_cache_updated_user-2620882-83.patch, failed testing.

The last submitted patch, 83: reset_cache_updated_user-2620882-83.patch, failed testing.

The last submitted patch, 83: reset_cache_updated_user-2620882-83.patch, failed testing.

edaa’s picture

I think the patch on #80 is acceptable, @hass, how do you think?

hass’s picture

Yes, I think we can go with this. Can you upgrade the test to D8, please?

hass’s picture

Status: Needs work » Needs review
StatusFileSize
new3.34 KB
new3.87 KB

hass’s picture

Why is the entity tests not failing?

  • hass committed add4860 on 7.x-1.x authored by edwardaa
    Issue #2620882 by edwardaa, hass: Reset realname cache for the updated...

  • hass committed 7ec28e2 on 8.x-1.x authored by edwardaa
    Issue #2620882 by edwardaa, hass: Reset realname cache for the updated...
hass’s picture

Status: Needs review » Fixed

Committed the basic patch to D8, too. I guess the entity patch may be obsolete or it need to be rewritten. Just a guess. If you know how, please try it. D8 branch is not clean, so all fails nevertheless until now.

  • hass committed 7e2b144 on 8.x-1.x
    Issue #2620882 by edwardaa, hass: Reset realname cache for the updated...

  • hass committed c9755b4 on 8.x-1.x
    Issue #2620882 by hass: Try upgrading the test
    
edaa’s picture

Yes, the entity test patch is ignored, since there is a dependencies => array('entity') in getInfo() method.
A test class is skipped if it requires a non-existing module,
see simpletest.module#374.

edaa’s picture

Sorry hass, I am not familiar with D8.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.