Extension talk:Cargo

gallery error
If i have a blank field it will error. dunno if you can catch and handle that.

Fatal error: Call to a member function getText on a non-object in /home2/juanitos/public_html/w/w/includes/gallery/ImageGalleryBase.php on line 235


 * Sorry about that, and thanks for letting me know. I just checked in what I think is a fix... Yaron Koren (talk) 23:24, 8 June 2015 (UTC)

Using Queries Operator
Is it possible to use queries operators like 'minus' http://www.techonthenet.com/sql/minus.php ? Guillaume Prêcheur (talk) 12:52, 10 June 2015 (UTC)


 * You can't use "MINUS". Is that a standard SQL operator? It seems like it only exists for Oracle... Yaron Koren (talk) 13:37, 10 June 2015 (UTC)

map display stopped working..
i dunno why but my map display stopped working. It works fine on the semantic forms edit page but on the cargo display it failed. I'm not too sure if this is directly caused by cargo or something else.

inspect the element below the Location heading http://pepperdatabase.org/wiki/Juanitos_2015_Grow


 * It displays for me, actually. I think there's a problem with Cargo's Google Maps implementation where sometimes things get loaded in the wrong order. Most of the time it works, though. If you reload a few times, does the map never show up? Yaron Koren (talk) 16:29, 17 June 2015 (UTC)


 * Ok it doesn't display at all on google chrome canary, works ok after i refresh a couple times in chrome and works with IE. guess they did something funky on canary

Problems in Cargo 0.8/MW 1.25.1
Hi Yaron,

First of all - many thanks for such a brilliant extension! If not for you I would have to invent it by myown. I have also completely translated ru.json into Russian.

Still I got some problems. In most cases I found also workarounds.

The system: Mediawiki 1.25.1, Cargo 0.8 (latest master release), NO SMW installed.

'''Problem 1. Display of DATETIME.'''

I create a table with 2 standard fields, which will keep date/time of the creating and updating of the record:

Insert some data.

mysql> SELECT UpdatedDT, CreatedDT FROM cargo__Ads ; +-+-+ | UpdatedDT          | CreatedDT           | +-+-+ | 2015-06-26 16:57:48 | 2015-06-26 12:39:19 | +-+-+

'''Problem 1a. Rewriting of date/time values: the last one rewrites any previous. '''

|- ! Updated: |    |-  ! Created: |

Expected: two different date/time values.

Real: only CreatedDT in BOTH fields. The last value of type date/time completely rewrites any previous value.

Workaround: use additional cargo query: ! Updated: |  |-  ! Created: |

'''Problem 1b. English default formatting of date/time.'''

I use workaround from 1a.

Expected: 2015-06-26 16:57:48

Real: 2015-06-26 4:57:48 PM

The problem is that 1st variant is neutral and suitable for any language, while the 2nd - only for English-speaking audience.

Workaround:

use fake CONCAT in the cargo query or backticks around field name - ! Updated: |

'''Problem 1c. Unexpected date/time format.'''

I use MySQL function to format date/time:

Expected: 26.06.2015 16:57:48

Real: 2015-06-26

Workaround: Use additional CONCAT: CONCAT(DATE_FORMAT(UpdatedDT,'%d.%m.%Y'), DATE_FORMAT(UpdatedDT, ' %H:%i:%s'))

'''Problem 2. Special:CargoExport doesn't support compound_query with calendar format.'''

I have different types of events and want to display them with different colors in calendar. If I specify only ONE query - all is OK: If I specify more than one query - results in empty string from the backend:

With JavaScript debugger I discovered, that backend doesn't support notation like tables[1]...tables[n]: http://MYDOMAIN/index.php?title=Special:CargoExport&tables=Events&&fields=_pageName%2C_pageTitle%3Dname%2CStartDT&where=EventType%3DExhibition&order+by=_pageName&limit=100&format=fullcalendar&color[0]=green&start=2015-05-31&end=2015-07-12&_=1435356283321 - OK http://MYDOMAIN/index.php?title=Special:CargoExport&tables[0]=Events&tables[1]=Events&join+on[0]=&join+on[1]=&fields[0]=_pageName%2C_pageTitle%3Dname%2CStartDT&fields[1]=_pageName%2C_pageTitle%3Dname%2CStartDT&where[0]=EventType%3DExhibition&where[1]=EventType%3DMovie&group+by[0]=&group+by[1]=&order+by[0]=_pageName&order+by[1]=_pageName&limit[0]=100&limit[1]=100&format=fullcalendar&color[0]=green&color[1]=blue&start=2015-05-31&end=2015-07-12&_=1435356397824 - empty string.

'''Problem 3. Urlencoding of aliases.'''

I use following query with aliases in Russian: The query is broken, as aliases in clause ORDER BY are urlencoded. Workaround is simple - use backticks or apostrophs: `Начало` or 'Начало'.

But, first, MySQL and other databases permit field names in national languages (I use this feature rather often), second - urlencoding makes no sense in this place as the result will be broken 100%.

Once again - many thanks for this extension!!


 * I'm glad you like Cargo! And thank you for this detailed analysis. My responses:
 * 1a - the real solution for this is to have Cargo itself be able to store basic page data like when a page was first created, and when it was last edited. That's something I'm planning to add in. Until then, any attempt to store that kind of data manually will be a hack, as you've discovered.
 * 1b - Cargo needs a global variable to set whether to use 12-hour or 24-hour time; that has been a "todo" in the code for a long time. (It's not just English-speaking countries that use 12-hour time, but your larger point stands.)
 * 1c - I have no idea why that's happening; do you?
 * 2 - this was the most serious problem you found. I looked into it, and you're right - it was a Cargo bug. I introduced the bug about a month ago, while fixing something else; I think I just fixed this bug in Git.
 * 3 - I'll have to look into that. Yaron Koren (talk) 00:43, 27 June 2015 (UTC)


 * Okay, I just checked in fixes for 1b and 3 as well. For 1b, I added in the new global variable $wgCargo24HourTime (default is false), which I have been meaning to do for a while. Yaron Koren (talk) 14:49, 29 June 2015 (UTC)
 * Dear Yaron, sorry for disappearance from the discussion - I have just returned to active programming and promise now to reply in time. :) I tested all changes made with Cargo 0.9.


 * Thanks for correcting bug 2. My calendar now shows all colors.


 * Bug 1b.

! Updated: |
 * I see no effect from variable $wgCargo24HourTime. False or true, the result is always English 12-hour format. If I apply

fields=CONCAT(UpdatedDT)


 * - the result is always 24-hour format.


 * But in any case - I have workarounds for the rest. Alexey Rudenko (talk) 20:42, 23 August 2015 (UTC)

bar chart label not interpreted as wiki text
The bar-chart's labels shown as query's result are not interpreted as wiki text. I tried to encapsulate a value with " " and "  " to create a link to a wiki page inside my bar chart , it doesn't work, it just show me the values inside the " " and "  " as you can see :



any idea ? Guillaume Prêcheur (talk) 16:26, 30 June 2015 (UTC)


 * That's on purpose, actually... parsing of values could be done, but the big reason to do it, and the reason you have as well - to display links - is unfortunately not doable with the JavaScript library being used to display bar charts, NVD3. At least, it's not doable without some custom JS programming, which would (I assume) be complicated. By the way, CONCAT can take more than two arguments, so you don't need to chain them like that - not that it matters in this case, though. Yaron Koren (talk) 19:30, 30 June 2015 (UTC)


 * thanks for the answer (an for the CONCAT lesson !) - Do you plan to integrate other kinds of graphic formats ?Guillaume Prêcheur (talk) 07:25, 1 July 2015 (UTC)


 * I don't have any specific plans - what did you have in mind? The obvious graphical format to add would be pie charts, but many of the data visualization people say that a bar chart is always better than a pie chart. Yaron Koren (talk) 13:40, 1 July 2015 (UTC)

Cargo 0.9 - outline fields
The request:

First page displays correctly. When I click on more results... link below, I get internal error:

[cf28a627] /index.php?title=Special:ViewData&tables=Articles%2CArticles__ArticleTypes&fields=_pageName%2CArticles__ArticleTypes._value%3DCategory&join_on=Articles._ID%3DArticles__ArticleTypes._rowID&order_by=Category%2C_pageName&format=outline&offset=50&limit=100&outline+fields=Category MWException from line 157 of /www/chileru.org/extensions/Cargo_0.9/formats/CargoOutlineFormat.php: Error: 'outline fields' parameter must be set for 'outline' format. Backtrace:
 * 1) 0 /www/chileru.org/extensions/Cargo_0.9/CargoQueryDisplayer.php(236): CargoOutlineFormat->display(array, array, array, array)
 * 2) 1 /www/chileru.org/extensions/Cargo_0.9/specials/CargoViewData.php(240): CargoQueryDisplayer->displayQueryResults(CargoOutlineFormat, array)
 * 3) 2 /www/chileru.org/includes/specialpage/QueryPage.php(563): ViewDataPage->outputResults(OutputPage, SkinVector, DatabaseMysqli, ResultWrapper, integer, integer)
 * 4) 3 /www/chileru.org/extensions/Cargo_0.9/specials/CargoViewData.php(37): QueryPage->execute(NULL)
 * 5) 4 /www/chileru.org/includes/specialpage/SpecialPage.php(384): CargoViewData->execute(NULL)
 * 6) 5 /www/chileru.org/includes/specialpage/SpecialPageFactory.php(582): SpecialPage->run(NULL)
 * 7) 6 /www/chileru.org/includes/MediaWiki.php(267): SpecialPageFactory::executePath(Title, RequestContext)
 * 8) 7 /www/chileru.org/includes/MediaWiki.php(566): MediaWiki->performRequest
 * 9) 8 /www/chileru.org/includes/MediaWiki.php(414): MediaWiki->main
 * 10) 9 /www/chileru.org/index.php(41): MediaWiki->run
 * 11) 10 {main}

Supposing problem is in encoding of outline fields parameter as outline+fields. As a result this parameter is represented in CargoOutlineFormat->display as outline_fields with underscore.

I made dump of $displayParams in CargoOutlineFormat->display:

First page display: Array (   [outline fields] => Category )

Click on more results link: Array (   [limit] => 100    [outline_fields] => Category    [offset] => 50 )

Alexey Rudenko (talk) 21:01, 23 August 2015 (UTC)


 * Sorry about that, and thanks for your work in diagnosing the error. I just checked in what I think is a fix. Yaron Koren (talk) 15:40, 24 August 2015 (UTC)
 * Thank you! I downloaded the latest development version 0.10-alpha (Cargo-master-0b334b2.tar.gz) - the bug is fixed. Alexey Rudenko (talk) 16:49, 29 August 2015 (UTC)

MW 1.25.2 / Cargo 0.10 alpha
I install from the scratch MW 1.25.2 and Cargo 0.10 alpha via Distributor (no other extensions).

Run update.php. Tables cargo_pages and cargo_tables are created.

After that any "normal" page (not special) throws fatal error:

Catchable fatal error: Argument 1 passed to CargoRecreateDataAction::displayTab2 must be an instance of SkinTemplate, string given in /www/cargo.chileru.org/extensions/Cargo_0.10-alpha/CargoRecreateDataAction.php on line 97

The same happens in my working installation of MW 1.25.1, but I installed a new MW from the scratch to isolate the problem. What did I made wrong? Cargo extension is vitally important for my project, I would like to have its latest version. Thanks in advance! Alexey Rudenko (talk) 21:20, 23 August 2015 (UTC)


 * I just discovered this bug last week - it's actually a bug in MediaWiki 1.25-1.25.2, for extensions that use extension.json (like Cargo now does). It will be fixed in MediaWiki 1.25.3, but for now you can fix it yourself by putting in this change in your core MW code. Yaron Koren (talk) 02:37, 24 August 2015 (UTC)
 * I copied patched ExtensionProcessor_new-5523fe65955dbc14b87ad9dc0a08c3694fdd949d.php to includes/registration/ExtensionProcessor.php, ran update.php. Thank you, it works! Alexey Rudenko (talk) 13:20, 24 August 2015 (UTC)

MW 1.25.2 / Cargo any version
The SQL request includes MySQL function SUBSTRING_INDEX:

I get error: Error: the SQL function "SUBSTRING_INDEX" is not allowed.

If I replace SUBSTRING_INDEX with SUBSTRING - all works fine. No problems with SUBSTRING_INDEX from other PHP scripts o command line.

I am 100% sure, that with MW 1.24 it worked correctly. Tested with Cargo 0.6, 0.9, 0.10-alpha on MW 1.25.2. Any suggestions? Alexey Rudenko (talk) 15:18, 9 September 2015 (UTC)


 * This is not related to the MediaWiki version, it's just the Cargo version. It's my fault - I added the $wgCargoAllowedSQLFunctions variable to the code over a month ago, but I haven't released a new version, so the change is not documented yet. (I doubt you saw this same error with Cargo 0.6.) I think all you need to do is add the following to LocalSettings.php, after the inclusion of Cargo:

$wgCargoAllowedSQLFunctions[] = 'SUBSTRING_INDEX';
 * Yaron Koren (talk) 15:37, 9 September 2015 (UTC)

Error when trying to create tables
When going to the tab "Create data table" and hitting "ok" nothing happens. My FireBug reports: "TypeError: templateData is null" (twice)

What I did to get here:
 * got sources via git
 * ran update.php
 * database user with create/drop table rights (tested both: default mw-database settings and separate ones)
 * copied quick-start templates book and author from Extension:Cargo/Quick_start_guide

with TypeError: templateData is null https://HOST/_w/extensions/Cargo/libs/ext.cargo.recreatedata.js Line 16 for ( var i = 0; i < templateData.length; i++ ) { -^

It doesn't seem to matter, if I create pages that call the templates author or book. Also, I tried to use the maintenance script to create the tables. It ran for 1 or 2 sec and then exited without any output. And of course: no tables were created... :(

BTW, I'm running a german MediaWiki with: and a few other minor extensions.
 * MediaWiki 	1.23.10
 * PHP 	5.6
 * MySQL 	5.5
 * SemanticForms 3.4
 * Cargo 0.10-alpha

Also, setting error_reporting(E_ALL); ini_set ("display_errors", "1"); $wgShowExceptionDetails = true; $wgShowDebug = true; $wgDevelopmentWarnings = false; in my LocalSettings.php doesn't yield any more viable information. I'm at a loss and would appreciate any suggestion as to where to look next...

Regards, Tobias Oetterer (talk) 14:06, 23 September 2015 (UTC)


 * kept me awake (so to speak) and I think I found the problem:
 * was created but ext.cargo.recreatedata.js returned an empty object when trying to access it. So I supsected a failed race condition.
 * I then edited the section for 'ext.cargo.recreatedata' in  in Cargo.php and changed position to bottom:
 * 'position' => 'bottom',
 * Now it seems to work fine. No idea, if this breaks something else in the long run, though...
 * Tobias Oetterer (talk) 17:19, 23 September 2015 (UTC)


 * That's a great find! I don't know why that happened for you, but I'll make that change in the code. Yaron Koren (talk) 14:06, 24 September 2015 (UTC)

Cargo Template
Hi I'm trying to create a single template for a table. Looking at the example how would I add the query for the single table? I did create a template whether right or wrong and selected "create data table" came up with Create Cargo data for this template? I selected ok and nothing happened.

I can't find anything on the form layout is that the same as SMW?


 * If you go to Special:CargoTables, do you see the table? For the forms - the Semantic Forms documentation covers all of that, including the Cargo-specific stuff. Yaron Koren (talk) 14:17, 24 September 2015 (UTC)


 * nothing there. Phil Legault 26 September 2015
 * Enabled debugging and I don't see any errors

here is my template This is the for FEA Domain


 * That certainly looks like it should work... can you try calling the command-line script cargoRecreateData.php and see if that works, or if you get an error message? Yaron Koren (talk) 02:46, 27 September 2015 (UTC)

Problems with creation of Cargo tables
Hi Yaron,

I use newly installed MediaWiki 1.25.2 with extensions:
 * Cargo (0.10-alpha),
 * ParserFunctions (1.6.0),
 * LocalisationUpdate (1.3.0).

I created Template:Book, but I can't create the table of data, because the page (index.php?title=Template:Book&action=recreatedata) has the javascript error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data http://cargoen.loc/load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150930T154529Z Line 125 and when I click "OK" button, nothing happens.

From the command line I can't create the table of data, too. Nothing happens.

Please help solve the problem and create a table.


 * I'm guessing that the API is returning an error message. I would try going directly to "api.php?action=cargorecreatetables&template=templateNameHere" (that's the URL being retrieved behind the scenes) and seeing what it displays. Yaron Koren (talk) 16:59, 30 September 2015 (UTC)


 * Thanks a lot! I executed API request for creation of the table and it worked - the table was successfully created: "This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use. Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json. See the complete documentation, or the API help for more information. {"success": ""}. What to do with the javascript error? Perhaps I should write more detailed report about an error? Sergey Mikhalev 18:27, 01 October 2015 (UTC+3)


 * That's unexpected. There are actually two URLs being accessed - maybe the second one is causing the problem? The second one is "api.php?action=cargorecreatedata&template=templateNameHere&table=tableNameHere". Could you try going to that one too? Yaron Koren (talk) 15:49, 1 October 2015 (UTC)


 * I executed API request for recreation of the table ( http://cargoen.loc/api.php?action=cargorecreatedata&template=Book&table=Books ) and it worked - the table was successfully recreated: "This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use. Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json. See the complete documentation, or the API help for more information. {"success": ""}. Sergey Mikhalev 09:22, 02 October 2015 (UTC+3)


 * Alright, so the API is not the problem. If the web interface still doesn't work for you, I would go the "recreate data" page and add "&debug=true" to the URL after "?action=recreatedata". That should lead to a more helpful JS error message. Yaron Koren (talk) 10:47, 2 October 2015 (UTC)


 * I executed API request for recreation of the table with the "&debug=true" parameter (http://cargoen.loc/index.php?title=Template:Book&action=recreatedata&debug=true):

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data http://cargoen.loc/load.php?debug=true&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=vector&version=20150930T154529Z Line 8520 In a debug mode: jQuery.parseJSON = function( data ) { // Attempt to parse using the native JSON parser first if ( window.JSON && window.JSON.parse ) { // Support: Android 2.3 // Workaround failure to string-cast null input 8520			return window.JSON.parse( data + "" ); }

var requireNonComma, "Data" variable is undefined before throwing an exception. Also when using "&debug=true" parameter there are 2 more errors: TypeError: $content.find(...).makeCollapsible is not a function http://cargoen.loc/resources/src/mediawiki.page/mediawiki.page.ready.js Line 23 TypeError: $(...).on is not a function http://cargoen.loc/resources/src/jquery/jquery.mw-jump.js Line 6 Sergey Mikhalev 16:22, 05 October 2015 (UTC+3)


 * Okay, that's only somewhat helpful. Are you using the very latest version of the Cargo code? I just made a change last week, that moved the JavaScript for "recreate data" from the top to the bottom of the page, that may fix this issue for you, if you're not using that code yet. Yaron Koren (talk) 14:42, 5 October 2015 (UTC)


 * I updated the code and everything works. Thank you very much! Sergey Mikhalev 10:15, 06 October 2015 (UTC+3)


 * (Phew) That's good to hear! I should have thought of that earlier. Yaron Koren (talk) 14:38, 6 October 2015 (UTC)

BLOB or TEXT columns
Hey, I will soon face the task of storing quite a bit of text (>> 300 chars) in a field. Currently. I'm working with cargo and I'm really excited about the capabilities. Somehow, at the the design level, I assumed that fieldtype "Wikitext" would result in a TEXT or BLOB column. Unfortunately, it also results in varchar(300). My questions: And the bonus question:
 * Is there a way, I can increase the limit of 300?
 * Is there a way to have #cargo_declare create a column of type BLOB or TEXT?
 * Is any of this a permanent restriction or do you plan to add such capabilities (possibly in the near future?)?
 * Do you have any idea, how cargo would react, if I manually changed the column type via phpmyadmin?

Best wishes Tobias (talk) 06:02, 16 October 2015 (UTC)


 * You can change the size by adding "(size=..)" after the type in the #cargo_declare call. And, for recent versions of Cargo, if the size is greater than 1000, the field will be saved as type "TEXT". So I would recommend declaring the type as "Wikitext (size=2000)". It's kind of a hack, I know; and maybe the BLOB/TEXT type should really just be directly settable.
 * I don't think changing the type would cause problems, though your changes would be overwritten if you ever refreshed the table. Thankfully, there's probably no need for this. Yaron Koren (talk) 20:42, 16 October 2015 (UTC)
 * Awesome, thanks. You are the best! The  parameter must have slipped by me, sorry. Nevertheless, works perfectly.
 * imho, giving the user the option to set a field type to text/blob would be better. It's straight forward and the user knows what to expect. Maybe simple introduce another field type "blob" or something like that.
 * Cool. That's not a bad idea - I somewhat wish I had used "String" for smaller strings, so I could have "Text" for the TEXT type, the way Semantic MediaWiki used to do it. Maybe "Longtext" would work... "Blob" might be confusing, because it wouldn't actually be the SQL BLOB type. Yaron Koren (talk) 01:30, 22 October 2015 (UTC)
 * I'm a stricly mysql kinda guy, so you have to forgive my inexperience with other databases. :/ Longtext however sounds perfect! :)
 * I favor MySQL too. :) I ended up adding a "String" type, as I should have done originally - so "Text" now always sets a DB field of type "TEXT", if you get the latest code. Yaron Koren (talk) 00:38, 9 November 2015 (UTC)

Cargo and Lua
I needed to use cargo_query in Lua module. It is clear that the ideal would be to get the result as a table Lua. But cargo_query not provide even a simple text output (csv?). We have to use a list (uncomfortable parsing) or template (very expensive). --StasR (talk) 06:32, 17 October 2015 (UTC)


 * cargo_query provides a link to a CSV output, which is directly available at Special:CargoExport. If you have the code create the Special:CargoExport URL directly (which shouldn't be that hard to do), it will hopefully work. Yaron Koren (talk) 23:40, 17 October 2015 (UTC)


 * Thank you. Intuitively it seems to me a http request even less convenient and efficient than 'list' parsing. Maybe slight improvements 'list' to turn it into a machine-processed?


 * The main difficulties are caused by the definition of the boundaries of records (field boundaries can be recognized by text  without loss of generality). Furthermore, it is inconvenient that the first field in the record is displayed in a special way, but it is less important and  problem can be solved. --StasR (talk) 11:47, 19 October 2015 (UTC)


 * What are you ultimately trying to do? Maybe there's an easier way to do whatever it is. Yaron Koren (talk) 14:03, 19 October 2015 (UTC)


 * I need to process each record via Lua. The obvious way is to put the format of 'template' and make a template that contains only . It is technically possible, but it seems too expensive.
 * As long as I use a template that contains  for each record. And largely because of the excessive number of calls I want to use Cargo.  --StasR (talk) 17:56, 19 October 2015 (UTC)


 * Alright. This might be a hack, but you could potentially use the External Data extension, and specifically its parser functions #get_web_data and #for_external_table, to get the data from Special:CargoExport to Lua in the necessary format. It wouldn't require either parsing or an HTTP request, for what it's worth. Yaron Koren (talk) 18:34, 19 October 2015 (UTC)


 * I, too, had to choose between External Data and the  "hack". As of now, I'm running the latter but I haven't done any excessive performance tests, yet. Basically, I use a template, that again calls a lua function that encases the arguments in some predefined strings so that I can easily construct a table from the return string. After some minor problems, it runs quite well now. If you're interested, I could send you my solution...  Tobias (talk) 18:13, 21 October 2015 (UTC)


 * Yaron Koren, why not make displaying format without strip markers? --StasR (talk) 08:36, 22 October 2015 (UTC)
 * What's a strip marker? Yaron Koren (talk) 13:00, 22 October 2015 (UTC)
 * Strip marker. CargoQuery.php, line ~130:

--StasR (talk) 14:23, 22 October 2015 (UTC)


 * Oh, okay. What's the problem with it? Yaron Koren (talk) 14:41, 22 October 2015 (UTC)
 * The problem is still the same. Result without strip markers can be analyzed by Lua. --StasR (talk) 14:55, 22 October 2015 (UTC)
 * The strip thing is there so that HTML can be displayed correctly. Why not use the External Data approach? Yaron Koren (talk) 17:27, 22 October 2015 (UTC)
 * Best (and most performant) approach would be to create a Lua package for Cargo. Otherwise take external data or the template hack. All works fine... Tobias (talk) 20:17, 22 October 2015 (UTC)
 * I agree. Lua package is the best solution. But first, it would be enough to analogue #for_external_table  in Cargo. --StasR (talk) 11:56, 24 October 2015 (UTC)
 * I too agree that a Lua package would be great (and I wish I knew how to create them). But, StasR - why not just use #for_external_table directly? Or, maybe better yet, #display_external_table? Yaron Koren (talk) 03:12, 26 October 2015 (UTC)
 * I was hoping #for_external_table (unlike #display_external_table) alone does not cause the MW parser to interpret each row. I was wrong? --StasR (talk) 09:20, 26 October 2015 (UTC)
 * I don't know; I would try it. Yaron Koren (talk) 13:11, 26 October 2015 (UTC)


 * Yaron, I did Cargo format similar #for_external_table. It was easy, because the code is well structured. Can I offer it to you? --StasR (talk) 22:31, 27 October 2015 (UTC)


 * Sure; I don't really understand what that means, but I'm looking forward to seeing it. Yaron Koren (talk) 23:31, 27 October 2015 (UTC)


 * Please take into account that I do not do coding for many years :-). New file CargoPatternFormat.php (I designed it from CargoListFormat.php) contains:

and the condition at the end of CargoQuery.php looks like this
 * Furthermore, obvious changes made in Cargo.php and CargoQueryDisplayer.php. Not made by me: (i) I have not studied the situation with the "View more"; (ii) The same should be the end CargoCompoundQuery.php, but I did not engaged. --StasR (talk) 09:12, 28 October 2015 (UTC)

What's an example of a pattern that this would be called with? Yaron Koren (talk) 23:36, 28 October 2015 (UTC)
 * Example:


 * But for Lua parsing I would have written something like this  --StasR (talk) 07:09, 29 October 2015 (UTC)


 * Ah... now I understand. And now I know what you meant by "similar to #for_external_table". I'll look into this - maybe there's an easier way to do this, using the "template" format, but maybe not. Yaron Koren (talk) 09:03, 29 October 2015 (UTC)

Trouble Adding Table to a particular Template
For the life of me I can't see to get a particular template to create tables. I'm starting with Page Schemas and have something like this...

    Author  text   Text    Update</Label>  text</InputType> </semanticforms_FormInput>  Text</Type> </cargo_Field> </Field> </Template>

This is my actual template that gets generated:

This is the "Status" template. It should be called in the following format: &lt;pre>

&lt;/pre> Edit the page to see the template text.

Originally it was a multiple instance, with a datefield, author (user page), and textbox/wikitext. I've tried changing the name, order, datatypes, etc. My other templates are coming through but not this one or anything like it. I execute runJobs on cmd line. In the API url call I get something like this...

/api.php?action=cargorecreatetables&template=Status

{   "error": { "code": "internal_api_error_DBQueryError", "info": "[7817f089] Database query error" } }

Usually I get an error when I then try to edit the page with form stating the table doesn't exist, but what's weird is that eventually the form works and I can edit data, but no data is stored to the database, and still no table for this one actually exists in the mysql database.

If I run cargoRecreateData it seems to skip this template also.

I appreciate any direction to help debug this.--Kc5vcx (talk) 03:01, 2 November 2015 (UTC)


 * My guess is that the field called "Update" is causing the problem, because that is already an SQL keyword. If so, that's a bug in Cargo - it should either handle that name or reject it. Please let me know, though. Yaron Koren (talk) 14:13, 2 November 2015 (UTC)


 * Ahh, yes, that's it! Thanks, works now after renaming the field. --Kc5vcx (talk) 15:22, 2 November 2015 (UTC)

Timeline output format displays blank box
Here's the question I was going to ask: The timeline format (as here) would be ideal for my data, but unfortunately all I get is a blank space. It is exactly the same as the example on discoursedb.org, and similar to the example on mwstake.org. I'm using MW1.25.3 and Cargo 0.6.

Then I realised I should use Cargo 0.10 so did "get checkout master". It all works fine now. So don't use the REL1_25 branch with MW 1.25.3 :-)

Also the calendar format showed an empty calendar on the iPhone but that also now works fine. Jonathan3 (talk) 19:19, 5 November 2015 (UTC)

Timeline and calendar formats don't work properly with Foreground skin tabs
I would like to use three tabs for an events page - for Table, Timeline and Calendar formats.

Each format works fine, one after the other, without using tabs. But...

In tab 1, only Table and Timeline work. Calendar does not.

In tabs 2 or 3, only Table works. Calendar and Timeline do not.

Is there something I can do to fix this?

The tabs are done as follows. Each "section" is a tab.



<p class="title" data-section-title>Timeline ...

It looks similar to the problem here though probably is unrelated. Jonathan3 (talk) 20:48, 5 November 2015 (UTC)

I have discovered that the timeline format DOES work, in any tab, if there is a cargo query outside the tabs structure on the same page. Jonathan3 (talk) 20:57, 5 November 2015 (UTC)


 * I would check the JavaScript console for errors, if you know how to do that. Also, does this only happen with the Foreground skin? Yaron Koren (talk) 01:16, 6 November 2015 (UTC)


 * Thanks Yaron. The problem isn't there for the Vector skin (the tabs don't show as tabs with Vector, but everything appears one after the other - as it does with Foreground if you don't use tabs).
 * I got the following error initially:

Test_page:1 XMLHttpRequest cannot load http://domain.co.uk/index.php?title=Special:CargoExport&tables=Event&&fields=_pageName%2CDate&&order+by=_pageName&limit=100&format=timeline. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.domain.co.uk' is therefore not allowed access.
 * After adding a str_replace to add the www that error stopped appearing (I don't really understand this to be honest so it may have coincided with something else).
 * Also I was getting an error "Caught exception: SyntaxError: Unexpected end of input" which may have been related, and which also no loger appears.
 * The only other things are just lots of "Use of "wgCargoMonthNamesShort" is deprecated. Use mw.config instead."
 * Jonathan3 (talk) 02:22, 6 November 2015 (UTC)


 * So, you're no longer getting errors? (You can disregard those warnings.) And is the actual problem still happening? Yaron Koren (talk) 02:43, 6 November 2015 (UTC)


 * Sorry for not being clear. It all seems so random to me so I'm just trying different things. I'm not getting those errors any more but the original problem persists (plus at the moment timeline format doesn't work in tab 1 either). I'll email you a URL if that would help (I don't want to publish it). Jonathan3 (talk) 02:47, 6 November 2015 (UTC)


 * Ah - yes, please do. Yaron Koren (talk) 02:51, 6 November 2015 (UTC)

Are "Semantic_Extra_Special_Properties" meta data not available for Cargo either ?
If yes I suggest to add "Semantic Extra Special Properties + SMW" in the line "Storage of page metadata"/column "SMW-based system" of the "Features checklist" in the page Extension:Cargo/Cargo_and_Semantic_MediaWiki.

Cheers,

Nicolas NALLET (talk) 16:03, 6 November 2015 (UTC)


 * Good point - I just added it in. Yaron Koren (talk) 16:49, 6 November 2015 (UTC)

Advanced SQL Joins in cargo_query for multiple instance templates
I'm probably over complicating things in my data store, but I'm building a project tracker on SMW using Cargo. Our projects can have multiple milestones with planned/expected/actual dates I want to track. Rather than hard-coding a potential list of these milestones and respective dates (this list could get long) in my form, I made a multiple instance dates template where somebody can select from usual milestones and add others. The problem is I then need to link it back to the project and this obviously complicates the query. It's been awhile since I've done SQL but I can accomplish what I want in phpmyadmin with something like this...

select Projects._pageName,Dates.Planned_Design_Start from cargo__projects Projects JOIN (select _pageName, Planned_date as Planned_Design_Start from cargo__project_dates where Milestone="Design Start") Dates ON Projects._pageName = Dates._pageName

Unfortunately a simple join doesn't really organize the way I need and produces something like this...

Not sure why the aref's aren't coming through here, but that's not part of the issue on my real page.

I'm assuming I need to translate my data more directly like the first example for the various results formats to process it, but I'm just getting there. I was trying to embedded it in the cargo syntax, maybe put the join in the tables= field, but it obviously won't let me use SELECT for the subquery, and $wgCargoAllowedSQLFunctions in localSettings.php also won't let me allow it. Obviously I could simplify my data structure and that's why I'm working through this, but wanted to explain my example to help justify. Any thoughts on enabling something like this or how I might hack around it? Might be nice if I could just give it a raw sql query (this is on a secure internal network, so less concerned about security).

Also, as I'm debugging, is there a good way to display the raw sql query text it generates like at the top of the page with a variable? I can introduce some types of errors and get it, which I've found helpful debugging what I'm trying to do with my data.

Thanks again.--Kc5vcx (talk) 18:35, 6 November 2015 (UTC)


 * Hi - I think I see the issue: you want to show more than one "row" of data from that "Dates" table across the same row of results. Unfortunately, I don't think you can do that with a call to #cargo_query, given its constraints. There is one way, if you use a "template" format and then include a query within that template; but that's a hack, and anyway it won't let you display anything more interesting than a (hacked-together) table. What I would suggest instead is to hardcode the fields for "planned date" and "expected date", since every page should have those. And if there are other dates that you'd expect every page to have, I'd hardcode those as well. Actually, maybe it's better to hardcode everything, unless there are really a lot of other date types, in which case you can use that setup you came up with for all the other types.
 * A "debug" format would be great; I keep meaning to add that in. Yes, I too introduce errors in order to see the SQL, which is not great. Yaron Koren (talk) 19:39, 6 November 2015 (UTC)


 * I found I can sort of do what I want my concatenating the field names in a compound query, in this case to send to the calendar result format, like so...

However, there's something wrong with the AS statement on a date field because the calendar format equivalent is empty. If I remove the =date field, then I get the first query on my calendar, but not the second because it's in a second column. It looks like cargo is including the __precision table in the query behind the scenes and I presume formatting it correctly to send to the calendar. Using the = in fields which correlates to the SQL AS for alias, looses this formatting or whatever. I seem to need to be able to combine my dates all into one column for them to show up on the calendar. So is there a way to force the date formatting calendar needs? I've been trying the DATE and DATE_FORMAT functions on both sides.--Kc5vcx (talk) 22:38, 6 November 2015 (UTC)

Job run rate "too high"?
The Known bugs and planned features page states: "If a table is recreated via the web interface and the "job run rate" (set via $wgJobRunRate) is too high, it can lead to some pages not getting their data stored." What is too high? Alternatively, what range is all right (e.g. 0.1 to 1)? Thanks Jonathan3 (talk) 20:51, 6 November 2015 (UTC)


 * I don't know; I should do more testing. I think it's worked for me fine with a rate of 1, but caused problems when I used a rate of 10. Yaron Koren (talk) 21:54, 6 November 2015 (UTC)


 * Thanks for explaining. Jonathan3 (talk) 22:24, 6 November 2015 (UTC)

Boolean field always 0 in database
I have a boolean field ("Active" in a "Jobs" adverts table). When I create the job page using Semantic Forms, the tick box makes it "Yes" or "No" as appropriate. But when it appears in the Cargo database table it's always 0. I'm sure I'm missing something simple..... Thanks Jonathan3 (talk) 22:28, 6 November 2015 (UTC)

P.S. When I edit the database directly (changing one of the 0s to 1) it is reflected in the Special:CargoTables/Jobs page, but when I "recreate data" on Template:Jobs it returns everything to 0. Jonathan3 (talk) 22:40, 6 November 2015 (UTC)

P.S. And when I change the Job page so that "Active" is "1" (instead of "Yes") this leads to Special:CargoTables/Jobs page showing 1. So I suppose I need to know either: (a) how to get SF to make the values 1/0 rather than Yes/No, or (preferably) (b) how to get Cargo to recognise "Yes" and save "1" to the database.Jonathan3 (talk) 22:46, 6 November 2015 (UTC)


 * I was going to try to help, but I just realized the same thing is happening to me. --Kc5vcx (talk) 22:50, 6 November 2015 (UTC)


 * Yikes! It looks like the setting of Boolean values never worked correctly. I guess it's not a very popular type. Sorry about that; I think I just fixed the problem in the Cargo code. Yaron Koren (talk) 20:20, 8 November 2015 (UTC)

Error: the SQL function "AND" is not allowed.
When I use the following query I get the error in the topic title: |where=Active=1 AND (Closes >= NOW or Closes IS NULL)

But when I use this it works fine: |where=(Closes >= NOW or Closes IS NULL) AND Active=1

For future reference, where am I going wrong? Jonathan3 (talk) 23:13, 6 November 2015 (UTC)


 * That was a bug - sorry about that! I just fixed it in the code. Yaron Koren (talk) 19:16, 10 November 2015 (UTC)