Fix bad URLs from happening when inheritUrlFromParent is used. Fixes bug #11011
This commit is contained in:
parent
4fc3e55a3a
commit
9d438f7266
3 changed files with 13 additions and 14 deletions
|
|
@ -56,6 +56,7 @@
|
|||
- fixed #10990: Survey: View Transposed Results not working
|
||||
- fixed #11009: Shipping address is lost after login
|
||||
- fixed #11010: Purchasing non-recurring subscription twice does not extend group membership
|
||||
- fixed #11011: Inherit URL from parent can generate bad URLs
|
||||
|
||||
7.7.19
|
||||
- fixed #10838: Forwarded forum post email to new CS adds reply to original thread
|
||||
|
|
|
|||
|
|
@ -681,12 +681,12 @@ sub fixUrl {
|
|||
$url =~ s/(.*)\..*/$1/;
|
||||
$url .= '/'.$self->getValue("menuTitle");
|
||||
}
|
||||
$url = $self->session->url->urlize($url);
|
||||
|
||||
# if we're inheriting the URL from our parent, set that appropriately
|
||||
if($self->get('inheritUrlFromParent')) {
|
||||
$url = $self->fixUrlFromParent($url);
|
||||
}
|
||||
$url = $self->session->url->urlize($url);
|
||||
|
||||
# fix urls used by uploads and extras
|
||||
# and those beginning with http
|
||||
|
|
@ -768,15 +768,10 @@ sub fixUrlFromParent {
|
|||
my @parts = split(m{/}, $url);
|
||||
|
||||
# don't do anything unless we need to
|
||||
if("/$url" ne $self->getParent->getUrl . '/' . $parts[-1]) {
|
||||
$url = $self->getParent->getUrl . '/' . $parts[-1];
|
||||
if($url ne $self->getParent->get('url') . '/' . $parts[-1]) {
|
||||
$url = $self->getParent->get('url') . '/' . $parts[-1];
|
||||
}
|
||||
|
||||
##Note we do not need to call fixUrl on the url argument. Here's the reasoning why.
|
||||
##If a URL has not been set to updated at the same time that inheritUrlFromParent is
|
||||
##called, then it has already been "fixed".
|
||||
##On the other hand, if it has, the sideEffect nature of this method guarantees that
|
||||
##the URL was "fixed" before it was called.
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ $canViewMaker->prepare(
|
|||
},
|
||||
);
|
||||
|
||||
plan tests => 115
|
||||
plan tests => 116
|
||||
+ scalar(@fixIdTests)
|
||||
+ scalar(@fixTitleTests)
|
||||
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
|
||||
|
|
@ -769,7 +769,7 @@ $properties2 = {
|
|||
my $iufpAsset2 = $iufpAsset->addChild($properties2, $properties2->{id});
|
||||
$iufpAsset2->update( { inheritUrlFromParent => 1 } );
|
||||
$iufpAsset2->commit;
|
||||
is($iufpAsset2->getUrl, '/inheriturlfromparent01/inheriturlfromparent02', 'inheritUrlFromParent works');
|
||||
is($iufpAsset2->get('url'), 'inheriturlfromparent01/inheriturlfromparent02', 'inheritUrlFromParent works');
|
||||
|
||||
my $properties2a = {
|
||||
# '1234567890123456789012'
|
||||
|
|
@ -782,15 +782,15 @@ my $properties2a = {
|
|||
|
||||
my $iufpAsset2a = $iufpAsset->addChild($properties2a, $properties2a->{id});
|
||||
$iufpAsset2a->commit;
|
||||
is($iufpAsset2a->getUrl, '/inheriturlfromparent01/inheriturlfromparent2a', 'inheritUrlFromParent works when created with the property');
|
||||
is($iufpAsset2a->get('url'), 'inheriturlfromparent01/inheriturlfromparent2a', '... works when created with the property');
|
||||
|
||||
# works for setting, now try disabling. Should not change the URL.
|
||||
$iufpAsset2->update( { inheritUrlFromParent => 0 } );
|
||||
$iufpAsset2->commit;
|
||||
is($iufpAsset2->getUrl, '/inheriturlfromparent01/inheriturlfromparent02', 'setting inheritUrlFromParent to 0 works');
|
||||
is($iufpAsset2->get('url'), 'inheriturlfromparent01/inheriturlfromparent02', '... setting inheritUrlFromParent to 0 works');
|
||||
|
||||
# also make sure that it is actually disabled
|
||||
is($iufpAsset2->get('inheritUrlFromParent'), 0, "disabling inheritUrlFromParent actually works");
|
||||
is($iufpAsset2->get('inheritUrlFromParent'), 0, "... disabling inheritUrlFromParent actually works");
|
||||
|
||||
# works for setting and disabling, now ensure it recurses
|
||||
|
||||
|
|
@ -807,7 +807,10 @@ $iufpAsset2->update( { inheritUrlFromParent => 1 } );
|
|||
$iufpAsset2->commit;
|
||||
$iufpAsset3->update( { inheritUrlFromParent => 1 } );
|
||||
$iufpAsset3->commit;
|
||||
is($iufpAsset3->getUrl, '/inheriturlfromparent01/inheriturlfromparent02/inheriturlfromparent03', 'inheritUrlFromParent recurses properly');
|
||||
is($iufpAsset3->get('url'), 'inheriturlfromparent01/inheriturlfromparent02/inheriturlfromparent03', '... recurses properly');
|
||||
|
||||
$iufpAsset2->update({url => 'iufp2'});
|
||||
is($iufpAsset2->get('url'), 'inheriturlfromparent01/iufp2', '... update works propertly when iUFP is not passed');
|
||||
|
||||
|
||||
################################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue