Difference between revisions of "WikiDebug/show revision"

From TestWiki
Jump to: navigation, search
m (moved Debugging tools/show version to WikiDebug/show version: Let's name it for the extension.)
m (Example 1: WikiDebug.php: not revision 9 any more!)
Line 20: Line 20:
 
== Example 1: WikiDebug.php ==
 
== Example 1: WikiDebug.php ==
  
The following code shows the current revision of the WikiDebug.php file, which contains the SVN revision string <code>$Rev: 9 $</code>:
+
The following code shows the current revision of the WikiDebug.php file, which contains the SVN revision string <code>$Rev: X $</code> (where X is the current revision number):
  
 
<html4strict>Result: <show_version file="WikiDebug.php"></show_version></html4strict>
 
<html4strict>Result: <show_version file="WikiDebug.php"></show_version></html4strict>

Revision as of 21:44, 19 October 2011

IMPORTANT NOTE - THIS WILL BE RENAMED TO show_revision IN THE NEXT RELEASE!

The WikiDebug extension adds a new tag that allows you to display the Subversion revision number of a specified file. It currently detects and reports the first instance of any of the following SVN keywords (which are all aliases for the current file revision): Rev, LastChangedRevision, Revision.

Note - If you know of any other common version strings that it would be useful to add to this list (e.g. those used by other revision control systems) then please let me know via the talk page.

Syntax

<show_version file="{FileName}"></show_version>
  • {FileName} is the name of a file residing on the server.

As a security measure this extension will only allow display of tables added to the $wgWikiDebug_ViewableFiles array. Any other files are blocked.

For example, to view the version number for the file containing this extension, you would need to add the following to LocalSettings.php:

$wgWikiDebug_ViewableFiles[] = "WikiDebug.php";

Note that paths are relative to the current include path, which includes the extensions directory on this wiki, but which may not on yours.

Example 1: WikiDebug.php

The following code shows the current revision of the WikiDebug.php file, which contains the SVN revision string $Rev: X $ (where X is the current revision number):

Result: <show_version file="WikiDebug.php"></show_version>

Result: (rev 2439)

Example 2: Non-viewable file

Here is an attempt to view LocalSettings.php. Because this file is not in the array of allowed files, you are unable to see it's contents:

Result: <show_version file="LocalSettings.php"></show_version>

Result: (File cannot be viewed. It either does not exist, or is protected against viewing.)

Example 3: File with no revision number

There are currently no viewable files on the wiki which do not have a revision number, but if you were to use the tag to view such a file, you would get the following:

Result: <show_version file="SomeFileWithoutRevision.php"></show_version>

Result: (version unknown)