When no url_alias rows is present in db upon start of request, the static $count is set to '0', and the 'wipe' does not clear this state.

Steps to reproduce:
1.) clear url_alias cache
2.) create some code that does:
a.) sets an alias using path_set_alias()
b.) get the alias back, using drupal_get_path_alias()

The alias returned will be wrong, even though path_set_alias() calls drupal_clear_path_cache() (which just calls the drupal_lookup_path('wipe')).

Cause: the $count is not reset upon wipe.

The above issue gives me problems with creation of nodes during when using an installation profile.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gielfeldt’s picture

FileSize
822 bytes

Here's a patch that fixes the problem.

Dave Reid’s picture

Version: 5.10 » 7.x-dev

You should just use unset($count). And this should probably be fixed in D7, then backported.

Dave Reid’s picture

Status: Active » Needs review
FileSize
525 bytes

Patch for D7.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

Ok.

Damien Tournoud’s picture

Status: Reviewed & tested by the community » Needs work

Since when can we unset static variables?

This probably doesn't work, and anyway, it should have a test.

Anonymous’s picture

If a static variable is unset() inside of a function, unset() destroys the variable only in the context of the rest of a function. Following calls will restore the previous value of a variable.

function foo()
{
    static $bar;
    $bar++;
    echo "Before unset: $bar, ";
    unset($bar);
    $bar = 23;
    echo "after unset: $bar\n";
}

foo();
foo();
foo();

The above example will output:

Before unset: 1, after unset: 23
Before unset: 2, after unset: 23
Before unset: 3, after unset: 23

Which means that if the unset is at the top of the function then it works well. Setting $count to NULL instead would work for this case.

Damien Tournoud’s picture

Status: Needs work » Needs review
FileSize
524 bytes

Here is a proper patch.

#204106: Test for translated path aliases now depends on this.

Dries’s picture

Status: Needs review » Fixed

I've committed this to CVS HEAD and DRUPAL-6. Thanks!

gpk’s picture

Version: 7.x-dev » 5.x-dev
Status: Fixed » Patch (to be ported)
marcingy’s picture

Status: Patch (to be ported) » Closed (won't fix)

Marking as won't fix as d5 is end of life.