Skip to content

Commit

Permalink
Item12952: moved admin-only DEPENDENCYREPORT macro into the core wher…
Browse files Browse the repository at this point in the history
…e it belongs, and renamed it to PERLDEPENDENCYREPORT to avoid confusion with DISPLAYDEPENDENCIES (which relates to the cache)
  • Loading branch information
crawford committed Sep 25, 2014
1 parent 8375be2 commit dc1865f
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 55 deletions.
7 changes: 1 addition & 6 deletions ConfigurePlugin/data/System/ConfigurePlugin.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1411582947" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1411624271" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}%
<!--
One line description, required for extensions repository catalog.
Expand Down Expand Up @@ -33,11 +33,6 @@ Users of the =configure= interface access it through the CGI script in
=bin/configure=. The UI is self-explanatory and needs no further introduction
here.

The plugin also provides a =%<nop>DEPENDENCYREPORT% macro for use in
wiki topics. The dependency report analyzes the identified perl
dependencies for %WIKITOOLNAME% and all installed extensions, and
reports any issues with installed versions of the dependencies.

Of interest to developers may be the JSON RPC interface provided by the
plugin, which gives access to the Foswiki configuration to web clients
(who must, of course, be authenticated as admins to make RPC calls).
Expand Down
45 changes: 13 additions & 32 deletions ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin.pm
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# See bottom of file for default license and copyright information

# Note on separation of concerns: Please *do not* add anything to this
# plugin that is not specific to the Javascript 'configure' interface.
# Generic functionality related to configuration should be implemented
# in the core. The ConfigurePlugin is *just* for handling the UI, no more.

# Note that POD in this module is included in the documentation topic
# by BuildContrib

=pod
---++ Remote Procedure Call (RPC) interface
RPC calls are handled via the =JsonRpcContrib=. Callers must authenticate
as admins, or the request will be rejected with a 403 status.
Expand Down Expand Up @@ -33,7 +39,7 @@ use Foswiki::Configure::Reporter ();
use Foswiki::Configure::Checker ();
use Foswiki::Configure::Wizard ();

our $RELEASE = '29 May 2013';
our $RELEASE = '25 Sep 2014';
our $SHORTDESCRIPTION = '=configure= interface using json-rpc';

our $NO_PREFS_IN_TOPIC = 1;
Expand Down Expand Up @@ -105,35 +111,10 @@ sub initPlugin {
}
}

Foswiki::Func::registerTagHandler( 'DEPENDENCYREPORT',
\&_DEPENDENCYREPORT );

return 1;

}

sub _DEPENDENCYREPORT {
my ( $session, $params, $topic, $web ) = @_;

require Foswiki::Plugins::ConfigurePlugin::DependencyReport;

print STDERR "PARAM = ($params->{_DEFAULT}) \n"
if defined $params->{_DEFAULT};

if ( defined $params->{_DEFAULT}
&& $params->{_DEFAULT} =~ m/'?extensions'?/ )
{
return
Foswiki::Plugins::ConfigurePlugin::DependencyReport::analyzeExtensions(
);
}
else {
return
Foswiki::Plugins::ConfigurePlugin::DependencyReport::analyzeFoswiki();
}

}

sub _JSONwrap {
my $method = shift;
return sub {
Expand Down Expand Up @@ -169,18 +150,18 @@ sub _JSONwrap {
}

# Canonicalise a key string
sub safeKeys {
sub _safeKeys {
my $k = shift;
$k =~ s/^{(.*)}$/$1/;
return '{'
. join( '}{',
map { $_ =~ s/^(['"])(.*)\1$/$2/; safeKey($_) }
map { $_ =~ s/^(['"])(.*)\1$/$2/; _safeKey($_) }
split( /}{/, $k ) )
. '}';
}

# Make a single key safe for use in a canonical key string
sub safeKey {
sub _safeKey {
my $k = shift;
return $k if ( $k =~ /^[a-z_][a-z0-9_]*$/i );
$k =~ s/'/\\'/g;
Expand Down Expand Up @@ -733,7 +714,7 @@ sub changecfg {
/^($Foswiki::Plugins::ConfigurePlugin::SpecEntry::configItemRegex)$/;

# Implicit untaint
$key = safeKeys($1);
$key = _safeKeys($1);
if ( eval "exists \$Foswiki::cfg$key" ) {
print STDERR "Cleared $key\n" if TRACE;
$cleared++;
Expand All @@ -748,7 +729,7 @@ sub changecfg {
/^($Foswiki::Plugins::ConfigurePlugin::SpecEntry::configItemRegex)$/;

# Implicit untaint
$key = safeKeys($1);
$key = _safeKeys($1);
if ( eval "exists \$Foswiki::cfg$key" ) {
my $oval = eval "\$Foswiki::cfg$key";
if ( ref($oval) || $oval =~ /^[0-9]+$/ ) {
Expand Down Expand Up @@ -815,7 +796,7 @@ sub _lscify {
}
if ( ref($data) eq 'HASH' ) {
foreach my $sk ( sort keys %$data ) {
my $c = _lscify( $specs, $data->{$sk}, ( @path, safeKey($sk) ) );
my $c = _lscify( $specs, $data->{$sk}, ( @path, _safeKey($sk) ) );
push( @content, @$c );
}
}
Expand Down
3 changes: 0 additions & 3 deletions ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin/MANIFEST
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
!noci
bin/configure
data/System/ConfigurePlugin.txt 0644 Documentation page
data/System/DependencyReport.txt 0644 System dependency report
data/System/VarDEPENDENCYREPORT.txt 0644 Documentation page
lib/Foswiki/Plugins/ConfigurePlugin.pm 0444 Perl module
lib/Foswiki/Plugins/ConfigurePlugin/Config.spec 0444 Configuration
lib/Foswiki/Plugins/ConfigurePlugin/JQuery.pm 0444 Configuration
lib/Foswiki/Plugins/ConfigurePlugin/DependencyReport.pm 0444 Configuration
pub/System/ConfigurePlugin/checkWhirly.gif 0444
pub/System/ConfigurePlugin/configure.css 0444
pub/System/ConfigurePlugin/configure.css.gz 0444
Expand Down
3 changes: 2 additions & 1 deletion core/data/System/InstallationGuide.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1408949368" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1411624271" format="1.1" version="1"}%
%META:TOPICPARENT{name="AdminDocumentationCategory"}%
---+!! Installation Guide

Expand Down Expand Up @@ -229,6 +229,7 @@ In order to keep your user, group, and site configuration information separate f
If you are having problems with your installation, try the following:

* Run the =configure= script and ensure you have resolved all errors and are satisfied that you understand any warnings.
* Review the [[%SYSTEMWEB%.PerlDependencyReport]] and sure all dependencies are correctly resolved.
* Consult the topics at Foswiki:Support.SupplementalDocuments and Foswiki:Support.AskedQuestions.
* Ask for help on [[Foswiki:Community.InternetRelayChat][IRC]] (irc.freenode.net, channel #foswiki). There are often a number of people waiting to help.
* Ask a question in the Foswiki:Support web
Expand Down
27 changes: 27 additions & 0 deletions core/data/System/PerlDependencyReport.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1411624271" format="1.1" reprev="1" version="1"}%
%META:TOPICPARENT{name="InstallationGuide"}%

---+!! Perl dependencies for Foswiki and Extensions

This topic lists the perl module dependencies required by the Foswiki core
and installed extensions. It is designed to help administrators analyse and
resolve missing perl dependencies.

The module name links to the module information on the
[[https://metacpan.org][Comprehensive Perl Archive Network (CPAN)]].
In the report, all users of the module are identified (including the Foswiki
core). If a minimum version can be determined identified, the extension
requiring the highest minimum version is underlined.

%TOC%

<noautolink>
---++ Foswiki dependencies

%PERLDEPENDENCYREPORT%

---++ Foswiki extension dependencies

%PERLDEPENDENCYREPORT{'extensions'}%
</noautolink>

11 changes: 11 additions & 0 deletions core/data/System/VarPERLDEPENDENCYREPORT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%META:TOPICINFO{author="ProjectContributor" date="1411624271" format="1.1" version="1"}%
%META:TOPICPARENT{name="macros"}%
#VarPERLDEPENDENCYREPORT
---+++ PERLDEPENDENCYREPORT -- report the perl module dependencies and status for Foswiki core and extensions
* Syntax: =%<nop>PERLDEPENDENCYREPORT%=
---+++ DEPENDENCYREPORT{"extensions"} -- report the perl module dependencies for the installed extensions
* Syntax: =%<nop>PERLDEPENDENCYREPORT{"extensions"}%=
* Supported parameters:
| *Parameter:* | *Description:* | *Default:* |
| ="extensions"= | The word ="extensions" - requests dependencies of installed extensions. | (not set) |
* See also: %SYSTEMWEB%.PerlDependencyReport
27 changes: 14 additions & 13 deletions core/lib/Foswiki.pm
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,20 @@ BEGIN {

#deprecated functionality, now implemented using %ENV%
sub { $_[0]->{request}->header('Host') || '' },
HTTP => undef,
HTTPS => undef,
ICON => undef,
ICONURL => undef,
ICONURLPATH => undef,
IF => undef,
INCLUDE => undef,
INTURLENCODE => undef,
LANGUAGE => sub { $_[0]->i18n->language(); },
LANGUAGES => undef,
MAKETEXT => undef,
META => undef, # deprecated
METASEARCH => undef, # deprecated
HTTP => undef,
HTTPS => undef,
ICON => undef,
ICONURL => undef,
ICONURLPATH => undef,
IF => undef,
INCLUDE => undef,
INTURLENCODE => undef,
LANGUAGE => sub { $_[0]->i18n->language(); },
LANGUAGES => undef,
MAKETEXT => undef,
META => undef, # deprecated
METASEARCH => undef, # deprecated
PERLDEPENDENCYREPORT => undef,
NOP =>

# Remove NOP tag in template topics but show content.
Expand Down
3 changes: 3 additions & 0 deletions core/lib/Foswiki/Contrib/core/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ data/System/MetaData.txt 0644
data/System/ObjectMethod.txt 0644
data/System/PageCaching.txt 0644
data/System/ParentList.txt 0644
data/System/PerlDependencyReport.txt 0644
data/System/PerlDoc.txt 0644
data/System/PlainSkin.txt 0644
data/System/Plugins.txt 0644
Expand Down Expand Up @@ -258,6 +259,7 @@ data/System/VarNOTIFYTOPIC.txt 0644
data/System/VarOLIVE.txt 0644
data/System/VarORANGE.txt 0644
data/System/VarP.txt 0644
data/System/VarPERLDEPENDENCYREPORT.txt 0644 System dependency report
data/System/VarPINK.txt 0644
data/System/VarPLUGINDESCRIPTIONS.txt 0644
data/System/VarPLUGINVERSION.txt 0644
Expand Down Expand Up @@ -619,6 +621,7 @@ lib/Foswiki/Macros/LANGUAGES.pm 0444
lib/Foswiki/Macros/MAKETEXT.pm 0444
lib/Foswiki/Macros/META.pm 0444
lib/Foswiki/Macros/METASEARCH.pm 0444
lib/Foswiki/Macros/PERLDEPENDENCYREPORT.pm 0444 Configuration
lib/Foswiki/Macros/PUBURL.pm 0444
lib/Foswiki/Macros/QUERY.pm 0444
lib/Foswiki/Macros/QUERYPARAMS.pm 0444
Expand Down
Loading

0 comments on commit dc1865f

Please sign in to comment.