Skip to content

Commit

Permalink
Item13897: Removing finish() from the code.
Browse files Browse the repository at this point in the history
- First step to resolve circular dependencies by use of standard destruction
mechanizm and weak references. Tests are broken, removal of all finish()
calls is required.

- PageCache wasn't converted. Done.

- Finished incomplete convertion of Foswiki::Address and Foswiki::MetaCache.

- Warning is now generated by Foswiki::Object if finish() method is
detected available on the destruction stage.

- Foswiki::Object destructor now checks if there is a key on an object
which doesn't have corresponding method. Activated only in DEBUG mode.
Unreliable because getter/setter method names can be defined by user.
  • Loading branch information
vrurg committed Mar 6, 2016
1 parent 8c02395 commit 250991f
Show file tree
Hide file tree
Showing 31 changed files with 992 additions and 976 deletions.
@@ -1,11 +1,9 @@
# See bottom of file for license and copyright information
package EditTablePluginSuite;
use v5.14;

use strict;
use warnings;

use Unit::TestSuite;
our @ISA = 'Unit::TestSuite';
use Moo;
extends qw(Unit::TestSuite);

sub include_tests { return 'EditTablePluginTests' }

Expand Down
521 changes: 262 additions & 259 deletions EditTablePlugin/test/unit/EditTablePlugin/EditTablePluginTests.pm

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions UnitTestContrib/lib/Unit/Response.pm
Expand Up @@ -26,9 +26,9 @@ BEGIN {
$response = $t->response;
return $t;
};
my $_finish = \&Foswiki::finish;
*Foswiki::finish = sub {
$_finish->(@_);
my $_demolish = \&Foswiki::DEMOLISH;
*Foswiki::demolish = sub {
$_demolish->(@_);
undef $response;
};
use warnings 'redefine';
Expand Down
86 changes: 43 additions & 43 deletions UnitTestContrib/test/unit/AccessControlTests.pm
Expand Up @@ -50,7 +50,7 @@ around set_up => sub {
$Foswiki::cfg{DefaultUserWikiName} );
$topicObject->text('');
$topicObject->save();
$topicObject->finish();
undef $topicObject;
$this->registerUser( 'white', 'Mr', "White", 'white@example.com' );
$MrWhite = $this->session->users->getCanonicalUserID('white');
$this->registerUser( 'blue', 'Mr', "Blue", 'blue@example.com' );
Expand All @@ -71,7 +71,7 @@ around set_up => sub {
* Set ALLOWTOPICVIEW = $users_web.ReservoirDogsGroup
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

return;
};
Expand All @@ -95,7 +95,7 @@ sub DENIED {
"$user $mode $web.$topic"
);
}
$topicObject->finish();
undef $topicObject;

return;
}
Expand All @@ -119,7 +119,7 @@ sub PERMITTED {
"$user $mode $web.$topic"
);
}
$topicObject->finish();
undef $topicObject;

return;
}
Expand All @@ -141,7 +141,7 @@ If DENYTOPIC is set to a list of wikinames
* Set DENYTOPICVIEW = ,,MrYellow,,$users_web.MrOrange,%USERSWEB%.ReservoirDogsGroup,,,
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

$this->createNewFoswikiSession();
$this->PERMITTED( "VIEW", $MrGreen );
Expand All @@ -164,7 +164,7 @@ If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = )
* Set DENYTOPICVIEW=
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

$this->createNewFoswikiSession();
$this->PERMITTED( "VIEW", $MrGreen );
Expand All @@ -187,7 +187,7 @@ If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = )
* Set DENYTOPICVIEW =
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

$this->createNewFoswikiSession();
$this->PERMITTED( "VIEW", $MrGreen );
Expand All @@ -210,7 +210,7 @@ If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = )
* Set DENYTOPICVIEW = MrBlue
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

$this->createNewFoswikiSession();
$this->PERMITTED( "VIEW", $MrGreen );
Expand All @@ -234,7 +234,7 @@ If ALLOWTOPIC is set
* Set ALLOWTOPICVIEW = %USERSWEB%.MrOrange
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

$this->createNewFoswikiSession();
$this->PERMITTED( "VIEW", $MrOrange );
Expand All @@ -259,7 +259,7 @@ If ALLOWTOPIC is set
* Set ALLOWTOPICVIEW = %USERSWEB%.MrOrange
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

my $topicquery = Unit::Request->new( initializer => "" );
$topicquery->path_info( "/" . $this->test_web . "/" . $this->test_topic );
Expand Down Expand Up @@ -293,7 +293,7 @@ If ALLOWTOPIC is set
* Set ALLOWTOPICVIEW = %USERSWEB%.MrOrange
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# renew Foswiki, so WebPreferences gets re-read
$this->createNewFoswikiSession();
Expand Down Expand Up @@ -331,7 +331,7 @@ THIS
}
);
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# renew Foswiki, so WebPreferences gets re-read
$this->createNewFoswikiSession();
Expand Down Expand Up @@ -361,15 +361,15 @@ If DENYWEB is set to a list of wikiname
* Set DENYWEBVIEW = $users_web.MrOrange %USERSWEB%.MrBlue
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# renew Foswiki, so WebPreferences gets re-read
$this->createNewFoswikiSession();
($topicObject) =
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );
$topicObject->text("Null points");
$topicObject->save();
$topicObject->finish();
undef $topicObject;

$this->DENIED( "VIEW", $MrOrange );
$this->PERMITTED( "VIEW", $MrGreen );
Expand All @@ -393,7 +393,7 @@ If DENYWEB is set to a list of wikiname
* Set DENYWEBVIEW = $users_web.MrOrange %USERSWEB%.MrBlue
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# renew Foswiki, so WebPreferences gets re-read
$this->createNewFoswikiSession();
Expand All @@ -405,7 +405,7 @@ If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = )
* Set DENYTOPICVIEW = MrWhite
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

$this->DENIED( "VIEW", $MrOrange );
$this->PERMITTED( "VIEW", $MrGreen );
Expand All @@ -429,7 +429,7 @@ If DENYWEB is set to a list of wikiname
* Set DENYWEBVIEW = $users_web.MrOrange %USERSWEB%.MrBlue
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

($topicObject) =
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );
Expand All @@ -439,7 +439,7 @@ If DENYTOPIC is set to empty string
* Set DENYTOPICVIEW =
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# Verify that the new "empty deny" rule is ignored
# Also passes on Foswiki <1.2
Expand Down Expand Up @@ -482,7 +482,7 @@ If DENYWEB is set to the wildcard
* Set DENYWEBVIEW = *
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

($topicObject) =
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );
Expand All @@ -494,7 +494,7 @@ Except ALLOW at the topic will override DENY at web.
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# renew Foswiki, so WebPreferences gets re-read
$this->createNewFoswikiSession();
Expand All @@ -520,7 +520,7 @@ If DENYWEB is set to a list of wikiname
* Set DENYWEBVIEW = $users_web.MrOrange %USERSWEB%.MrBlue
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

($topicObject) =
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );
Expand All @@ -530,7 +530,7 @@ If DENYTOPIC is set to empty string
* Set ALLOWTOPICVIEW = *
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# Verify that the new "empty deny" rule is ignored
# Also passes on Foswiki <1.2
Expand Down Expand Up @@ -561,7 +561,7 @@ If DENYTOPIC is set to empty string
* Set ALLOWTOPICVIEW = $users_web.MrOrange %USERSWEB%.MrBlue
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# renew Foswiki, so WebPreferences gets re-read
$this->createNewFoswikiSession();
Expand Down Expand Up @@ -589,15 +589,15 @@ If ALLOWWEB is set to a list of wikinames
THIS
);
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# renew Foswiki, so WebPreferences gets re-read
$this->createNewFoswikiSession();
($topicObject) =
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );
$topicObject->text("Null points");
$topicObject->save();
$topicObject->finish();
undef $topicObject;
$this->DENIED( "VIEW", $MrOrange );
$this->PERMITTED( "VIEW", $MrGreen );
$this->PERMITTED( "VIEW", $MrYellow );
Expand All @@ -621,7 +621,7 @@ If ALLOWTOPIC is set
THIS
);
$topicObject->save();
$topicObject->finish();
undef $topicObject;
$this->createNewFoswikiSession();
$this->PERMITTED( "VIEW", $MrOrange );
$this->DENIED( "VIEW", $MrGreen );
Expand Down Expand Up @@ -660,13 +660,13 @@ THIS
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );
$topicObject->text($text);
$topicObject->save();
$topicObject->finish();
undef $topicObject;
$this->createNewFoswikiSession();

($topicObject) =
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );
$this->_checkSettings($topicObject);
$topicObject->finish();
undef $topicObject;

return;
}
Expand All @@ -686,14 +686,14 @@ sub test_setInMETA {
};
$topicObject->putKeyed( 'PREFERENCE', $args );
$topicObject->save();
$topicObject->finish();
undef $topicObject;
$this->createNewFoswikiSession();

($topicObject) =
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );

$this->_checkSettings($topicObject);
$topicObject->finish();
undef $topicObject;

return;
}
Expand All @@ -716,13 +716,13 @@ THIS
};
$topicObject->putKeyed( 'PREFERENCE', $args );
$topicObject->save();
$topicObject->finish();
undef $topicObject;
$this->createNewFoswikiSession();

($topicObject) =
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );
$this->_checkSettings($topicObject);
$topicObject->finish();
undef $topicObject;

return;
}
Expand All @@ -739,7 +739,7 @@ sub test_subweb_controls_override_parent {
Foswiki::Func::readTopic( $this->test_web, $this->test_topic );
$topicObject->text("Nowt");
$topicObject->save();
$topicObject->finish();
undef $topicObject;

($topicObject) =
Foswiki::Func::readTopic( $this->test_web,
Expand All @@ -748,18 +748,18 @@ sub test_subweb_controls_override_parent {
* Set ALLOWWEBVIEW = MrGreen
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# Now build a subweb with view restricted to MrOrange
my $webObject = $this->populateNewWeb($subweb);
$webObject->finish();
undef $webObject;
($topicObject) =
Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} );
$topicObject->text(<<'THIS');
* Set ALLOWWEBVIEW = MrOrange
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# Ensure that MrOrange can read the subweb and MrGreen the parent web
$this->createNewFoswikiSession();
Expand Down Expand Up @@ -788,17 +788,17 @@ sub test_subweb_inherits_from_parent {
* Set FINALPREFERENCES = ALLOWWEBVIEW
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# Now build a subweb with no restrictions
my $webObject = $this->populateNewWeb($subweb);
$webObject->finish();
undef $webObject;
($topicObject) =
Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} );
$topicObject->text(<<'THIS');
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

$this->createNewFoswikiSession();
$this->PERMITTED( "VIEW", $MrGreen, $subweb );
Expand Down Expand Up @@ -826,18 +826,18 @@ sub test_finalised_parent_overrides_subweb {
* Set FINALPREFERENCES = ALLOWWEBVIEW
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# Now build a subweb with view restricted to MrOrange
my $webObject = $this->populateNewWeb($subweb);
$webObject->finish();
undef $webObject;
($topicObject) =
Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} );
$topicObject->text(<<'THIS');
* Set ALLOWWEBVIEW = MrOrange
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;
$this->createNewFoswikiSession();

$this->DENIED( "VIEW", $MrOrange, $subweb );
Expand Down Expand Up @@ -866,7 +866,7 @@ anchor is preserved after login.
* Set ALLOWTOPICVIEW = MrYellow
THIS
$topicObject->save();
$topicObject->finish();
undef $topicObject;

# Request the page with the full UI
my $query = Unit::Request->new(
Expand Down

0 comments on commit 250991f

Please sign in to comment.