Extension talk:Cargo/Archive November to December 2015

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...

 <Template name="Status" format="standard">
    <cargo_TemplateDetails>
      <Table>Status</Table>
    </cargo_TemplateDetails>
    <Field name="Author">
      <Label>Author</Label>
      <semanticforms_FormInput>
        <InputType>text</InputType>
      </semanticforms_FormInput>
      <cargo_Field>
        <Type>Text</Type>
      </cargo_Field>
    </Field>
    <Field name="Update">
      <Label>Update</Label>
      <semanticforms_FormInput>
        <InputType>text</InputType>
      </semanticforms_FormInput>
      <cargo_Field>
        <Type>Text</Type>
      </cargo_Field>
    </Field>
  </Template>

This is my actual template that gets generated:


<noinclude>
This is the "Status" template.
It should be called in the following format:
<pre>
{{Status
|Author=
|Update=
}}
</pre>
Edit the page to see the template text.
{{#cargo_declare:_table=Status|Author=Text|Update=Text}}
</noinclude><includeonly>{{#cargo_store:_table=Status|Author={{{Author|}}}|Update={{{Update|}}} }}{| class="wikitable"
! Author
| {{{Author|}}}
|-
! Update
| {{{Update|}}}
|}
</includeonly>

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)Reply

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)Reply
Ahh, yes, that's it! Thanks, works now after renaming the field. --Kc5vcx (talk) 15:22, 2 November 2015 (UTC)Reply

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)Reply

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.

::<div class="section-container auto" data-section>
  <div class="section">
    <p class="title" data-section-title>Timeline</p>
    <div class="content" data-section-content>
       ...

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

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)Reply

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)Reply
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)Reply
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)Reply
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)Reply
Ah - yes, please do. Yaron Koren (talk) 02:51, 6 November 2015 (UTC)Reply

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)Reply

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

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


_pageName Planned_Design_Start
TestProj 2015-11-06
Anotherproj NULL
Test 2014-11-06
New Proj 2015-11-02


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

{{#cargo_query:
tables=Projects,Project_Dates
|join on=Projects._pageName = Project_Dates._pageName
|fields=Projects._pageName,Project_Dates.Milestone,Project_Dates.Planned_Date,Project_Dates.Expected_Date
|where=Project_Dates.Planned_Date<>""
|format=table
}}


_pageName Milestone Planned Date Expected Date
<a href="/Anotherproj" title="Anotherproj">Anotherproj</a> Tape Out October 1, 2015
<a href="/New_Proj" title="New Proj">New Proj</a> Design Start November 2, 2015
<a href="/New_Proj" title="New Proj">New Proj</a> Kickoff November 2, 2015
<a href="/New_Proj" title="New Proj">New Proj</a> Tape Out May 2, 2016
<a href="/Test" title="Test">Test</a> Design Start November 6, 2014 November 6, 2014
<a href="/Test" title="Test">Test</a> Tape Out November 6, 2015 November 6, 2015
<a href="/TestProj" title="TestProj">TestProj</a> Design Start November 6, 2015 November 6, 2015

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)Reply

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)Reply


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...
{{#cargo_compound_query:
tables=Project_Dates
;fields=CONCAT(_pageName," ",Milestone," Planned")=name,_pageName,Planned_Date=Date
;where=Planned_Date<>""
;color=blue
|tables=Project_Dates
;fields=CONCAT(_pageName," ",Milestone," Expected")=name,_pageName,Expected_Date=Date
;where=Expected_Date<>Planned_Date
;color=red
|format= table
}}


name _pageName Date
Anotherproj Tape Out Planned <a href="/Anotherproj" title="Anotherproj">Anotherproj</a> October 1, 2015
New Proj Design Start Planned <a href="/New_Proj" title="New Proj">New Proj</a> November 2, 2015
New Proj Kickoff Planned <a href="/New_Proj" title="New Proj">New Proj</a> November 2, 2015
New Proj Tape Out Planned <a href="/New_Proj" title="New Proj">New Proj</a> May 2, 2016
Test Design Start Planned <a href="/Test" title="Test">Test</a> November 4, 2015
Test Tape Out Planned <a href="/Test" title="Test">Test</a> November 6, 2015
TestProj Design Start Planned <a href="/TestProj" title="TestProj">TestProj</a> November 6, 2015
Test Design Start Expected <a href="/Test" title="Test">Test</a> November 5, 2015


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)Reply

This was indeed a bug, and the problem lay with the 'precision" fields like you said. Thanks for diagnosing it. I believe I just fixed it in the Cargo code. Yaron Koren (talk) 00:48, 11 November 2015 (UTC)Reply
Thanks, I'm still having a bit of an issue though after playing with my sample above. For some reason only one (maybe the last) of the second query in the compound query gets put on the calendar. What I'm trying to do is have color coded events, blue is the default planned date. A second red calendar shows where the expected date is not equal to the planned. If I use a format table I see a couple applicable entries, but in the calendar format only one shows up in red and the others not at all. Is there anything different in the data output between them? I confirmed they're all the same simple looking date format in mysql with precision 1. The rest of the blue are there and shouldn't conflict with names or dates. I haven't been able to figure out another way to view the raw calendar data to further debug. Any thoughts? --Kc5vcx (talk) 16:41, 11 November 2015 (UTC)Reply
There's a way to view the raw calendar data, though it's a little bit of a hassle; I use it all the time, though: (1) View the page source, and find the URL that includes "Special:CargoExport". (2) Replace all the "&amp;"s in the URL with just "&"s. (3) Add a "start=" and "end=" value to that URL, representing the range of dates you want to find, like "&start=2014-01-01&end=2015-01-01". (4) Go to that URL. Yaron Koren (talk) 00:10, 12 November 2015 (UTC)Reply
As I suspected the raw calendar data is a subset that I get in the table or even the csv format, so something else in the processing is filtering it out. The functions for the different types look significantly different in the export code with additional date stuff for the calendar, if I get anywhere looking at it I'll update.--Kc5vcx (talk) 16:48, 12 November 2015 (UTC)Reply
UPDATE: If I comment out the below section where it appends the start/end dates to the where clause of the query I get my expected result. There must be something conflicting with the multiple dates, but not obvious to me yet without seeing the produced sql.
			$where = $sqlQuery->mWhereStr;
			if ( $where != '' ) {
				$where .= " AND ";
			}
			$where .= "(";
			foreach ( $dateFieldRealNames as $j => $dateField ) {
				if ( $j > 0 ) {
					$where .= " OR ";
				}
				$where .= "($dateField >= '$startDate' AND $dateField <= '$endDate')";
			}
			$where .= ")";
			$sqlQuery->mWhereStr = $where;
Is there any particular reason for this rather than the user limiting the results on their own? --Kc5vcx (talk) 20:55, 12 November 2015 (UTC)Reply
It's because the calendar only shows one month/week/day at a time; so the page only queries for results from that time period. Yaron Koren (talk) 21:04, 12 November 2015 (UTC)Reply

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)Reply

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)Reply
Thanks for explaining. Jonathan3 (talk) 22:24, 6 November 2015 (UTC)Reply

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)Reply

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)Reply

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)Reply

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)Reply
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)Reply
Looks fixed to me. --Kc5vcx (talk) 16:41, 11 November 2015 (UTC)Reply

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)Reply

That was a bug - sorry about that! I just fixed it in the code. Yaron Koren (talk) 19:16, 10 November 2015 (UTC)Reply
Thank you very much (again). Jonathan3 (talk) 18:58, 11 November 2015 (UTC)Reply

Date precision

Here is written about the possibility of storing of incomplete dates (year or year+month). But I was not able to set incomplete dates by #cargo_store. What is the syntax for this? --StasR (talk) 15:41, 17 November 2015 (UTC)Reply

There's no special syntax - the code tries to figure out the precision of each date. What was the date you tried to set, and what happened? Yaron Koren (talk) 17:00, 17 November 2015 (UTC)Reply
Template:Cargo1
<noinclude>
{{#cargo_declare:_table=TabTest_1
  |descr=Text (size=80)
  |value=Date
}}
</noinclude>
<includeonly>
{{#cargo_store: _table=TabTest_1
  |descr={{{1}}}
  |value={{{1}}}
}}
</includeonly>
Page
{{Cargo1|31.03.2014}}
{{Cargo1|2014-03-31}}
{{Cargo1|.03.2014}}
{{Cargo1|2014-03-}}
{{Cargo1|03.2014}}
{{Cargo1|2014-03}}
{{Cargo1|2014}}
{{Cargo1|2011}}
View table
This table has 8 rows altogether.
Page    descr       value
Cargo2  31.03.2014  2014-03-31
Cargo2  2014-03-31  2014-03-31
Cargo2  .03.2014    1970-01-01
Cargo2  2014-03-    1970-01-01
Cargo2  03.2014     1970-01-01
Cargo2  2014-03     2014-03-01
Cargo2  2014        2014
Cargo2  2011        2010
Database content
_ID  descr       value     value__precision
 1  31.03.2014  2014-03-31  0              
 2  2014-03-31  2014-03-31  0              
 3  .03.2014    1970-01-01  0              
 4  2014-03-    1970-01-01  0              
 5  03.2014     1970-01-01  0              
 6  2014-03     2014-03-01  2              
 7  2014        2014-01-01  3              
 8  2011        2011-01-01  3              
I realized that the syntax is defined, but there are problems in Table View ("2014-03" → "2014-03-01" and "2011" → "2010"). In addition, value__precision for complete date contradicts its description (0 vs. 1). --StasR (talk) 18:07, 17 November 2015 (UTC)Reply
There were a few issues there. The date parsing obviously is not perfect - Cargo uses PHP's own date parsing, for what it's worth. Although those failing dates are in rather awkward formats; are there any that would specifically be useful to handle correctly? The year-off-by-one thing was strange; I just checked in a fix for that. Thanks for letting me know. As for the "precision" field showing the wrong value, I'm guessing that's just because you're using an older version of Cargo. Yaron Koren (talk) 20:08, 17 November 2015 (UTC)Reply
I use Cargo REL1_25. Cargo master and MW 1.25 — is it good? --StasR (talk) 21:33, 17 November 2015 (UTC)Reply
Cargo master View Table:
This table has 8 rows altogether.
Page    descr       value
Cargo2  31.03.2014  2014-03-31
Cargo2  2014-03-31  2014-03-31
Cargo2  .03.2014    1970-01-01
Cargo2  2014-03-    1970-01-01
Cargo2  03.2014     1970-01-01
Cargo2  2014-03     март 2014       - formally OK, but long form :-(
Cargo2  2014        2014
Cargo2  2011        2011            - OK!!!

--StasR (talk) 21:44, 17 November 2015 (UTC)Reply

Great! I think spelling out the month name, when it's only the month and year, is good - don't you agree? That's the usual way it's written out. As for the three failing syntaxes, are there any that you think are a problem? Yaron Koren (talk) 00:47, 18 November 2015 (UTC)Reply
The problem with the wrong year left (the master version is only shifted):
input value DB View Table
(translated)
2014-12 2014-12-01 Dec 2014
2014-03 2014-03-01 Mar 2014
2014-01 2014-01-01 Jan 2014
2013-12 2013-12-01 Dec 2013
2011-01 2011-01-01 Jan 2010
2010-12 2010-12-01 Dec 2010
And about long forms. It is very good for 'View table', but very inconvinient for templates etc. --StasR (talk) 07:36, 18 November 2015 (UTC)Reply
Oops! I forgot to add in that same fix for year/month-only dates. I just checked in what I think is a fix. As for the month formatting: if you want a specific format for the date, I would recommend using the DATE_FORMAT() function within the query, as opposed to doing formatting within a template. Wouldn't that work? Yaron Koren (talk) 14:39, 18 November 2015 (UTC)Reply
Yes, I will use the DATE_FORMAT() function. Thanks for the help! --StasR (talk) 14:57, 18 November 2015 (UTC)Reply
I tried. It turns VERY inconvenient. I need to read the date (probably incomplete) for further processing. The DATE_FORMAT() function (even if it will work) is not intended for incomplete dates. The '__precision' field can not be obtained through '#cargo_query'. I have to use regexps and an array of month names to calculate what really is stored in the database in the required format. --StasR (talk) 07:38, 26 November 2015 (UTC)Reply
It's true that, if you want to have a different custom display for different date precisions, the system does not make it easy to do. The issue isn't with DATE_FORMAT(), since all dates passed in to it are technically at full precision; but having the "__precision" field available in queries might indeed make things much easier - I'll have to look into that. Yaron Koren (talk) 13:31, 26 November 2015 (UTC)Reply
I just added in (re-added, really) the ability to display date precision fields in the query. Is that by itself enough to get this working, though? Or would you also need the ability to call "CASE", or something like it, in the "fields=" parameter? Yaron Koren (talk) 15:36, 30 November 2015 (UTC)Reply
Thank you. I think that is enough. --StasR (talk) 17:17, 30 November 2015 (UTC)Reply

Update to 0.10 version - make my sql request on error ( function SUBSTRING_INDEX())

Hello Yaron, I'm back, still using your Cargo ! I tried to update my cargo to the last 0.10 version, but I have this error message : Error: the SQL function "SUBSTRING_INDEX()" is not allowed. Allmost all my queries are concerning by this pb ... here one exemple of such a query :

{{#cargo_query:
 tables=MagDBCompetenceCollaborateur
 |fields=Experience=Exp,CONCAT('[[Competence:',Competence,'|',SUBSTRING_INDEX(Competence,'/',-1),']]')=Compétences,Secteur=Secteurs,Description_mission=Description,Mots_cles_techniques=Ingénierie logicielle,Mots_cles_metiers=Techniques et scientifiques,Mots_cles_normes=Normes et Standards,Mots_cles_trans=Transverses
 |where=_pageName="Utilisateur:{{PAGENAME}}"
 |format=dynamic table 
 }}

Guillaume Prêcheur (talk)

Hi Guillaume! Yes - the variable $wgCargoAllowedSQLFunctions was added, so you just need to add that function to it; see here. Yaron Koren (talk) 14:47, 18 November 2015 (UTC)Reply
I try to add this setting wgCargoAllowedSQLFunctions line after the Cargo inclusion, but still have an SQL error (Error: the SQL function "COMPETENCE:',COMPETENCE,'|',SUBSTRING_INDEX()" is not allowed.) for the same request - with this settings :
require_once( "$IP/extensions/Cargo.0.10/Cargo.php" );
$wgCargoAllowedSQLFunctions[] = 'SUBSTRING_INDEX';

Am I wrong again somewhere ?--Guillaume Prêcheur (talk) 16:26, 18 November 2015 (UTC)Reply

I think you're running into a bug that I may have fixed last week; I would recommend getting the latest version of the code, if you're not using that now. Yaron Koren (talk) 16:35, 18 November 2015 (UTC)Reply
I'm using the downloaded zip one. I'll try with the git version.--Guillaume Prêcheur (talk)
I tried with the master branch of the git sources. Same problem :-(. --Guillaume Prêcheur (talk)
Alright. What is the exact query you're calling, that leads to this error? I assume it's not the one from above. Yaron Koren (talk) 15:27, 19 November 2015 (UTC)Reply
The query is the same that the one above (I add some <nowiki> tags to display it completly !) --Guillaume Prêcheur (talk)
Ah, now it makes sense. And that's very interesting - it looks like your query had a rather specific combination of punctuation that Cargo's parsing failed on. I just checked in what I think is a fix - if you update your code, hopefully it will work correctly. Yaron Koren (talk) 14:19, 20 November 2015 (UTC)Reply
Ok the first query is now working. But this next one need the declaration of CHAR()
{{#cargo_query:
 tables=MagDBCompetenceCollaborateur,MagDBCollaborateurs
 |join on=MagDBCompetenceCollaborateur._pageName= MagDBCollaborateurs._pageName
 |fields=CONCAT('[[Competence:',MagDBCompetenceCollaborateur.Competence,'|',SUBSTRING_INDEX(MagDBCompetenceCollaborateur.Competence,'/',-1),']]')=Compétences, MagDBCompetenceCollaborateur.Experience=Exp,MagDBCompetenceCollaborateur.Secteur=Secteurs, CONCAT(CHAR(123, 123),'user',CHAR(124),SUBSTRING_INDEX(MagDBCompetenceCollaborateur._pageName,':',-1),CHAR(125,125))= Collaborateur,MagDBCollaborateurs.unite,MagDBCompetenceCollaborateur.Description_mission=Description
 |where=MagDBCompetenceCollaborateur.Competence !="" AND MagDBCollaborateurs.unite != "" AND SUBSTRING_INDEX(Competence,'/',1) LIKE "{{{competence}}}"
 |format=dynamic table 
 }}

If I simply 2 lines

#$wgCargoAllowedSQLFunctions[]  =  'CHAR'
#$wgCargoAllowedSQLFunctions[]  =  'INDEX_SUBSTRING'

It doesn'work (CHAR is not allowed) I tried something like :

#$wgCargoAllowedSQLFunctions[]  =  array('CHAR','INDEX_SUBSTRING');

It's still doesn't work - what'is the right syntaxe to add 2 functions ? --Guillaume Prêcheur (talk)

Ah - you've found another bug. Sorry about that. This one only happens with recent versions of MediaWiki (1.25.3 or higher). If you get the latest version of Cargo, the problem should go away - and then you should use the first of those approaches. Yaron Koren (talk) 17:50, 20 November 2015 (UTC)Reply
Yep - It works ! You fixed it ! thanks - --Guillaume Prêcheur (talk)

Changing lots of content at once

If I were to have a table with "Content" (wikitext) and "Accurate as at" (date) for the columns, is there an easy way to change the dates of multiple pages/rows? For instance, for periodic checks that the content is still accurate, so that readers can be assured that the content is up to date. I imagine that Extension:Replace Text might work, but is there another way? Thanks Jonathan3 (talk) 15:45, 18 November 2015 (UTC)Reply

I would think Replace Text would be the easiest approach. (I don't know how useful that "Accurate as at" field actually would be, but that's another story...) Yaron Koren (talk) 15:58, 18 November 2015 (UTC)Reply
Thanks. I'm interested in your views on the date field... Jonathan3 (talk) 21:42, 18 November 2015 (UTC)Reply
Well, how informative is that field if it's just going to be updated en masse? It doesn't inspire a lot of confidence that anyone is actually checking the accuracy of each page. Yaron Koren (talk) 22:15, 18 November 2015 (UTC)Reply
I see what you mean, but: (a) it boils down to how much people trust the site already; (b) in all likelihood I'll be checking multiple pages each time rather than all pages en masse, just becuase of time constraints, which would lessen your concern; (c) I think Cargo will be useful because I will be able to (for my own purposes) list pages by last-checked-date to prioritise future checks. Jonathan3 (talk) 22:24, 18 November 2015 (UTC)Reply

Changing structure of database once created

I guess this may have the same answer as my other question (about changing lots of data at once) - when you have created your data structure, template, form, etc, is there an easy way, for example, to add a column or change a column name, without having manually to edit all the pages? Thanks Jonathan3 (talk) 15:48, 18 November 2015 (UTC)Reply

Sure - just change the template and form, and recreate the Cargo table. The pages that call that template don't need to be changed, although if a field name changes, that's probably a good idea. Yaron Koren (talk) 17:10, 18 November 2015 (UTC)Reply
I guess that if a field name changes, the pages calling the relevant template would all need to be changed, as otherwise the data wouldn't end up in the Cargo table - is that right? Looking at Replace Text, it looks like you would just use the "Replace only in category" filter to change only the relevant pages. Jonathan3 (talk) 22:29, 18 November 2015 (UTC)Reply
That's right. Yaron Koren (talk) 23:09, 18 November 2015 (UTC)Reply

DATE_FORMAT problem

descr has type Text, value is the same text, but has type Date.

{{#cargo_query: tables=TabTest_1
  |fields = descr, value, DATE_FORMAT(value,"%d.%m.%Y")=var1,DATE_FORMAT(value,"%d %m %y")=var2
  |format = table
}}

Result is:

descr value var1 var2
31.03.2014 2014-03-31 2014-03-31 1970-01-01

--StasR (talk) 09:02, 21 November 2015 (UTC)Reply

Yes, you found another bug - sorry about that. I'm guessing you were the first person to try using DATE_FORMAT(). I just fixed this in the code, I think. Yaron Koren (talk) 15:08, 22 November 2015 (UTC)Reply

Request for new function : Template label for bar chart format output

Hello Yaron, I would like to be able to display bar chart labels throw templates to create links to pages for instance.  

The image above corresponding of what I dreamed about.

--Guillaume Prêcheur (talk)

You may recall that you asked for something similar a few months ago. Unfortunately, the answer is still the same: links would be difficult to implement within the bar chart display. Yaron Koren (talk) 18:42, 25 November 2015 (UTC)Reply

Request for new function : SQL function processing and template evaluation for exhibit format output

Hell Yaron (again) I'm trying the exhibit format queries output to help my users navigating into my skill database.

Sql functions

I'm using sql string formating functions into the field definition of my queries to format the labels . Example :

...
fields=CONCAT('[[Competence:',MagDBCompetenceCollaborateur.Competence,'|',SUBSTRING_INDEX(MagDBCompetenceCollaborateur.Competence,'/',-1),']]')=Compétences ) 
...

 

The exhibit output doesn't take in account the functions into the selection views. In the image above the string before the "\" should not be desplayed (ok for the [[ and ]])

template in the result tab

 

The exhibit output doesn't evaluate wiki syntaxe into the result view : In the image above :

  • column Label : the string before the "\" should not be desplayed and the label should be displayed as a link
  • column Collaborateur: the template is not evaluated.

--Guillaume Prêcheur (talk)

Columns hard coded in UL and OL formats

Tried to use the column parameter for the UL and OL formats but any time you add any number other than 1 you get three columns. Looked at the files for the OL and UL formats and 3 columns is hard coded for anytime the number isn't 1. --Cody3647 (talk) 01:04, 29 November 2015 (UTC)Reply

Ah, that's true! Sorry about that. Maybe I never tested it with a value other than 3. This is fixed now, in the latest code. Yaron Koren (talk) 15:38, 30 November 2015 (UTC)Reply

Did not find alias for special page

Just FYI (low priority), I'm seeing these Warnings in the debug console for Cargo when I goto the special pages main page.

Warning	Did not find alias for special page 'CargoTables'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor
Warning	Did not find alias for special page 'DeleteCargoTable'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor
Warning	Did not find alias for special page 'ViewData'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor
Warning	Did not find alias for special page 'Drilldown'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor
Warning	Did not find alias for special page 'GetData'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor
Warning	Did not find alias for special page 'GetData'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor
Warning	Did not find alias for special page 'CargoTables'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor
Warning	Did not find alias for special page 'DeleteCargoTable'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor
Warning	Did not find alias for special page 'Drilldown'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor
Warning	Did not find alias for special page 'ViewData'. Perhaps no aliases are defined for it?	SpecialPageFactory::getLocalNameFor

Looks like common issue/fix mentioned here:

Manual:Notices_and_error_messages

--Kc5vcx (talk) 17:33, 30 November 2015 (UTC)Reply

Thanks for the suggestion; I just added in an alias file. (Although Special:GetData comes from External Data - it could probably use an alias file too). Yaron Koren (talk) 00:25, 4 December 2015 (UTC)Reply

Custom text if Date is NULL

I have fields which are declared as dates (I need to do date comparisons) and wonder whether it is possible in the (dynamic) table format to display some custom text (e.g. "Ongoing") when the date field is NULL. Sorry if the answer is really obvious. Jonathan3 (talk) 21:49, 30 November 2015 (UTC)Reply

The only way I can think of to do that is to create another field in the Cargo table, which is of type String, and which is given the date if it's not null, or that custom text if it's null; and then display that in the query instead of the true date field. I don't know how it would look, though. Yaron Koren (talk) 23:56, 30 November 2015 (UTC)Reply
Thanks. I guess that could be done with a MySQL trigger but sadly I'm running too old a version. Does Cargo have any feature that would help here? Jonathan3 (talk) 00:20, 1 December 2015 (UTC) P.S. I doubt it, and am sure I would need to do it manually, but thought it worth asking Jonathan3 (talk) 00:21, 1 December 2015 (UTC)Reply
Just use an #if call within the #cargo_store call. Yaron Koren (talk) 00:53, 1 December 2015 (UTC)Reply

Format timeline error

Hi Yaron, I'm trying the timeline query format, I have got this error message :

Caught exception: SyntaxError: expected expression, got ')'

My template is :

{{#cargo_query:
tables=MagDBProjets
|fields=MagDBProjets.Date_debut
|where=MagDBProjets._pageName ="MagDBProjetDeTest"
|format=timeline 
}}

the query works (and return me a date) with default format. Any idea ? --Guillaume Prêcheur (talk) 11:31, 1 December 2015 (UTC)Reply

Where are you seeing that error message? And is there a line number or something for it? Yaron Koren (talk) 15:31, 1 December 2015 (UTC)Reply

 

The message appear in a popuped message window- no line number - It occurs when displaying the template page or the page containing the template page.

--Guillaume Prêcheur (talk) 09:10, 2 December 2015 (UTC)Reply

No idea. Are you using the latest version of Cargo? I should note that it's strange to just display the date, and not any other fields, although it should still work. Yaron Koren (talk) 14:00, 2 December 2015 (UTC)Reply

SQL error on Example

I noticed a SQL error on your following page : http://discoursedb.org/wiki/Colombia-United_States_Free_Trade_Agreement --Guillaume Prêcheur (talk) 11:35, 1 December 2015 (UTC)Reply

Thanks for letting me know about that; I just fixed it. Yaron Koren (talk) 15:32, 1 December 2015 (UTC)Reply

SQL error on my forms ..

Hello Yaron,

Still trying to upgrate to the 0.10 version, but i notice a new error message on my projet's editing form :

A database error has occurred. Did you forget to run maintenance/update.php after upgrading? See:  https://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script Query: SELECT `cargo__MagDBProjets__Client_direct`._value AS "Client direct" FROM `cargo__MagDBProjets` LEFT OUTER JOIN `cargo__MagDBProjets__Client_direct` ON ((`cargo__MagDBProjets`._ID=`cargo__MagDBProjets__Client_direct`._rowID)) GROUP BY `cargo__MagDBProjets__Client_direct`._value HAVING `cargo__MagDBProjets__Client_direct`._value ORDER BY 200 LIMIT 100 Function: CargoSQLQuery::run Error: 1054 Unknown column '200' in 'order clause' (localhost)

My template is pretty large, I didn't dump it in this page, let me know if you need it to investigate, I'll send you as a imported file or just an extract ..

Thanks. --Guillaume Prêcheur (talk) 12:22, 1 December 2015 (UTC)Reply

What version are you running? And what does the "{{{field}}}" tag look like for the "Client direct" field? Yaron Koren (talk) 15:33, 1 December 2015 (UTC)Reply
This message occurs when I jump to the 0.10 cargo version (git update 23/11/2015 10:59) - MediaWiki 1.24.1 - Semantics Forms 3.1 - Semantic MediaWiki 2.1.1 - Semantic Forms Input 0.7

Nothing special on the "{{{field}}}" tag - here is an extract on my Form definition :

 <noinclude>
 * Ceci est le formulaire ... 
 * Le modèle de données ...
 * Pour créer une page...
 * Pour tout renseignement ...
 * Pour tout renseignement ...
 {{#forminput:form=MagDBProjet}}
 [[category:MagDB]]
 </noinclude><includeonly>
 <div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div>
 {{{for template|MagDBProjet}}}
 ...
 = Organisation =
 {| class="formtable"
 ! Unite de rattachement: 
 | {{{field|Unite_de_rattachement}}}
 |-
 ! Date de début: 
 | {{{field|Date_debut|input type=datepicker}}}
 |-
 ! Date de fin: 
 | {{{field|Date_fin|input type=datepicker}}}
 |-
 ! Equipe avant-vente - commerciale: 
 | {{{field|Equipe_avv|values from namespace=Utilisateur}}}
 |-
 ! Equipe de management: 
 | {{{field|Equipe_de_management|values from namespace=Utilisateur}}}
 |-
 ! Equipe technique: 
 | {{{field|Equipe_technique|values from namespace=Utilisateur}}}
 |-
 ! Client direct: 
 | {{{field|Client_direct}}}
 |-
 ! Client final: 
 | {{{field|Client_final}}}
 |-
 ! Partenaires: 
 | {{{field|Partenaires}}}
 |-
 ! Fournisseurs: 
 | {{{field|Fournisseurs}}}
 |}
 ...
 {{{end template}}}
 

Here is an extract of the template :


 {{#cargo_declare:
 _table=MagDBProjets
 |Objet_fr=Text (size=200)
 |Objet_en=Text (size=200)
 |Description_courte_fr=Text (size=200)
 |Description_courte_en=Text (size=200)
 |Description_longue_fr=Text (size=800)
 |Description_longue_en=Text (size=800)
 |Projets_parents=List (,) of Page
 |Prestation=Text (allowed values= {{#var:Prestations}} )
 |Thematique=Text (allowed values= {{#var:Thematiques}} )
 |Secteur=Text (allowed values= {{#var:Secteurs}} )
 |Budget=Text (allowed values= {{#var:Budgets}} )
 |Chrono_Ptf=Text (size=15)
 |Code_ASA=Text (size=15)
 |Date_debut=Date
 |Date_fin=Date
 |Unite_de_rattachement=Text (allowed values= {{#var:Unités}} )
 |Equipe_de_management=List (,) of Page
 |Equipe_technique=List (,) of Page
 |Positionnement=Text (allowed values= {{#var:Positionnements}} )
 |Client_direct=List (,) of Page
 |Client_final=List (,) of Page
 |Fournisseurs=List (,) of Page
 |Partenaires=List (,) of Page
 |Mots_cles_techniques=List (,) of Page (allowed values={{#var:Techniques}} )
 |Mots_cles_metiers=List (,) of Page (allowed values= {{#var:Metiers}} )
 |Mots_cles_normes_et_standards=List (,) of Page (allowed values= {{#var:Normes_et_standards}} )
 |Repertoire_projet=Text
 |Bug_tracker=Text (link text= Bug tracker)
 |Gestion_configuration=Text (link text= Gestion de configuration)
 |Wiki_projet=Text (link text= Wiki Projet)
 |Equipe_avv=List (,) of Page
 |Statut_projet=Text (allowed values= {{#var:Statuts_projets}} )
 |Type_projet=Text (allowed values= {{#var:Types_projets}} )
 |Nature_projet=Text (allowed values= {{#var:Natures_projets}} )
 |Thematique_CIR_CII=Text (allowed values= {{#var:Thematiques_CIR_CII}} )
 |Retex_RD=Text (size=800)
 }}
 [[Category:MagDB]]
 </noinclude>
 <includeonly>
 __NOEDITSECTION__
 {{#cargo_store:
 _table=MagDBProjets
 |Objet_fr={{{Objet_fr|}}}
 |Objet_en={{{Objet_en|}}}
 |Description_courte_fr={{{Description_courte_fr|}}}
 |Description_courte_en={{{Description_courte_en|}}}
 |Description_longue_fr={{{Description_longue_fr|}}}
 |Description_longue_en={{{Description_longue_en|}}}
 |Projets_parents={{{Projets_parents|}}}
 |Thematique={{{Thematique|}}}
 |Secteur={{{Secteur|}}}
 |Prestation={{{Prestation|}}}
 |Budget={{{Budget|}}}
 |Chrono_Ptf={{{Chrono_Ptf|}}}
 |Code_ASA={{{Code_ASA|}}}
 |Date_debut={{{Date_debut|}}}
 |Date_fin={{{Date_fin|}}}
 |Unite_de_rattachement={{{Unite_de_rattachement|}}}
 |Equipe_avv={{{Equipe_avv|}}}
 |Equipe_de_management={{{Equipe_de_management|}}}
 |Equipe_technique={{{Equipe_technique|}}}
 |Positionnement={{{Positionnement|}}}
 |Client_direct={{{Client_direct|}}}
 |Client_final={{{Client_final|}}}
 |Fournisseurs={{{Fournisseurs|}}}
 |Partenaires={{{Partenaires|}}}
 |Mots_cles_techniques={{{Mots_cles_techniques|}}}
 |Mots_cles_metiers={{{Mots_cles_metiers|}}}
 |Mots_cles_normes_et_standards={{{Mots_cles_normes_et_standards|}}}
 |Repertoire_projet={{{Repertoire_projet|}}}
 |Bug_tracker={{{Bug_tracker|}}}
 |Gestion_configuration={{{Gestion_configuration|}}}
 |Wiki_projet={{{Wiki_projet|}}}
 |Type_projet= {{{Type_projet|}}}
 |Nature_projet={{{Nature_projet|}}}
 |Statut_projet={{{Statut_projet|}}}
 |Thematique_CIR_CII={{{Thematique_CIR_CII|}}}
 |Retex_RD={{{Retex_RD|}}}
 }}__NOEDITSECTION__

  • If I hide the Client_direct field in the form, it return a error message concerning the next field ...
  • If I hide the {| class="formtable" ... |} it runs well (without the formtable ..)
  • If I hide the fields from Client_direct to the end of the form, it runs well (without the hidded fields)
  • I also tried to cut my formtable in two peaces ... doesn't work ...(even if I just add one field in the second formtable (Fournisseurs for instance))

--Guillaume Prêcheur (talk) 09:26, 2 December 2015 (UTC)Reply

Aha - my guess is that this issue will go away if you upgrade your version of Semantic Forms. Yaron Koren (talk) 14:02, 2 December 2015 (UTC)Reply
It solve my pb - thanks --Guillaume Prêcheur (talk) 08:49, 3 December 2015 (UTC)Reply

duplicate entries in cargo sql tables

I'm seeing duplicate entries in my cargo sql tables. I have a test page using a form, I hadn't editing it for at least a day (other users editing pages in same category, but not using forms yet). Today I had like 9 rows for the same page, I thought maybe all the test edits I had done before caused the duplicates, but I just went and made a change, and it cleared back out to one. Maybe it was recreating the template, but that doesn't seem to be happening now. Seemed more like it happened on it's own. I think I could run the recreateData maintenance script but don't want to have to keep running it. I was looking at the possibility of letting somebody else run some advanced reporting outside of mediawiki, but didn't want to open that up if the data was messy. Thoughts? --Kc5vcx (talk) 04:10, 4 December 2015 (UTC)Reply

This sometimes happens; it has something to do with jobs, but beyond that I don't know. I hope to fix it. Yaron Koren (talk) 13:12, 4 December 2015 (UTC)Reply
I was trying to manually runjobs each time I modified the template pages, maybe not each time I edited or between quick edits. My system is internal and I'm not really worried about the load, is there a way to just force it to do all the updates inline rather than using job queue if this would help? --Kc5vcx (talk) 14:40, 4 December 2015 (UTC)Reply

Format List (,) of page inside a tab

hello Yaron In my model, I defined the project's management team as list of Page (as link to the User:Xxx page)

|Equipe_de_management=List (,) of Page

Inside a tab format query the field returned looks like : Xxx,Yyy,Zzz How can I do to format this result to produce something like [[User:Xxx|Xxx] [[User:Yyy|Yyy] [[User:Zzz|Zzz] ? --Guillaume Prêcheur (talk) 14:43, 4 December 2015 (UTC)Reply

What's a tab format query? Also, does that field right now link to the page "Xxx", or the page "User:Xxx"? That wasn't clear to me. Also, do you know about #arraymap? Yaron Koren (talk) 14:54, 4 December 2015 (UTC)Reply
this is a dynamic table format - the content of the field is Xxx (so the result propose a link to the Xxx page) - Can I use #arraymap inside a tab ?
No (though I still don't know what a tab is). But actually, thinking about it now, you might not need to call #arraymap at all. I would change that field's type from "Page" to "String" - and then, within the query's "fields=" parameter, instead of "Equipe_de_management", put in something like "CONCAT('[[User:', Equipe_de_management, '|', Equipe_de_management, ']]')". Yaron Koren (talk) 17:53, 4 December 2015 (UTC)Reply

where clause on page names with special characters

Cargo doesn't seem to handle page names with special characters very well, at least when needing to use them in a where clause like:

|where=._pageName="{{FULLPAGENAME}}"

It gives this message:

Error in "where" parameter: the string "#" cannot be used within #cargo_query.

I believe it's the same issue happening at your demo on this page. Thanks. --Kc5vcx (talk) 21:58, 9 December 2015 (UTC)Reply

Sorry about that; there was a validation change I made a few months ago that led to that error. I think I just fixed it in the code. Thanks for diagnosing the problem. Yaron Koren (talk) 01:19, 10 December 2015 (UTC)Reply
I got the latest Cargo code via git and see your change, unfortunately still doesn't seem to work. My page name is like
12-34 Company 'Test'
and I'm still using a where query like
._pageName={{FULLPAGENAME}}
--Kc5vcx (talk) 21:57, 11 December 2015 (UTC)Reply
Same error message? Yaron Koren (talk) 22:13, 11 December 2015 (UTC)Reply
Yes. --Kc5vcx (talk) 22:46, 11 December 2015 (UTC)Reply
I found a workaround and maybe better to use .pageID field and magicword {{PAGEID}} instead of full page name. --Kc5vcx (talk) 02:37, 13 December 2015 (UTC)Reply
Fun with PHP. It turns out that PHP's default HTML decoding decodes everything except for single quotes. I just checked in a fix, so if you go back to using "PAGENAME" it should work now. There's nothing wrong with using "PAGEID", though. Yaron Koren (talk) 15:11, 14 December 2015 (UTC)Reply
Confirmed fixed, thanks! --Kc5vcx (talk) 23:05, 14 December 2015 (UTC)Reply

Holds not working correctly

I've got a query that uses HOLD after several other conditions in the where clause. It was working when I originally wrote it on Dec 3. Now I get an error when using HOLDS after an AND where the query shown does not have a space between the AND and the name of the value field. Adding an extra space (AND  HOLDS) makes the query work. --Cody3647 (talk) 22:48, 23 December 2015 (UTC)Reply

Yes - this was a bug that was introduced on Dec. 17, and fixed on Dec. 22 - you just need to update your code. Yaron Koren (talk) 23:27, 23 December 2015 (UTC)Reply
I double checked and pulled from git again, but it said Cargo was up-to-date but the problem is still there.--Cody3647 (talk) 23:48, 23 December 2015 (UTC)Reply
That's very odd. Can you check to see if your version of CargoSQLQuery.php contains this code? Yaron Koren (talk) 02:39, 24 December 2015 (UTC)Reply
Yes the changes are there.--Cody3647 (talk) 04:41, 24 December 2015 (UTC)Reply
Is this viewable on a public wiki? Now that I think about it more, I don't know how "AND HOLDS" could work within a query. Yaron Koren (talk) 05:36, 24 December 2015 (UTC)Reply
Not Working Example and Working Example with the extra space. --Cody3647 (talk) 06:43, 24 December 2015 (UTC)Reply
Okay, thanks for the example. (I thought you literally meant "AND HOLDS".) And sorry about that. Clearly the issue hasn't been fully fixed... Yaron Koren (talk) 14:53, 24 December 2015 (UTC)Reply
I believe this is now fixed in the latest code. Yaron Koren (talk) 23:45, 25 December 2015 (UTC)Reply

Simple Scribunto library for Cargo

I made a simple tool for processing Cargo queries in Lua: User:StasR/CargoLua. If the request specifies |format=lua, the result of a query is available through the function mw.ext.cargo.get(). Is it possible to include this (or something similar) in the standard version? --StasR (talk) 12:14, 25 December 2015 (UTC)Reply

Wow, this is great! I'll be happy to include this functionality. I wonder, though, if the name for the format, 'lua', couldn't be made more generic? After all, all the format itself really does is make the query results available as a global PHP variable. This could be used by more than just Lua - in the most basic case, Scribunto could offer support for a language other than Lua, and this format could then be used by that other language. There are also potentially other extensions that could make use of it, etc. I don't know what a good alternate name might be, though - 'in memory'? 'for code'? What do you think? Yaron Koren (talk) 03:45, 26 December 2015 (UTC)Reply
Maybe 'pure'?
Generally, it would be interesting to pick up the result a little earlier, before converting values to strings. But my skill is not enough to understand whether and how to do it. --StasR (talk) 08:43, 26 December 2015 (UTC)Reply
I could live with "pure". And there could be special handling for this format earlier on in the process, so that the values are kept as non-string values. What is an example of where that would help? Yaron Koren (talk) 16:55, 26 December 2015 (UTC)Reply
I don't have a specific example. Just a lack of transformation is better than two transformations. But I'm not sure that this is necessary if it requires a lot of work. --StasR (talk) 22:15, 26 December 2015 (UTC)Reply
I don't think it would take that much work, but it would be special handling, and I'd prefer if there were a clear reason to do that. Barring an example, I'll probably just add in this code as-is, other than the necessary changes to change the format name. Yaron Koren (talk) 01:18, 27 December 2015 (UTC)Reply
ОК. Other options for the name of the format: 'none', 'native', 'internal', 'array'. --StasR (talk) 08:34, 27 December 2015 (UTC)Reply
Hm - all of those have their own merits. Any preferences? Yaron Koren (talk) 14:54, 27 December 2015 (UTC)Reply
To your taste :-). Attention: https://www.mediawiki.org/w/index.php?title=User%3AStasR%2FCargoLua&type=revision&diff=1983509&oldid=1980374 (unset($global) does not work correctly inside functions). Also should be set '$wgCargo_Lua = NULL' on an empty query result. --StasR (talk) 20:41, 27 December 2015 (UTC)Reply
Alright, I added in your code, with some small modifications; I went with "native" for the format name. I can't test out the code, so please let me know if you find any issues. Yaron Koren (talk) 04:37, 12 January 2016 (UTC)Reply
Many thanks! I will try it in the next few days. --StasR (talk) 16:07, 12 January 2016 (UTC)Reply
It works! --StasR (talk) 10:59, 15 January 2016 (UTC)Reply
That's great! Thank you for all the code. I look forward to officially releasing this. Yaron Koren (talk) 14:46, 15 January 2016 (UTC)Reply
Return to "Cargo/Archive November to December 2015" page.