-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item11983: Build patch contrib for 1.1.5 / 1.1.6
git-svn-id: http://svn.foswiki.org/trunk/PatchItem11983Contrib@16156 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
- Loading branch information
GeorgeClark
authored and
GeorgeClark
committed
Dec 6, 2012
0 parents
commit 60d5618
Showing
8 changed files
with
332 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!-- | ||
One line description, required for extensions repository catalog. | ||
* Set SHORTDESCRIPTION = Patch Foswiki 1.1.5 and 1.1.6 store to improve perfomance | ||
--> | ||
---+!! PatchItem11983Contrib | ||
|
||
%SHORTDESCRIPTION% | ||
|
||
%TOC% | ||
|
||
---++ Usage | ||
|
||
This extensions applies a "hotfix" for Item11983 to your Foswiki 1.1.5 or 1.1.6 system. | ||
|
||
<blockquote> | ||
<div class="foswikiAlert">%X% *CAUTION:* This patch can significantly improve the performance of the Foswiki "Store" system by reducing calls to the "RCS" - | ||
Revision Control System. However it removes critical checks that are performed to detect topics that have been externally modified outside of | ||
Foswiki. *This fix is not recommended if you have topics will be, or have been modified externally.* This includes: | ||
<ul><li>Topic.txt files manually edited without updating the =%META:TOPICINFO= line, and without checking them into RCS. | ||
<li>Topic.txt files that are created or modified by external processes. | ||
</ul> </div> | ||
</blockquote> | ||
|
||
When this extension is installed, it uses the Post-installation exit to apply any patch files found in the manifest. This extension ships with a hotfix for the following items: | ||
|
||
| *Original Issue* | *Patch File* | *Description* | | ||
| [[http://foswiki.org/Tasks/Item11983][Item11983]] | =Item11983-001= | Reduce calls to RCS made by Store to verify the TOPICINFO information. | | ||
|
||
Before any file is patched, a backup is copied to =working/configure/backup/<Item11983-001-date-time>=. Each file that is a candidate to be patched is backed up. If the extensions is installed multple times, a new backup is made for each run, regardless of whether or not the patch will be applied. For this patch, the following files are copied: | ||
* =lib/Foswiki/Store/VC/Store.pm= | ||
* =lib/Foswiki/Store/VC/Handler.pm= | ||
|
||
Patches are only applied if the target file is an _exact_ match to the original file. There is no attempt to do "fuzzy" patching. Note however that a patch can be built to cover multiple versions of the file. | ||
|
||
There is no "dependency order" established between patches. Patches are installed in order of their patch file name. | ||
|
||
Patches will be mapped from the default Foswiki filename to the directory location used on the target system. | ||
|
||
|
||
---++ Installation | ||
%$INSTALL_INSTRUCTIONS% | ||
|
||
---++ Info | ||
|
||
| Author: | GeorgeClark | | ||
| Copyright ©: | Foswiki Contributors | | ||
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | ||
| Dependencies: | %$DEPENDENCIES% | | ||
| Version: | %$VERSION% | | ||
| Change History: | <!-- versions below in reverse order --> | | ||
| 1.0 (05 Dec 2012) | Initial version | | ||
| Home: | http://foswiki.org/Extensions/%TOPIC% | | ||
| Support: | http://foswiki.org/Support/%TOPIC% | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# See bottom of file for default license and copyright information | ||
|
||
=begin TML | ||
---+ package Foswiki::Contrib::PatchItem11983Contrib | ||
This is a stub module for a new contrib. Customise this module as | ||
required. | ||
=cut | ||
|
||
package Foswiki::Contrib::PatchItem11983Contrib; | ||
|
||
# Always use strict to enforce variable scoping | ||
use strict; | ||
use warnings; | ||
|
||
# $VERSION is referred to by Foswiki, and is the only global variable that | ||
# *must* exist in this package. This should always be in the format | ||
# $Rev$ so that Foswiki can determine the checked-in status of the | ||
# extension. | ||
our $VERSION = '1.0'; | ||
|
||
# $RELEASE is used in the "Find More Extensions" automation in configure. | ||
# It is a manually maintained string used to identify functionality steps. | ||
# You can use any of the following formats: | ||
# tuple - a sequence of integers separated by . e.g. 1.2.3. The numbers | ||
# usually refer to major.minor.patch release or similar. You can | ||
# use as many numbers as you like e.g. '1' or '1.2.3.4.5'. | ||
# isodate - a date in ISO8601 format e.g. 2009-08-07 | ||
# date - a date in 1 Jun 2009 format. Three letter English month names only. | ||
# Note: it's important that this string is exactly the same in the extension | ||
# topic - if you use %$RELEASE% with BuildContrib this is done automatically. | ||
our $RELEASE = '1.0'; | ||
|
||
our $SHORTDESCRIPTION = | ||
'Improve Store performance for Foswiki 1.1.5 and 1.1.6.'; | ||
|
||
1; | ||
|
||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Author: GeorgeClark | ||
Copyright (C) 2008-2011 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ONLYIF ( $Foswiki::Plugins::VERSION < 2.3) | ||
Foswiki::Contrib::PatchFoswikiContrib, >=1.3, perl, Required for old Foswiki versions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
!noci | ||
data/System/PatchItem11983Contrib.txt 0644 | ||
lib/Foswiki/Contrib/PatchItem11983Contrib.pm 0444 | ||
working/configure/patch/Item11983-001.patch 0644 Patch to improve Store performance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
my $this = shift; | ||
my $msgs = ''; | ||
|
||
foreach my $key ( grep /^working.*\.patch/, sort keys %{ $this->{_manifest} } ) | ||
{ | ||
|
||
my $patchFile = Foswiki::Configure::Util::mapTarget( $this->{_root}, $key ); | ||
|
||
$msgs .= "Processing $patchFile\n"; | ||
|
||
require Foswiki::Configure::PatchFile; | ||
my %result = Foswiki::Configure::PatchFile::parsePatch($patchFile); | ||
|
||
$msgs .= $result{error} if ( $result{error} ); | ||
$msgs .= $result{summary} if ( $result{summary} ); | ||
|
||
unless ( $result{error} ) { | ||
$msgs .= | ||
Foswiki::Configure::PatchFile::backupTargets( $this->{_root}, | ||
\%result ); | ||
$msgs .= | ||
Foswiki::Configure::PatchFile::applyPatch( $this->{_root}, \%result ); | ||
} | ||
|
||
} | ||
|
||
return $msgs; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/perl -w | ||
# | ||
# Example build class. Copy this file to the equivalent place in your | ||
# plugin or contrib and edit. | ||
# | ||
# Read the comments at the top of lib/Foswiki/Contrib/Build.pm for | ||
# details of how the build process works, and what files you | ||
# have to provide and where. | ||
# | ||
# Requires the environment variable FOSWIKI_LIBS (a colon-separated path | ||
# list) to be set to point at the build system and any required dependencies. | ||
# Usage: ./build.pl [-n] [-v] [target] | ||
# where [target] is the optional build target (build, test, | ||
# install, release, uninstall), test is the default. | ||
# Two command-line options are supported: | ||
# -n Don't actually do anything, just print commands | ||
# -v Be verbose | ||
# | ||
|
||
# Standard preamble | ||
use strict; | ||
use warnings; | ||
|
||
BEGIN { unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} ); } | ||
|
||
use Foswiki::Contrib::Build; | ||
|
||
# Create the build object | ||
my $build = new Foswiki::Contrib::Build('PatchItem11983Contrib'); | ||
|
||
# Build the target on the command line, or the default target | ||
$build->build( $build->{target} ); | ||
|
||
=begin TML | ||
You can do a lot more with the build system if you want; for example, to add | ||
a new target, you could do this: | ||
<verbatim> | ||
{ | ||
package MyModuleBuild; | ||
our @ISA = qw( Foswiki::Contrib::Build ); | ||
sub new { | ||
my $class = shift; | ||
return bless( $class->SUPER::new( "MyModule" ), $class ); | ||
} | ||
sub target_mytarget { | ||
my $this = shift; | ||
# Do other build stuff here | ||
} | ||
} | ||
# Create the build object | ||
my $build = new MyModuleBuild(); | ||
</verbatim> | ||
You can also specify a different default target server for uploads. | ||
This can be any web on any accessible Foswiki installation. | ||
These defaults will be used when expanding tokens in .txt | ||
files, but be warned, they can be overridden at upload time! | ||
<verbatim> | ||
# name of web to upload to | ||
$build->{UPLOADTARGETWEB} = 'Extensions'; | ||
# Full URL of pub directory | ||
$build->{UPLOADTARGETPUB} = 'http://foswiki.org/pub'; | ||
# Full URL of bin directory | ||
$build->{UPLOADTARGETSCRIPT} = 'http://foswiki.org/bin'; | ||
# Script extension | ||
$build->{UPLOADTARGETSUFFIX} = ''; | ||
</verbatim> | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
Author: MichaelDaum | ||
Date: Mon Nov 26 04:32:23 2012 +0000 | ||
|
||
Item11983: prevent excessive calls into the revision system | ||
|
||
This patch removes calls to the RevisionControlSystem (RCS) to verify the | ||
META::TOPICINFO for the topic. This change trades performance with some risk | ||
manually edited or externally modified will report incorrect revision information | ||
|
||
Foswiki 1.2 will have a more extensive fix that avoids incorrect revision information | ||
without incuring the performance penalty. | ||
|
||
~~~PATCH 596b5999cb61f941b5425555d9d232c4 lib/Foswiki/Store/VC/Store.pm (Foswiki 1.1.5, Foswiki 1.1.6) | ||
--- ./lib/Foswiki/Store/VC/Store.pm.orig 2012-12-06 00:56:34.138034928 -0500 | ||
+++ ./lib/Foswiki/Store/VC/Store.pm 2012-12-06 00:56:53.163811954 -0500 | ||
@@ -93,15 +93,16 @@ | ||
$text =~ s/\r//g; # Remove carriage returns | ||
$topicObject->setEmbeddedStoreForm($text); | ||
|
||
- unless ( $handler->noCheckinPending() ) { | ||
- | ||
- # If a checkin is pending, fix the TOPICINFO | ||
- my $ri = $topicObject->get('TOPICINFO'); | ||
- my $truth = $handler->getInfo($version); | ||
- for my $i (qw(author version date)) { | ||
- $ri->{$i} = $truth->{$i}; | ||
- } | ||
- } | ||
+ # Item11983 - switched off for performance reasons | ||
+# unless ( $handler->noCheckinPending() ) { | ||
+# | ||
+# # If a checkin is pending, fix the TOPICINFO | ||
+# my $ri = $topicObject->get('TOPICINFO'); | ||
+# my $truth = $handler->getInfo($version); | ||
+# for my $i (qw(author version date)) { | ||
+# $ri->{$i} = $truth->{$i}; | ||
+# } | ||
+# } | ||
|
||
my $gotRev = $version; | ||
unless ( defined $gotRev ) { | ||
@@ -260,8 +261,16 @@ | ||
|
||
sub getVersionInfo { | ||
my ( $this, $topicObject ) = @_; | ||
- my $handler = $this->getHandler($topicObject); | ||
- return $handler->getInfo( $topicObject->getLoadedRev() ); | ||
+ | ||
+ $topicObject->loadVersion() unless $topicObject->latestIsLoaded(); | ||
+ my $info = $topicObject->get('TOPICINFO'); | ||
+ | ||
+ if ( not defined $info ) { | ||
+ my $handler = $this->getHandler($topicObject); | ||
+ $info = $handler->getInfo( $topicObject->getLoadedRev() ); | ||
+ } | ||
+ | ||
+ return $info; | ||
} | ||
|
||
sub saveAttachment { | ||
|
||
~~~PATCH d6e0928805bfcc5442a4b329e50488a5 lib/Foswiki/Store/VC/Handler.pm (Foswiki 1.1.5) | ||
--- ./lib/Foswiki/Store/VC/Handler.pm.orig 2012-12-06 00:56:34.142034883 -0500 | ||
+++ ./lib/Foswiki/Store/VC/Handler.pm 2012-12-06 00:56:53.163811954 -0500 | ||
@@ -446,7 +446,17 @@ | ||
sub getLatestRevisionID { | ||
my $this = shift; | ||
return 0 unless -e $this->{file}; | ||
- my $rev = $this->_numRevisions() || 1; | ||
+ | ||
+ my $info = {}; | ||
+ my $rev; | ||
+ | ||
+ $this->_getTOPICINFO($info); | ||
+ $rev = $info->{version}; | ||
+ | ||
+ unless ( defined $rev ) { | ||
+ $rev = $this->_numRevisions() || 1; | ||
+ } | ||
+ | ||
|
||
# If there is a pending pseudo-revision, need n+1, but only if there is | ||
# an existing history | ||
|
||
~~~PATCH 497d27bc2cd58232e9b54eaa63877851 lib/Foswiki/Store/VC/Handler.pm (Foswiki 1.1.6) | ||
--- ./lib/Foswiki/Store/VC/Handler.pm.orig 2012-12-06 10:25:55.865698878 -0500 | ||
+++ ./lib/Foswiki/Store/VC/Handler.pm 2012-12-06 10:27:51.505358144 -0500 | ||
@@ -446,7 +446,17 @@ | ||
sub getLatestRevisionID { | ||
my $this = shift; | ||
return 0 unless -e $this->{file}; | ||
- my $rev = $this->_numRevisions() || 1; | ||
+ | ||
+ my $info = {}; | ||
+ my $rev; | ||
+ | ||
+ $this->_getTOPICINFO($info); | ||
+ $rev = $info->{version}; | ||
+ | ||
+ unless ( defined $rev ) { | ||
+ $rev = $this->_numRevisions() || 1; | ||
+ } | ||
+ | ||
|
||
# If there is a pending pseudo-revision, need n+1, but only if there is | ||
# an existing history | ||
|