Skip to content

Commit

Permalink
Item11929: removing pointless code causing serious performance issues.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/branches/Release01x01@15226 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Jul 28, 2012
1 parent c4b5aa7 commit 380afb2
Showing 1 changed file with 0 additions and 114 deletions.
114 changes: 0 additions & 114 deletions core/lib/Foswiki/UI/Rename.pm
Original file line number Diff line number Diff line change
Expand Up @@ -790,14 +790,6 @@ sub _moveTopicOrAttachment {
$to->unload();
$to->load();

if ( $from->web ne $to->web ) {

# If the web changed, replace local refs to the topics
# in $from->web with full $from->web.topic references so that
# they still work.
_replaceWebInternalReferences( $session, $from, $to );
}

# Now let's replace all self-referential links:
require Foswiki::Render;
my $text = $to->text();
Expand Down Expand Up @@ -964,112 +956,6 @@ sub _replaceWebReferences {
return $text;
}

# _replaceWebInternalReferences( $from, $to )
#
# Change within-web wikiwords that refer to the topic $from so they
# point to $to. $from and $to are Foswiki::Meta.
sub _replaceWebInternalReferences {
my ( $session, $from, $to ) = @_;

my $renderer = $session->renderer;
my $webObject = Foswiki::Meta->new( $session, $from->web() );
my $it = $webObject->eachTopic();
my $oldTopic = $from->topic();

my $options = {

# exclude this topic from the list
topics => [ grep { !/^$oldTopic$/ } $it->all() ],

inWeb => $from->web,
inTopic => $from->topic,

oldWeb => $from->web,

#oldTopic => will be filled in by _replaceInternalRefs

newWeb => $from->web,

#newTopic => will be filled in by _replaceInternalRefs

# Process noautolink blocks. forEachLine will set in_noautolink when
# processing links in a noautolink block. getReferenceRE will force
# squabbed links when in_noautolink is set.
autolink => 1,
};

my $text = $to->text();

# Replace references that were internal to the source web; they are
# now inter-web
$text =
$renderer->forEachLine( $text || '', \&_replaceInternalRefs, $options );

$options->{inMeta} = 1;
$to->forEachSelectedValue( qw/^(FIELD|TOPICPARENT)$/, undef,
\&_replaceInternalRefs, $options );
$to->forEachSelectedValue( qw/^TOPICMOVED$/, qw/^by$/,
\&_replaceInternalRefs, $options );
$options->{inMeta} = 0;
$to->forEachSelectedValue( qw/^FILEATTACHMENT$/, qw/^user$/,
\&_replaceInternalRefs, $options );

# Ok, let's look for links to topics in the
# new web and remove their web qualifiers
$webObject = Foswiki::Meta->new( $session, $to->web() );
$it = $webObject->eachTopic();

$options = {

# exclude this topic from the list
topics => [ $it->all() ],
fullPaths => 0,

inWeb => $to->web,
inTopic => $to->topic,

oldWeb => $to->web,

#oldTopic => will be filled in by _replaceInternalRefs

newWeb => $to->web,

#newTopic => will be filled in by _replaceInternalRefs
};

$text = $renderer->forEachLine( $text, \&_replaceInternalRefs, $options );

$to->text($text);

$options->{inMeta} = 1;
$to->forEachSelectedValue( qw/^(FIELD|TOPICPARENT)$/, undef,
\&_replaceInternalRefs, $options );
$to->forEachSelectedValue( qw/^TOPICMOVED$/, qw/^by$/,
\&_replaceInternalRefs, $options );
$options->{inMeta} = 0;
$to->forEachSelectedValue( qw/^FILEATTACHMENT$/, qw/^user$/,
\&_replaceInternalRefs, $options );

}

# callback used by _replaceWebInternalReferences to correct references
# to topics that were in the same web previously, but are now in a
# different web because the topic has moved. $args should be populated
# with oldWeb and newWeb already, so just need to add each topic as we
# process it.
sub _replaceInternalRefs {
my ( $text, $args ) = @_;

foreach my $topic ( @{ $args->{topics} } ) {
$args->{fullPaths} = ( $topic ne $args->{inTopic} )
if ( !defined( $args->{fullPaths} ) );
$args->{oldTopic} = $topic;
$args->{newTopic} = $topic;
$text = _replaceTopicReferences( $text, $args );
}
return $text;
}

# Display screen so user can decide on new web, topic, attachment names.
sub _newTopicOrAttachmentScreen {
my ( $session, $from, $to, $attachment, $toattachment, $confirm,
Expand Down

0 comments on commit 380afb2

Please sign in to comment.