internal package Foswiki::Configure::Checker

See PublishedAPI for packages intended to be used by Plugin and Contrib authors, or browse all packages.
See also Developing plugins, Developer's Bible, Technical Overview

internal package Foswiki::Configure::Checker; is a Foswiki::Configure::UI

Base class of all checkers. Checkers give checking and guessing support for configuration values. Most of the methods of this class are intended to be protected i.e. only available to subclasses.

ObjectMethod check($value) → $html

  • $value - Value object for the thing being checked

Entry point for the value check. Overridden by subclasses.

Returns html formatted by $this->ERROR(), WARN(), NOTE(), or hand made OR an empty string. The output of a checker will normally be included in an HTML table, so don't get too carried away.

PROTECTED ObjectMethod guessed($status) -> $html

A checker can either check the sanity of the previously saved value, or guess a one if none exists. If the checker guesses, it should call $this->guessed(0) (passing 1 if the guess was an error).

ObjectMethod getCfg($name) → $expanded_val

Get the value of the named configuration var. The name is in the form getCfg("{Validation}{ExpireKeyOnUse}")

Any embedded references to other Foswiki::cfg vars will be expanded.

PROTECTED ObjectMethod warnAboutWindowsBackSlashes($path) -> $html

Generate a warning if the supplied pathname includes windows-style path separators.

PROTECTED ObjectMethod guessMajorDir($cfg, $dir, $silent) -> $html

Try and guess the path of one of the major directories, by looking relative to the absolute pathname of the dir where configure is being run.

PROTECTED ObjectMethod showExpandedValue -> $html

Return the expanded value of a parameter as a note for display.

PROTECTED ObjectMethod checkTreePerms($path, $perms, $filter) -> $html

Perform a recursive check of the specified path. The recursive check is limited to the configured "PathCheckLimit". This prevents excessive delay on installations with large data or pub directories. The count of files checked is available in the class method $this->{fileCount}

$perms is a string of permissions to check:

Basic checks:
  • r - File or directory is readable
  • w - File or directory is writable
  • x - File is executable.

All failures of the basic checks are reported back to the caller.

Enhanced checks:
  • d - Directory permission matches the permissions in {RCS}{dirPermission}
  • f - File permission matches the permission in {RCS}{filePermission} (FUTURE)
  • p - Verify that a WebPreferences exists for each web

If > 20 enhanced errors are encountered, reporting is stopped to avoid excessive errors to the administrator. The count of enhanced errors is reported back to the caller by the object variable: $this->{fileErrors}

In addition to the basic and enhanced checks specified in the $perms string, Directories are always checked to determine if they have the 'x' permission.

$filter is a regular expression. Files matching the supplied regex if present will not be checked. This is used to skip rcs,v or .txt files because they have different permission requirements.

Note that the enhanced checks are important especially on hosted sites. In some environments, the Foswiki perl scripts run under a different user/group than the web server. Basic checks will pass, but the server may still be unable to access the file. The enhanced checks will detect this condition.

Callers of this checker should reset $this->{fileCount} and $this->{fileErrors} to zero before calling this routine.

PROTECTED ObjectMethod checkCanCreateFile($path) -> $html

Check that the given path can be created (or, if it already exists, can be written). If the existing path is a directory, recursively check for rw permissions using checkTreePerms.

Returns a message or the empty string if the check passed.

PROTECTED ObjectMethod checkGnuProgram($prog) -> $html

Check for the availability of a GNU program.

Since Windows (without Cygwin) makes it hard to capture stderr ('2>&1' works only on Win2000 or higher), and Windows will usually have GNU tools in any case (installed for Foswiki since there's no built-in diff, grep, patch, etc), we only check for these tools on Unix/Linux and Cygwin.

PROTECTED ObjectMethod checkRE($keys) -> $html

Check that the configuration item identified by the given keys represents a compilable perl regular expression.

PROTECTED ObjectMethod checkRCSProgram($prog) -> $html

Specific to RCS, this method checks that the given program is available. Check is only activated when the selected store implementation is RcsWrap.

Topic revision: r1 - 19 Apr 2011, ProjectContributor
This site is powered by FoswikiCopyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki? Send feedback