Feature Proposal: Add option to allow statistics script to auto-create missing topics

Motivation

Currently we have to ship a dummy WebStatistics topic with each release. If the statistics run could auto-create missing statistics topics, we could omit the default topics from the release.

This would also simplify the archiving process for statistics. For example, admin could rename WebStatistics to WebStatistics2010, and the next run would create a new WebStatistics topic.

I've already restructured the topics a bit as part of Tasks.Item11182. Adding auto-create would complete the process and let us drop the WebStatistics topic from the build.

Description and Documentation

  • Add a configure option {Stats}{AutoCreateMissing} - default 'Prohibited'.
  • Add a url param autocreate to the statistics script.
  • If autocreate is true and permitted, the UI::Statistics will copy the (shipped) WebStatisticsTemplate topic from System web, or (if locally created) from Main web when it finds the WebStatistics topic is missing for a requested web.

  • Add a configure option {Stats}{StatisticsGroup} - default empty.
  • If this group is configured, then the statistics script will be restricted to members of the configured group.
  • Also add a configuration checker to warn if statistics is not listed in the AuthScripts list.
Under Tasks.Item11182 I started the work to have WebStatistics %INCLUDE a DefaultWebStatistics topic for the help text and table headings. Using a Template topic could eliminate the need for the DefaultWebStatistics topic. Or keep it anyway, so the text isn't duplicated in every web.

Examples

Impact

By shipping with default false, this should be low enough impact to include in 1.1.4.

%WHATDOESITAFFECT%
edit

Implementation

# **SELECT Prohibited, Allowed, Always**
# Set this parameter to <code>Allowed</code> if you want the statistics script to create a
# missing WebStatistics topic only when the parameter <code>autocreate=1</code> is supplied.
# Set it to <code>Always</code> if a missing WebStatistics topic should be created unless
# overridden by URL parameter <code>'autocreate=0'</code>.  <code>Prohibited</code> is
# the previous behavior and is the default.
$Foswiki::cfg{Stats}{AutoCreateTopic} = 'Prohibited';

# **STRING 20**
# If this is set to the name of a Group, then the statistics script will only run for
# members of that group.  Ex. Set to <code>AdminGroup</code> to restrict statistics to
# administrators.   Default is un-set.  Anyone can run statistics.
$Foswiki::cfg{Stats}{StatisticsGroup} = '';
-- Contributors: GeorgeClark - 15 Oct 2011

Discussion

After some offline discussion with Olivier Raginel, I've amended the above proposal to have 3 options for AutoCreate. Prohibited (the default), Allowed, and Always. This will prevent the urlparam autocreate from being used unless the site administrator permits it.

Also added an optional StatisticsGroup. if configured, statistics generation will be restricted to members of this group.

Currently statistics can be generated by anyone provided they have update authorization on the statistics topic. Even without authorization, the statistics are generated and only the "save" is prevented. This can create a significant server load, and the statistics script is not listed in the AuthorizedScripts list by default.

-- GeorgeClark - 21 Oct 2011
Topic revision: r5 - 02 Jan 2012, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy