Difference between revisions of "WikiDebug"

From TestWiki
Jump to: navigation, search
(Added icon)
(Updated to reflect new name.)
 
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Image:Tools icon.png|right]]
+
{{ExtensionCheck|WikiDebug}}
This extension contains a small set of tools that I find useful when debugging my extensions.  I have not prepared a downloadable version of the file yet, but the full source code is listed towards the bottom of this page.
+
{{On MediaWiki.org|WikiDebug}}
 +
This extension contains a small set of tools that I find useful when debugging my extensions, or when making them available to others.  I periodically add tools as I find a need, and may consider requests from other people if I find them interesting or useful enough.
  
Currently the extension contains two tools: 'describe_table' and 'show_source'.
+
<div style="border: 1px solid #CCCCCC; padding: 0.2em 0.5em 0.5em 0.5em; margin: 1em; float: left;">
 +
* '''[[/describe_table|&lt;describe_table&gt;]]''' - allows you to output the structure of a DB table on a wiki page.
 +
* '''[[/show_source|&lt;show_source&gt;]]''' - displays the contents of a named file on a wiki page.
 +
* '''[[/show_revision|&lt;show_revision&gt;]]''' - displays the Subversion revision number of the specified file.
 +
* '''[[/IfExtensionPresent|<nowiki>{{#IfExtensionPresent: ...}}</nowiki>]]''' - Parser hook so you can alter page content depending on whether an extension is installed on the wiki.
 +
</div>
 +
<br clear="both" />
  
__TOC__
+
'''Current version: <show_revision file="WikiDebug.php" />'''<br>
 
+
The source is available under [[/show_source#Example 1: WikiDebug.php|example 1 of the show_source page]].
== describe_table ==
+
 
+
This extension adds a new tag that allows you to get a live description of a DB table.
+
 
+
=== Syntax ===
+
 
+
<html4strict><describe_table table="{TableName}" showindexes="{bool}"></describe_table></html4strict>
+
 
+
* {TableName} is the name of a table in the wiki's database.  Do not include the prefix specified by $wgPrefix.
+
* showindexes is an optional argument, which defaults to true if omitted.  Set to false to disable index display.
+
 
+
As a security measure this extension will only allow display of tables added to the $wgWikiDebug_ViewableTables array.  Any other tables are blocked. 
+
 
+
For example, to view the table 'page', you would need to add the following to LocalSettings.php:
+
<php>$wgWikiDebug_ViewableTables[] = "page";</php>
+
 
+
 
+
=== Example 1: Description with indexes ===
+
 
+
Providing the table 'page' is in the viewable tables array, then you can show it's description by using the following syntax:
+
 
+
<html4strict><describe_table table="page"></describe_table></html4strict>
+
 
+
<describe_table table="page"></describe_table>
+
 
+
 
+
=== Example 2: Description without indexes ===
+
 
+
<html4strict><describe_table table="page" showindexes="false"></describe_table></html4strict>
+
 
+
<describe_table table="page" showindexes="false"></describe_table>
+
 
+
 
+
=== Example 3: Non-viewable table ===
+
 
+
If we try and look at a table that is not listed in the $wgWikiDebug_ViewableTables array we get the following:
+
 
+
<describe_table table="user"></describe_table>
+
 
+
 
+
== show_source ==
+
 
+
This extension adds a new tag that allows you to display the contents of a php file within the page.  For security reasons it only allows the display of files that are added to an array of allowed files.  If an extension that adds a hook for the 'php' tag has been installed (e.g. the GeSHi Syntax Highlighter) then this will be used to wrap the output, otherwise 'pre' tags will be used.
+
 
+
''Note: The use of 'php' tags is currently disabled, as it trips up if the code contains a closing tag, as in the example below.''
+
 
+
=== Syntax ===
+
 
+
<html4strict><show_source file="{FileName}"></show_source></html4strict>
+
 
+
* {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 file containing this extension, you would need to add the following to LocalSettings.php:
+
<php>$wgWikiDebug_ViewableFiles[] = "WikiDebug.php";</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 ===
+
 
+
Here is the current (live) contents of WikiDebug.php - the file that contains this extension.
+
 
+
<html4strict><show_source file="WikiDebug.php"></show_source></html4strict>
+
<show_source file="WikiDebug.php"></show_source>
+
 
+
 
+
=== 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:
+
 
+
<html4strict><show_source file="LocalSettings.php"></show_source></html4strict>
+
<show_source file="LocalSettings.php"></show_source>
+

Latest revision as of 00:56, 8 February 2016

This extension is currently installed on this wiki. Feel free to experiment with it!
MediaWiki logo.png
This extension is also documented at
Extension:WikiDebug
on MediaWiki.org.

If the pages are not in sync. then this version on my test wiki is always the most up-to-date.

This extension contains a small set of tools that I find useful when debugging my extensions, or when making them available to others. I periodically add tools as I find a need, and may consider requests from other people if I find them interesting or useful enough.

  • <describe_table> - allows you to output the structure of a DB table on a wiki page.
  • <show_source> - displays the contents of a named file on a wiki page.
  • <show_revision> - displays the Subversion revision number of the specified file.
  • {{#IfExtensionPresent: ...}} - Parser hook so you can alter page content depending on whether an extension is installed on the wiki.


Current version: (rev 2439)
The source is available under example 1 of the show_source page.