Extension:Cargo/Common problems
Appearance
- An error message that looks like "A database query error has occurred. This may indicate a bug in the software" shows up on pages with Cargo templates if one has not run '
php update
' after installing the Cargo extension. If that's not the cause, you may want to add the following to LocalSettings.php, so that the page displays a more helpful error message:
$wgShowSQLErrors = true;
- Similarly, if you see an error message like "Fatal exception of type MWException", add the following to LocalSettings.php for a more helpful error message:
$wgShowExceptionDetails = true;
- Cargo makes use of the MediaWiki API, so make sure that you do not have the API disabled; if you have $wgEnableAPI set to false in LocalSettings.php, you should remove that line.
- If the "where" clause contains something like
_pageName = '{{PAGENAME}}'
, the query will break for pages that contain a single quote/apostrophe (') in their name. There are a few potential fixes for this: the easiest is to change the query to_pageID = {{PAGEID}}
, which should always work. Another option is to change it to_pageName='{{#replace:{{PAGENAME}}|'|\'}}'
. (You could also consider replacing the single quotes around {{PAGENAME}} with double quotes, but single quotes are generally preferred for SQL literals, plus this formulation will itself break if the page name contains double quotes.)
- By default, '=' comparisons in MySQL are case-insensitive. If you want an '=' comparison within the "where" clause to be case-sensitive, you can do it by adding "BINARY" to the comparison, like "BINARY Nickname = 'Joe'". You can do the same thing for "HOLDS" statements, like "BINARY Genre HOLDS 'Drama'". Unicode characters are not respected either and will also require "BINARY" lookups, though this behavior is inconsistent across languages.
- Unlike Semantic MediaWiki, Cargo does not provide a "class" parameter for any of its formats. However, you can still define custom formatting for a display, by wrapping a #cargo_query call inside a "div" or "span" tag that has its own class declaration, like
<div class="black">{{#cargo_query|...</div>
. Then the CSS you use can contain calls like "div.black table ...", or whatever it is.
- If you have the Joomla! CMS running on the same server as MediaWiki, it may lead to the Cargo "recreate data" action failing. That is because one of Joomla's recommended htaccess settings blocks the string "template" in the URL, and Cargo uses this word as a parameter in its API call. To get Cargo working, you will probably have to modify or remove this line.
- If you want to show a row number for each row in the query results, do the following:
- Create a template called
Iter
with contents{{#vardefineecho:ITER_INDEX|{{#expr:{{#var:ITER_INDEX|0}}+1}} }}
. Note that#vardefineecho
is from Extension:Variables. - Create templates called
((
and))
with contents{{
and}}
respectively. - Add the field
CONCAT('{{((}}Iter{{))}}')=N
to your query.
- Create a template called
- If you have Cargo tables with many columns, and trying to save a page's data leads to an error message like "1118 Row size too large", it may make sense to change the database row format of your Cargo tables. You can do this using the $wgCargoDBRowFormat global variable. Just add a line like the following to LocalSettings.php, under the inclusion of Cargo:
$wgCargoDBRowFormat = 'COMPRESSED';
- You will then have to recreate the relevant Cargo table(s).
- If you want to prevent VisualEditor from mangling your #cargo_query statements, place the first clause ("tables=") on the same line as "#cargo_query:". Or, better yet, wrap the queries in a template.
- If you want return the page name (usually
_pageName
) you will get an error like "Error: Field alias \"_pageName\" starts with an underscore (_). This is not allowed in Cargo API queries.". To get this to work, you need to create an alias like_pageName=Page
.