Commit
All Foswiki::Func::* functions, except for deprecated ones, are either moved to Foswiki.pm if they're purely static. Otherwise they're made Foswiki::App methods except for a few defined in %_funcPrefixMap which are new methods of other classes where they natively belong. The purpose of this move is to minize use of the global $Foswiki::app and %Foswiki::cfg variables. Note Foswiki::Func maps moved functions using AUTOLOAD(). If a function gets called it gets generated using pretty simple code of checking if $Foswiki::app is defined and then calling corresponding method on it. AUTOLOAD() takes care of deprecated functions too. If it detects that function is still present in Foswiki::Func namespace and has '_deprecated_' prefix in its name then the code generated for the function will log a warning about use of a deprecation each time it gets called. - Foswiki::Aux::Holder can now use a object of any class with restore() method defined. - To be noted: Foswiki::Configure::Pluggables::SCRIPTHASH is using $Foswiki::engine in a regex. The variable isn't there anymore and the whole approach has been changed. Must be reconsidered. - Clean up of search/query methods parameters of modules in Foswiki::Store family: removed $app parameter and using object's app attribute instead. - Converted static _search() methods of Foswiki::Store::SearchAlgorythms into object methods. - Added reason object attribute on Foswiki::Meta. Must be given preference over $Foswiki::Meta::reason whenever possible. Though upon change the attribute sets the global variable to the same value.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,14 +46,15 @@ has handler => ( is => 'rw', lazy => 1, default => sub { {} }, ); | |
################################################################################ | ||
# static | ||
sub writeDebug { | ||
Foswiki::Func::writeDebug '- JsonRpcContrib::Server - ' . $_[0]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vrurg
Author
Member
|
||
my $this = shift; | ||
$this->app->writeDebug( '- JsonRpcContrib::Server - ' . $_[0] ); | ||
} | ||
|
||
################################################################################ | ||
sub registerMethod { | ||
my ( $this, $namespace, $method, $fnref, $options ) = @_; | ||
|
||
writeDebug("registerMethod($namespace, $method, $fnref)") if TRACE; | ||
$this->writeDebug("registerMethod($namespace, $method, $fnref)") if TRACE; | ||
|
||
$this->handler->{$namespace}{$method} = { | ||
function => $fnref, | ||
|
@@ -68,7 +69,7 @@ sub dispatch { | |
|
||
my $app = $ui->app; | ||
|
||
writeDebug("called dispatch") if TRACE; | ||
$this->writeDebug("called dispatch") if TRACE; | ||
|
||
my $request = $app->request; | ||
|
||
|
@@ -90,7 +91,7 @@ sub dispatch { | |
$topic ); | ||
$app->request->web($jsrpcWeb); | ||
$app->request->topic($jsrpcTopic); | ||
writeDebug("topic=$topic") if TRACE; | ||
$this->writeDebug("topic=$topic") if TRACE; | ||
|
||
# get handler for this namespace | ||
my $handler = $this->getHandler($request); | ||
|
@@ -109,7 +110,7 @@ sub dispatch { | |
# if there's login info, try and apply it | ||
my $userName = $request->param('username'); | ||
if ($userName) { | ||
writeDebug("checking password for $userName") if TRACE; | ||
$this->writeDebug("checking password for $userName") if TRACE; | ||
my $pass = $request->param('password') || ''; | ||
unless ( $app->users->checkPassword( $userName, $pass ) ) { | ||
Foswiki::Contrib::JsonRpcContrib::Response->print( | ||
|
@@ -155,7 +156,7 @@ sub dispatch { | |
try { | ||
no strict 'refs'; | ||
my $function = $handler->{function}; | ||
writeDebug( "calling handler for " | ||
$this->writeDebug( "calling handler for " | ||
. $request->namespace . "." | ||
. $request->jsonmethod ) | ||
if TRACE; | ||
|
@@ -242,7 +243,8 @@ sub getHandler { | |
my $def = | ||
$Foswiki::cfg{JsonRpcContrib}{Handler}{$namespace}{$method}; | ||
|
||
writeDebug("compiling $def->{package} for $namespace.$method") | ||
$this->writeDebug( | ||
"compiling $def->{package} for $namespace.$method") | ||
if TRACE; | ||
eval qq(use $def->{package}); | ||
|
||
|
Did you just empty Foswiki::Func??? That's not a good idea. It is the most common interface for any plugin that we tried to preserve while the engine underneath was changing during the years.