Extension talk:Cargo/Archive August to December 2020

Having issues with Cargo not requesting data

Hi, I've just installed cargo and currently i am having a problem where I'm getting the error Error: The SQL function "FIELD()" is not allowed. I am using my original mediawiki db and I have updated the db to have cargo functions. What is going wrong?

This is the page I am having issues with https://nartherael.com/Narthwiki/index.php?title=Nartherael_(world)

It seems like you've made several changes to the query - but if there's a specific query you want help with, please put it here. In general, though, queries with complex logic might be better done some other way, such as by using Scribunto/Lua. Yaron Koren (talk) 03:12, 14 December 2020 (UTC)

so the issue i'm having at the moment is

"Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near -') ORDER BY CONCAT(description, IF(LENGTH(category)>0, CONCAT('[[',category, at line 1 (localhost) Function: CargoSQLQuery::run Query: SELECT CONCAT(description, IF(LENGTH(category)>0, CONCAT('',category,''),)) FROM `cargo__TradeSummary` WHERE `cargo__TradeSummary`.`_ID` IN (SELECT _rowID FROM `cargo__TradeSummary__code` WHERE _value = CONCAT() '-') ORDER BY CONCAT(description, IF(LENGTH(category)>0, CONCAT('',category,''),)) LIMIT 100"


which i think is this part.

REPLACE(REPLACE(BasesCode.description,'%Allegiance%',COALESCE(AllegianceCode.short_name, '')),'%article%',COALESCE(AllegianceCode.article,'a')) = basesDescription, BasesCode.category = basesCategory, CONCAT('{{#replace:{{{Non-canon trade codes|}}}|'|''}}')=NCcodes, CONCAT('{{#replace:{{{First Survey name|}}}|'|''}}')=FSName, CONCAT('{{#replace:{{{Nahuatl name|}}}|'|''}}')=NSName


what am I doing wrong?

I have no idea. But that seems awfully complex. :) And, I'm sure you'd agree, somewhat of a hack. Have you considered using Scribunto (which itself would query the Cargo data) instead? Yaron Koren (talk) 02:55, 17 December 2020 (UTC)

I’m not 100% sure what it’s even doing to the template. I copied off this template, which seems to work but it’s an earlier version of mediawiki, so I’m not sure.

This is the template I copied

https://wiki.travellerrpg.com/Template:StellarDataQuery

Which works here.

https://wiki.travellerrpg.com/Template:StellarData.layout

But when I’ve copied it into my wiki and used the exact same extensions etc it’s getting that error? Is it a cargo error or something else?

I don't know - I'm surprised that this query works in any set of circumstances. It's somewhat of a hack! I'm guessing that there are better ways to get whatever output you are trying to display. Yaron Koren (talk) 17:14, 20 December 2020 (UTC)

Every Date after 27-12 (include) in every year will be stored as the next year

Hi, Im using cargo 2.0.1.

I saw a problem that i can reproduce with open new table (2 fields, one of them is Date).

I store this value in the Date field=28-12-1957 and when i query\see this table the saved date is: 28-12-1958.

Tried also:

  • year > 2000
  • Insert the date as: 1957-28-12

TY — Preceding unsigned comment added by Koshob (talkcontribs) 22:48, 2 August 2020‎ (UTC)

This might have been fixed already. Could you try using the latest version of Cargo? Yaron Koren (talk) 00:16, 3 August 2020 (UTC)

Koshob (talk) 21:13, 3 August 2020 (UTC) Indeed, ty!

Conditional formatting tables

I Have a table with different color hexcodes in table cells. Is it possible to make the backgroundcolor of a tablecell so to match the code for each cell? Something like: style=background: #c6bdab | DGWKJacobs (talk) 10:42, 10 August 2020 (UTC)

Are you asking about the Cargo "template" format? Yaron Koren (talk) 13:53, 10 August 2020 (UTC)
Its about a cargo query with table as display format. I am trying:
{{#cargo_query:
tables=XXX
|fields= _pageName=Catalogsnummer, File,Headline, CONCAT("style=background: #",Color1),Color2, Color3, Color4, Color5
|format=table
|columns=3
|group by=Headline
|limit=500
}}
Unfortunately, I don't think there is any way to set the formatting of cells in the the "table" format. You might have to instead manually (more or less) create the table, using the "list" or "template" formats. Yaron Koren (talk) 20:17, 13 August 2020 (UTC)
I nested the cargoquery with template as displayresult inside the wikitable syntax: DGWKJacobs (talk) 02:00, 28 August 2020 (UTC)
{| class="wikitable sortable"
! Catalogusnummer !! Uitgever !! Datering !! Kleur 1 !! Kleur 2 !! Kleur 3 !! Kleur 4 !! Kleur 5
|-
{{#cargo_query:
tables=Metadata
|fields=_pageName=Page, Color1, Color2, Color3, Color4, Color5
|format=template
|template=Colortable
|order by=Page ASC
}}
|}
The template Colortable defines the body of the table:
| [[: {{{1}}} ]] ||  ||  || style='background: #{{{2}}}' | #{{{2}}} || style='background: #{{{3}}}' | #{{{3}}} || style='background: #{{{4}}}' | #{{{4}}} || style='background: #{{{5}}}' | #{{{5}}} || style='background: #{{{6}}}' | #{{{6}}}
|-

Error: table “Level” not found

See also phab on miraheze.

The template located at Template:关卡信息 defined a Cargo table "Level". However, when visiting Special:CargoTables/Level, it reads: Error: table Level not found. And Special:CargoTables shows nothing. If I re-create the table, it doesn't help.

I also created some sandbox tables like Template:Sandbox and Template:沙盒, and the same thing happens.

The error message provides no details. It's unlikely to set $wgShowExceptionDetails according to Miraheze stewards and actually the detail is the same as a table that really does not exist.

--SolidBlock (talk) 10:55, 17 August 2020 (UTC)

Yes, clearly the table was not created - your Special:CargoTables page shows no tables. Somehow the "create table" command failed - maybe because the template name contains non-ASCII characters, I don't know. Did you try creating the table from the web interface, or the command line? Whichever one you tried, I would try the other one. Yaron Koren (talk) 15:29, 17 August 2020 (UTC)
@Yaron Koren: I created the table via the interface label near the "view/edit/history". Maybe due to non-ascii characters, but Template:Sandbox is also wrong. And the parser function #cargo_declare shows the table is defined (unless the table is really not defined). ——SolidBlock (talk) 15:53, 17 August 2020 (UTC)
Oh, I didn't notice that you mentioned the "Sandbox" template as well. Yes, that one looks totally non-ASCII - and all the calls in it look fine. And you probably don't have command-line access, unfortunately. Here is what you should do: go again to one of those templates, "inspect" the page by right-clicking and then go the "Network" tab, and follow the process again to create the table. The last URL in the "Network" tab is the API page that actually does the table creation; if you go to that URL, you might be able to see a more helpful error message. Yaron Koren (talk) 16:59, 17 August 2020 (UTC)
I did what you said to, and got the following messages:
https://rs.miraheze.org/w/api.php?action=cargorecreatedata&table=Sandbox&template=Sandbox&offset=0
{
    "success": ""
}
https://rs.miraheze.org/w/api.php?action=cargorecreatetables&template=Sandbox
{
    "error": {
        "code": "internal_api_error_DBQueryError",
        "info": "[818b4c0f68a0e4e2c9c7303e] Caught exception of type Wikimedia\\Rdbms\\DBQueryError",
        "errorclass": "Wikimedia\\Rdbms\\DBQueryError"
    },
    "servedby": "mw6"
}
--SolidBlock (talk) 00:50, 18 August 2020 (UTC)
Alright - here is indeed a case where being able to see the exception details would be helpful. My only guess right now is that the database tables cargo_tables and cargo_pages were never created for this wiki (update.php needs to be called to create them). Is that possible? Yaron Koren (talk) 01:07, 18 August 2020 (UTC)
I don't think so...I don't know how to call update.php. SolidBlock (talk) 01:50, 18 August 2020 (UTC)
I meant, is it possible that that's the issue. Yaron Koren (talk) 03:53, 18 August 2020 (UTC)
I see "Error: 1054 Unknown column 'field_helper_tables' in 'field list' (db11.miraheze.org)" in the logs. RhinosF1 (talk) 08:48, 18 August 2020 (UTC)
Aha! That's helpful. The column field_helper_tables was added in 2017. So clearly either this database, or the code you are using to install Cargo on a new wiki, are from before then. You just need to update the DB, or the code, or both, and then hopefully everything will work. Yaron Koren (talk) 14:10, 18 August 2020 (UTC)
I will inform miraheze stewards. They may be able to help do that. --SolidBlock (talk) 14:28, 18 August 2020 (UTC)
It's fiexd now. Thanks for your help. --SolidBlock (talk) 03:34, 23 August 2020 (UTC)

timeline error - Caught exception: SyntaxError: Unexpected token '<'

Hi, I´m new to Cargo and running a private wiki on Windows 7 64-bit with Xampp 7.4.7. I'm getting the above error when trying to see timeline displayed on Drilldown and also when I try to use it as a display format of #cargo_query. After some research I have found this 2018 post about what seems to be a similar problem:
1.timeline causing error

However, the sugested fix didn´t work for me (installing MagicNoCache extension and adding "__NOCACHE__", on a line by itself, to any page that calls the "timeline" format.). The same error message remains...

  • Caught exception: SyntaxError: Unexpected token '<'

Even if the fix worked, I wouldn´t be able to use it on Special Page drilldown, since, as far as I can see, it's not possible to edit this page to add the magic word. I wonder if it has some relation to previously installed SMW or the Modern Timeline or Semantic Bundle extensions on my wiki. Before I discovered Cargo...

My installed software are recent versions, but my system Windows OS is perhaps a bit outdated...

  • MediaWiki 1.34.1
  • PHP 7.4.7 (apache2handler)
  • MariaDB 10.4.13-MariaDB
  • Page Forms 4.9.5
  • Cargo 2.6
  • Page Schemas 0.5.1

PS: When I try to use the Cargo Query Special Page, it displays the query correctly, except for the error message

ErrorException from line 106 of C:\xampp\htdocs\mediawiki\extensions\Cargo\includes\CargoQueryDisplayer.php: PHP Notice: Trying to access array offset on value of type null

This line of code reads

$tableName = $this->mFieldTables[$fieldName];

I suspect it is somehow connected to the problem...

Any help would be much appreciated!

csv export

Hello, I have a one cargo table. I have a multiple instances template and a main template.

Is it possible to get my csv export to contain all my fields to populate one row? My multiple instance data populates a separate row and my main template data populate another row. Note, I am using a cargo_query:

{{#cargo_query:table=Request_calendar_item
|fields=_pageName=Title,Program_Name=Program Name,Month,Monthly_Time=Monthly Time,Technician
|where=Request_calendar_item.Month LIKE "%{{{Month|}}}%"
|order=asc
|headers=show
|format=csv
|limit=2000
|link text=HERE
|parse values
|filename=Monthly Resources.csv
}}

Program Name is from the main template. Thank you for your wonderful tool! Regards, Margaret

I don't understand - you have two templates but only one Cargo table? Yaron Koren (talk) 22:31, 31 August 2020 (UTC)
Yes, One Cargo table and two templates. The main template and a multiple instance template that attaches to the table.
{{#cargo_attach:_table=Request_calendar_item |Technician=String |Month=String |Monthly_Time=Integer }}
If I understand it correctly, these two templates each have a different set of fields. If that's the case, they should each have their own Cargo table - defining them together provides no benefit. If you want to then display them together, use "join on". Yaron Koren (talk) 13:53, 2 September 2020 (UTC)
If I can add a multiple instance template in the main template, that would be preferred. Maybe I missed something when it comes to the multiple instances (when you can add the same field multiple times on one page.) Thank you for your info. Margaret

What is a cargo admin?

Hello guys! I am confused about cargoadministrators. What do they do? --Jakek (Talk | Contributions | CentralAuth) 18:16, 29 September 2020 (UTC)

There's no such thing as a "Cargo administrator", at least by default. Cargo defines two permissions - "recreatecargodata" and "deletecargodata" - which, by default, are only available to admins/sysops. You could create a user group that has those two permissions, but there's no need to do it. Yaron Koren (talk) 18:22, 29 September 2020 (UTC)

Question about query documentation

The query documentation page explains the #cargo_query parameters entirely in reference to SQL SELECT queries, as opposed to describing their functions independently. Is there anywhere where the parameters are explained in terms of what they actually mean for those who know nothing of SQL? Sunmarsh (talk) 15:15, 8 October 2020 (UTC)

That's very true, I never thoughts about that... I need to improve the documentation. Yaron Koren (talk) 14:22, 13 October 2020 (UTC)

Dynamic Tables and Detail/Hidden Fields: Is there a known live example?

I cannot figure out why my attempts at using the Hidden and Detail Fields features of the Dynamic Table format are not working and was hoping to find a working example somewhere. The two examples given in the Dynamic Table subsection do not utilize these options. I tried using the query editor and while it does generate wikitext, it does not work (either in the "preview" of the editor or in a page itself). A small bit I noticed is that while the input fields in the query editor generally give options/predictive text when selecting tables/fields, it does not in these Detail and Hidden fields....maybe this functionality doesn't function yet? Thanks in advance for any help that can be provided. --206.55.182.254 03:52, 11 October 2020 (UTC)

Here is a live example I just generated, using Special:CargoQuery. Note that any fields listed in "details fields" or "hidden fields" have to also be included in "fields" - maybe that explains the problem you were seeing. And it would be great if those two inputs had autocompletion in Special:CargoQuery, but that is not implemented yet, unfortunately. Yaron Koren (talk) 14:27, 13 October 2020 (UTC)
Ahh okay, I didn't have it in the selected fields as you suggested. Thank you! Now I'm going to experiment with only returning fields that have data. --206.55.182.254 15:17, 13 October 2020 (UTC)

Back again (this time as a registered user!) with another question on details fields. Is it possible to only show fields that are marked as "detail fields" if there is a result/value in the field? I understand that for a normal table it wouldn't be possible because if any record has a result, there is no way to "hide the column/field". But if the fields that are marked as "detail" does that they mean they are basically their own mini table, and thus able to have each field hidden if there is no value in it? If there are 5 total detail fields for each record, and a particular record only has values in 3 of those fields, could I hide the other two? If not possible with the data/table itself, I'll see if i can do it with CSS. Thanks again for your help.--GrapheneBob (talk) 17:25, 14 October 2020 (UTC)

It's not currently possible. "dynamic table" uses the DataTables JavaScript library, so if it's possible there, then it could probably be added to this result format. Yaron Koren (talk) 21:51, 14 October 2020 (UTC)
Okay thank you for confirming. In the meantime, I think I'll be able to do this with CSS by targeting empty td or p tags and reducing their width/height to 0. Thanks again!--GrapheneBob (talk) 00:30, 15 October 2020 (UTC)

Exception: Parser::parse recursively? Lock is held by...

Hi, Im keep getting this exception: https://pastebin.com/McL4SzFb while running a query, Be glad for help.

When running the original Query with bigger limit im not getting this exception. This one is raised only when running the query with a limit (lets say 15) and then pressing the "More..." link to see a special window with more results.

I can supply the query, But that seems to be related to "Special:CargoQuery" Page. TYVM for help Koshob (talk) 22:22, 11 October 2020 (UTC)

Yes, what is the query? And what version of MediaWiki are you running? Yaron Koren (talk) 14:28, 13 October 2020 (UTC)

Query Mapping Info

MW 1.35 Maps 7.20.1 Page Forms 2.7

How do I create a page that displays the coordinates (pin) on a map of entries I made from Page Forms? This does not work: {{#cargo_query:tables=New Home Builders|fields=_pageName,Coordinates|format=openstreetmaps}} and says Error: Table New Home Builders not found. Cargo is installed, Maps installed, Page Forms installed and at least Page Forms and Maps work as it creates the pages I enter. Thanks! -- Foreclosurepedia (talk) 20:38, 15 October 2020 (UTC)

I figured out the other issues (spaces must use _ and field was address); however, I do not know how to display those coords on a Map.

Page calling data for map: https://digitalmatrixgroup.com/index.php/Investor_Assets format=googlemaps works but kicks the developer stuff, I want to use Open Street Maps. Thanks! -- Foreclosurepedia (talk) 21:02, 15 October 2020 (UTC)

Solved. openlayers is openstreetmaps for want of better words. Leaving up for other new folks like me whom have no clue. -- Foreclosurepedia (talk) 21:25, 15 October 2020 (UTC)

Some pages do not get stored on their table?

Hello, I'm having an issue that I'm not entirely certain how or why it is occurring. For some reason, not all pages using the template that defines and stores data in one of our cargo tables appear in the table defined by it. Editing the page to force it to update has no effect. If it helps, this is the table and this is one of the pages which is consistently affected. It isn't in the table at all, even though it uses the template that defines the table. What could be causing this? Disgustedorite (talk) 04:27, 31 October 2020 (UTC)

UPDATE: I figured it out. Changed columns "diet" and "descendants" to Wikitext instead of Wikitext String because they can sometimes be really really long. Disgustedorite (talk) 20:11, 1 November 2020 (UTC)

That's very strange. If you have access to the command line, I would recommend calling cargoRecreateData.php from the command line, and seeing if that or any other pages lead to any error messages. Yaron Koren (talk) 02:43, 2 November 2020 (UTC)

Return value of Parser::getTitle() must be an instance of Title, null returned

An error occurred after upgrading to 1.35.0(Cargo version 2.7)。

[a369925d034e2449e71bf18f] /index.php?title=2005%E5%B9%B46%E6%9C%88&action=pagevalues TypeError from line 1007 of /www/wwwroot/mediawiki/includes/parser/Parser.php: Return value of Parser::getTitle() must be an instance of Title, null returned

Backtrace:

#0 /www/wwwroot//extensions/Cargo/includes/CargoUtils.php(519): Parser->getTitle()
#1 /www/wwwroot/mediawiki/extensions/Cargo/includes/CargoQueryDisplayer.php(259): CargoUtils::smartParse(string, Parser)
#2 /www/wwwroot/mediawiki/extensions/Cargo/includes/CargoQueryDisplayer.php(133): CargoQueryDisplayer::formatFieldValue(string, string, CargoFieldDescription, NULL)
#3 /www/wwwroot/mediawiki/extensions/Cargo/includes/specials/CargoPageValues.php(159): CargoQueryDisplayer->getFormattedQueryResults(array)
#4 /www/wwwroot/mediawiki/extensions/Cargo/includes/specials/CargoPageValues.php(66): CargoPageValues->getRowsForPageInTable(string)
#5 /www/wwwroot/mediawiki/extensions/Cargo/includes/CargoPageValuesAction.php(27): CargoPageValues->execute()
#6 /www/wwwroot/mediawiki/includes/MediaWiki.php(527): CargoPageValuesAction->show()
#7 /www/wwwroot/mediawiki/includes/MediaWiki.php(313): MediaWiki->performAction(Article, Title)
#8 /www/wwwroot/mediawiki/includes/MediaWiki.php(940): MediaWiki->performRequest()
#9 /www/wwwroot/mediawiki/includes/MediaWiki.php(543): MediaWiki->main()
#10 /www/wwwroot/mediawiki/index.php(53): MediaWiki->run()
#11 /www/wwwroot/mediawiki/index.php(46): wfIndexMain()
#12 {main}
Sorry about that - it looks like the handling of Parser::getTitle() changed in MW 1.35. I just checked in to Cargo what I think is a fix for this. Yaron Koren (talk) 15:15, 2 November 2020 (UTC)
Thanks, the problem is solved after the update.

ANDed HOLDS statements do not produce expected result

On our Gamepedia wiki, this Cargo query fails to return the expected results. The same query but with OR does work as expected.

There is a workaround using __full with LIKE as documented on the Gamepedia Help wiki but I wanted raise the issue here in case it wasn't already.

Gamepedia is still on version 2.2 for the time being. Phantom Caleb (talk) 16:02, 8 November 2020 (UTC)

I logged phab:T267498. PhantomCaleb (talk) 20:09, 8 November 2020 (UTC)

Recreate does not add data to Cargo DB

The only way to get data in my Cargo DB is to edit and resave pages containing expressions like {{#cargo_store: _table=Topic |Auteur=Drebbel|About=Wondervondt|Location=Alkmaar|Language=Dutch|Year_of_publication=1607 }}

Using recreate in http://localhost/mediawiki/index.php/Special:CargoTables or corresponding php code have no result.

Cis:/var/www/html/mediawiki/extensions/Cargo/maintenance$ php cargoRecreateData.php Recreating data for Cargo table Topic in 5 seconds... hit [Ctrl]-C to escape. Deleting and recreating table... Handling template that adds to this table: Topic Saving data for pages 1 to 0 that call this template...


Product Version MediaWiki 1.35.0 PHP 7.4.12 (apache2handler) MySQL 5.7.32-0ubuntu0.18.04.1 ICU 65.1 Semantic MediaWiki 3.2.0 Cargo 2.7

Is that #cargo_store call in a template, or just in a standalone page? The "recreate" calls will only work if it's in a template that is in turn called by other pages. Yaron Koren (talk) 23:58, 8 November 2020 (UTC)

Understood. But then I have another (probably stupid) question: How do I transfer the values for the properties (Year, etc) in my standalone page to my Template «{ {Boek} }» ?
«[ [Year::1607| ]][ [Published in::Alkmaar| ]] [ [Language::Dutch| ] ]» into «{ {Boek} }»

You need to make your "book" pages (and maybe others as well) template-based - meaning that all data contained in those pages, like "1607", should be contained only within template calls. Yaron Koren (talk) 14:51, 9 November 2020 (UTC)

Works fine now. Many thanks. Love cargo!

That's great! Yaron Koren (talk) 22:29, 12 November 2020 (UTC)

DATEDIFF with interval parameter seems not to be possible (Incorrect parameter count in the call to native function 'DATEDIFF')

Hello everybody,

I am trying to use the DATEDIFF date function in a cargo query to get only datasets in a certain range of time. In my case, results should only be displayed, if the date of the corresponding cargo field is within the last 6 months from now.

I tried to add an interval parameter like "month" as it is possible in SQL.

It should look like this

DATEDIFF(month,date,NOW()) >= -6

But if I run the query with this where-condition, I only get the error message "Incorrect parameter count in the call to native function 'DATEDIFF'".

Does anybody know a workaround to get this running?

Kind regards, Axel --Shuitavsshente (talk) 11:28, 11 November 2020 (UTC)

It looks like you're just calling DATEDIFF() incorrectly - it only takes two arguments. Yaron Koren (talk) 15:07, 11 November 2020 (UTC)
thank you very much for your quickl response. and yes, you are right. I am not calling DATEDIFF correctly with this interval parameter. I just assumed that it works similiar to the SQL function. There DATEDIFF also returns the difference between two dates in years, months or some other parameter values. Would it be possible to integrate a third interval parameter, although I know, that there are more important features/fixes to add to cargo. --Shuitavsshente (talk) 06:11, 12 November 2020 (UTC)
When you see a function like DATEDIFF() within a #cargo_query call, that literally is the MySQL function being called - Cargo isn't processing it in any way. So if you want to change the DATEDIFF() parameters, you'll have to talk about it with the MySQL developers. Yaron Koren (talk) 14:49, 12 November 2020 (UTC)

Replacement table stuck, can't recreate

Hello,

I help maintain the Dauntless Wiki on Gamepedia, and we're having a weird issue with Cargo. Our "Perks" table had a duplicate entry (Molten), so I tried to recreate the data to fix it and Molten disappeared from the table entirely. Now, I can't even recreate the table; it says it's stuck making the replacement table, which I can't access. Not really sure what to do here.

Thanks, MaximumLeech (talk) 16:21, 11 November 2020 (UTC)

What do you mean by "stuck"? What does it actually say? Yaron Koren (talk) 16:28, 11 November 2020 (UTC)
The template page says "This template defines the table "Perks". Create data table A replacement table has been generated for this table; View replacement table." which I found odd. Clicking "Create data table" brings up a page that says "Cannot currently recreate the table "Perks"; the replacement table "Perks__NEXT" still exists. (View replacement table)". When I click the replacement table, it pulls up a white screen that says
"MediaWiki internal error.
Original exception: [6919be70323902e8] 2020-11-11 17:12:01: Fatal exception of type "MWException"
Exception caught inside exception handler.
Set $wgShowExceptionDetails = true; at the bottom of LocalSettings.php to show detailed debugging information." MaximumLeech (talk) 17:14, 11 November 2020 (UTC)
That's unfortunate. I think that's a bug that was fixed in May (i.e, version 2.6), but it may take a while before it reaches you. Until then, I think your best course of action might be to get an administrator to go into the database and delete the table "Perks__NEXT" (which is really "cargo__Perks__NEXT"). That, I think will take care of the problem. Yaron Koren (talk) 17:24, 11 November 2020 (UTC)

Removing extra Space from Delimiter parameter

When using the delimiter parameter, is there a way to avoid having the extra forced space inserted? For example, I'm needing the output to look like "Name1;Name2;Name3;Etc" instead of "Name1; Name2; Name3; Etc". Thank you, Ertosi November 12, 2020.

I think this is actually a Page Forms question, since I'm guessing that the problem is the output of the #arraymap parser function. Oddly, maybe there's no way to have #arraymap output a delimiter without a space, although there probably should be. It could be that the best way to do this is to wrap #replace around the #arraymap call, so it looks like "{{#replace:...#arraymap call here...|; <nowiki />|;}}". You'll also need the ParserFunctions extension installed to get this working. Yaron Koren (talk) 22:32, 12 November 2020 (UTC)

Using MIN on dates with varying precision

Whenever I use the MIN function on a date column, it always returns values lacking precision first. This might be sensible behaviour but in my case it looks like a bug. What's worse, it displays as e.g. 2020-01-01 when the value is actually just 2020 (precision 3). I tried hacking around it as with things like MIN(CASE WHEN shows.date__precision = 1 THEN shows.date ELSE '9999-99-99' END)=First date but I get Error: No field named "CASE WHEN shows.date__precision = 1 …" found for any of the specified database tables. Basically I need to query for the minimum date with precision 3, but without filtering out dates with other precision because I'm also doing an overall COUNT. Any ideas? MusikAnimal talk 05:50, 18 November 2020 (UTC)

I guess I can also provide an example. Here the "First date" by Pumpkins should be 1988-07-09, not 1988-01-01 (in fact no show took place on January 1). MusikAnimal talk 05:52, 18 November 2020 (UTC)
That's a pretty complex query you're trying to put together! The problem with complex queries is that it can be hard to get them past Cargo's rather strict validation, as you've seen. Your best bet might to create a Lua module to display this output, which would get all the dates and manually put together the table. It's a lot slower and less efficient, but it might be the only way to do it. Yaron Koren (talk) 19:08, 18 November 2020 (UTC)

TypeError from line 1007

On a cargo table, I receive the following error when pressing the More... text/link that automatically appears at the bottom of the table located on Special:CargoTables/Characters:

Versions: MW 1.35.0 PHP 7.4.12 (cgi-fcgi) MySQL 5.7.28-log ICU 57.1 Cargo: 2.7

[X7jJ80WjwbIAADt9YKAAAAAD] /index.php?title=Special:CargoQuery&tables=Characters&fields=_pageName%3DPage%2Ccodex%3Dcodex%2Cdtype%3Ddtype%2Cbase%3Dbase%2Csecond%3Dsecond%2Cthird%3Dthird%2Cstyle%3Dstyle%2Cdescription%3Ddescription%2Csection%3Dsection%2Ccollection%3Dcollection%2Ccost%3Dcost%2Cavailable%3Davailable%2Cmethod%3Dmethod%2Cadditional%3Dadditional%2Cdotw%3Ddotw%2Cdotm%3Ddotm%2Crotm%3Drotm%2Cbdgd%3Dbdgd%2Clb%3Dlb%2Ctoken%3Dtoken%2Cdungeon%3Ddungeon%2Cdupdate%3Ddupdate%2Chealth%3Dhealth%2Cattack%3Dattack%2Ccollecting%3Dcollecting%2Cccp%3Dccp%2Cgold%3Dgold%2Csell%3Dsell%2Climited%3Dlimited%2Cobtaining%3Dobtaining%2Cvipcollecting%3Dvipcollecting%2Chatching%3Dhatching%2Cviphatching%3Dviphatching%2Cxp%3Dxp%2Chealth2%3Dhealth2%2Chealth3%3Dhealth3%2Cattack2%3Dattack2%2Cattack3%3Dattack3%2Cdunlock%3Ddunlock%2Cspecial%3Dspecial%2Ctrophies%3Dtrophies%2Cleague%3Dleague%2Ccode%3Dcode%2Cfp%3Dfp%2Cdaily%3Ddaily%2Cmode%3Dmode%2Cq%3Dq%2Cdivision%3Ddivision%2Cvip%3Dvip%2Cden%3Dden%2Cs%3Ds%2Cparent1%3Dparent1%2Cs1%3Ds1%2Cparent2%3Dparent2%2Cs2%3Ds2%2Ccm%3Dcm%2Cpowers%3Dpowers%2Cpowers2%3Dpowers2%2Cregular%3Dregular%2Cquest%3Dquest%2Cprevious%3Dprevious%2Cnext%3Dnext%2Cunknown%3Dunknown%2Cswitch%3Dswitch&order_by%5B0%5D=%60_pageName%60&order_by%5B1%5D=%60codex%60&order_by%5B2%5D=%60dtype%60&order_by%5B3%5D=%60base%60&order_by%5B4%5D=%60second%60&offset=100&limit=100&max+display+chars=300 TypeError from line 1007 of /home/my-site/my-site.com/public/includes/parser/Parser.php: Return value of Parser::getTitle() must be an instance of Title, null returned

Backtrace:

#0 /home/my-site/my-site.com/public/extensions/Cargo/includes/CargoUtils.php(519): Parser->getTitle()
#1 /home/my-site/my-site.com/public/extensions/Cargo/includes/CargoQueryDisplayer.php(259): CargoUtils::smartParse(string, Parser)
#2 /home/my-site/my-site.com/public/extensions/Cargo/includes/CargoQueryDisplayer.php(170): CargoQueryDisplayer::formatFieldValue(string, string, CargoFieldDescription, NULL)
#3 /home/my-site/my-site.com/public/extensions/Cargo/includes/CargoQueryDisplayer.php(371): CargoQueryDisplayer->getFormattedQueryResults(array)
#4 /home/my-site/my-site.com/public/extensions/Cargo/includes/CargoQueryPage.php(181): CargoQueryDisplayer->displayQueryResults(CargoTableFormat, array)
#5 /home/my-site/my-site.com/public/includes/specialpage/QueryPage.php(736): CargoQueryPage->outputResults(OutputPage, SkinPivot, Wikimedia\Rdbms\DatabaseMysqli, Wikimedia\Rdbms\ResultWrapper, integer, integer)
#6 /home/my-site/my-site.com/public/extensions/Cargo/includes/specials/SpecialCargoQuery.php(35): QueryPage->execute(NULL)
#7 /home/my-site/my-site.com/public/includes/specialpage/SpecialPage.php(600): SpecialCargoQuery->execute(NULL)
#8 /home/my-site/my-site.com/public/includes/specialpage/SpecialPageFactory.php(635): SpecialPage->run(NULL)
#9 /home/my-site/my-site.com/public/includes/MediaWiki.php(307): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#10 /home/my-site/my-site.com/public/includes/MediaWiki.php(940): MediaWiki->performRequest()
#11 /home/my-site/my-site.com/public/includes/MediaWiki.php(543): MediaWiki->main()
#12 /home/my-site/my-site.com/public/index.php(53): MediaWiki->run()
#13 /home/my-site/my-site.com/public/index.php(46): wfIndexMain()
#14 {main}

I have already tried deleting and generating the cargo table again fresh and am not sure what else I can do at this point. There isn't a class or ID for that element in order to target it for hiding in CSS, or I'd just hide that link and create my own pagination... would also be nice of that link had a unique style for CSS targeting. Any idea why this error might be happening and how to remedy it? Thanks! TiltedCerebellum (talk) 08:36, 21 November 2020 (UTC)

Edit: 4330 - This and T235392 this might be related, sounds like they started making changes to getTitle() behavior in 1.34 and more changes were slated for 1.35, with little notice to extension builders (at least for 1.34)? TiltedCerebellum (talk) 18:01, 21 November 2020 (UTC)

Sorry about that - this is a MW 1.35-specific bug that was actually fixed a few weeks ago. That reminds me that I should release a new version of Cargo soon... Yaron Koren (talk) 17:31, 22 November 2020 (UTC)

Repeating rows in a table displaying more than one form

I have one form that I call a process and I have a second form that I call form. After the user creates a process and forms there will be one process to many forms.

I am trying to display these processes and forms in one table. I am using the Group by for the forms but now I have the process repeating across each form. Is there a way (maybe using another tool I am not familiar with?) that would stop the process column from repeating? Here is a screen capture of what I am talking about. Notice the Business Form Number is unique but the Business Process Number is repeated.

 


I found " |merge similar cells=yes " which seems to do the trick! Thank you for your awesome tool.

Cargo Tables Page with persistent note

I am using MediaWiki 1.35.0, Semantic MediaWiki3.2.1 and Cargo 2.7.

I noticed that String is deprecated in SMW so I have replaced them with page, text or enumeration.

I have a cargo query joining two tables and I can't get the query to work. No results found. I have the query working on MediaWiki 1.32.3, Semantic MediaWiki 3.1.0 and Cargo 2.7.)

I noticed that I am getting a persistent note on the Cargo tables page:

NOTE: One or more of these tables are currently being populated, via the job queue.

I deleted the tables and I still have this error. Not sure if this has anything to do with my query not working so I thought I would bring it to your attention. Any troubleshooting help would be greatly appreciated.

199.247.46.55

That's too bad. It might help to run MediaWiki's runJobs.php script, in the /maintenance directory, in order to clear the job queue. Yaron Koren (talk) 22:14, 29 November 2020 (UTC)
I did run that with no luck and the message is there whether or not there is a table created.
That's strange. I would just empty the "job" database table, then, if you have access to the DB and know how to do it. Yaron Koren (talk) 02:25, 30 November 2020 (UTC)

Blank Row in a cargo query

Here is my code:

{{#cargo_query: tables=Forms,Processes |join on=Processes.Process_Title=Forms.Form_Parent |fields=Processes._pageName=Process, Forms._pageName=Form |group by=Forms._pageName |format=table |merge similar cells=yes |limit=5000 }}

In my example: the Form_Title field will have 'many' to 'one' Process_Title. I am getting a blank row in my query. When I edit with form the Process Title and save the blank row goes away but then the next Process title in my list shows the blank row. I have been chasing this blank row through all my Process Titles and when I solve the last one it shows up again in the first one.

 

Are you still seeing this problem? Yaron Koren (talk) 04:06, 4 December 2020 (UTC)
I fixed this by replacing the templates that used #cargo_attach with its own #cargo_declare. Worked like a charm! Thanks again.

Missing result in query

I posted the same code above with a different question:

{{#cargo_query: tables=Forms,Processes |join on=Processes.Process_Title=Forms.Form_Parent |fields=Processes._pageName=Process, Forms._pageName=Form |group by=Forms._pageName |format=table |merge similar cells=yes |limit=5000 }}


The field Forms.Form_Parent can hold a "List (,) of Strings". When I do a query only the first item in the list of strings shows in my query. What am I do wrong that I can't get all the list items to show in the query?

Thank you!

The "join on" clause might need to be "Forms.Form_Parent HOLDS Processes.Process_Title" instead. Also, the "group by" parameter might be messing things up; I'm not sure. Yaron Koren (talk) 16:12, 3 December 2020 (UTC)
I removed the "group by" and replaced = with HOLDS and I get the following error. (please ignore the different field names. I simplified the names for your ease of reading.
A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: SELECT `cargo__Business_Processes`.`_pageName` AS `Process`,`cargo__Business_Forms`.`_pageName` AS `Form` FROM `cargo__Business_Processes` LEFT OUTER JOIN `cargo__Business_Forms` ON ((`cargo__Business_Processes`.`Business_Process_Title` HOLDS 
`cargo__Business_Forms`.`Business_Form_Parent`)) ORDER BY `cargo__Business_Processes`.`_pageName`,`cargo__Business_Forms`.`_pageName` LIMIT 5000 Function: CargoSQLQuery::run Error: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL 
server version for the right syntax to use near 'HOLDS `cargo__Business_Forms`.`Business_Form_Parent`)) ORDER BY `cargo__Busin' at line 1 (localhost)
Please note that, for the new "join on" value, you also need to reverse the two fields. Yaron Koren (talk) 16:32, 3 December 2020 (UTC)
Thank you. I switched it but still gives error.
A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: SELECT `cargo__Business_Processes`.`_pageName` AS `Process`,`cargo__Business_Forms`.`_pageName` AS `Form` FROM `cargo__Business_Forms` LEFT OUTER JOIN `cargo__Business_Processes` ON ((`cargo__Business_Forms`.`Business_Form_Parent` HOLDS 
`cargo__Business_Processes`.`Business_Process_Title`)) ORDER BY `cargo__Business_Processes`.`Business_Process_Title` LIMIT 5000 Function: CargoSQLQuery::run Error: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server 
version for the right syntax to use near 'HOLDS `cargo__Business_Processes`.`Business_Process_Title`)) ORDER BY `cargo_' at line 1 (localhost)
That's strange. Are you sure that the "Form_Parent" field is really defined as a list field? When you go to Special:CargoTables for that "Form" table, does it show up that way? Yaron Koren (talk) 18:32, 3 December 2020 (UTC)
I made it page, so your right, but here is why I guess I didn't use List of String. See error below. My new code is included
A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: SELECT `cargo__Business_Processes`.`_pageName` AS `Process`,`cargo__Business_Processes`.`Business_Process_Title` AS `Business Process`,`cargo__Business_Processes`.`Process_Owner` AS `Process Owner`,`cargo__Business_Processes`.`Business_Process_Upload` AS 
`Uploaded Process`,`cargo__Business_Forms`.`_pageName` AS `Form`,`cargo__Business_Forms`.`Business_Form_Title` AS `Form Title`,`SMEs__full` AS `Subject Matter Experts`,`cargo__Business_Forms`.`Business_Form_Upload` AS `Uploaded Form` FROM `cargo__Business_Processes` 
LEFT OUTER JOIN `cargo__Business_Forms` ON ((`cargo__Business_Processes`.`Business_Process_Title`=`cargo__Business_Forms`.`Business_Form_Parent`)) GROUP BY `cargo__Business_Forms`.`_pageName` ORDER BY 
`cargo__Business_Processes`.`_pageName`,`cargo__Business_Processes`.`Business_Process_Title`,`cargo__Business_Processes`.`Process_Owner`,`cargo__Business_Processes`.`Business_Process_Upload`,`cargo__Business_Forms`.`_pageName` LIMIT 5000 Function: CargoSQLQuery::run 
Error: 1054 Unknown column 'cargo__Business_Forms.Business_Form_Parent' in 'on clause' (localhost)
Well, Page vs. String shouldn't matter, but it definitely matters whether the field is a list or not. Could the issue be that the "Process_Title" field is also a list? Yaron Koren (talk) 19:30, 3 December 2020 (UTC)
Process_Title is defined as Page. The field calls _pageName in query.

Alright, it's good that it's not a list. Do you still have "Form_Parent HOLDS Process_Title" in your "join on", or could it be that it went back to being the other way around? Yaron Koren (talk) 20:01, 3 December 2020 (UTC)

Yes, I did change it. Here is the code and the error.
{{#cargo_query:
tables=Business_Forms,Business_Processes
|join on=Business_Forms.Business_Form_Parent HOLDS Business_Processes.Business_Process_Title
|fields=Business_Processes._pageName=Process,Business_Processes.Business_Process_Title=Business Process,Business_Processes.Process_Owner=Process Owner,Business_Processes.Business_Process_Upload=Uploaded Process,Business_Forms._pageName=Form,Business_Forms.Business_Form_Title=Form Title,Business_Forms.SMEs=Subject Matter Experts,Business_Forms.Business_Form_Upload=Uploaded Form
|format=table
|merge similar cells=yes
|limit=5000
}}
A database query error has occurred. Did you forget to run your application's database schema updater after upgrading?
Query: SELECT `cargo__Business_Processes`.`_pageName` AS `Process`,`cargo__Business_Processes`.`Business_Process_Title` AS `Business Process`,`cargo__Business_Processes`.`Process_Owner` AS `Process 
Owner`,`cargo__Business_Processes`.`Business_Process_Upload` AS `Uploaded Process`,`cargo__Business_Forms`.`_pageName` AS `Form`,`cargo__Business_Forms`.`Business_Form_Title` AS `Form Title`,`SMEs__full` 
AS `Subject Matter Experts`,`cargo__Business_Forms`.`Business_Form_Upload` AS `Uploaded Form` FROM `cargo__Business_Forms` LEFT OUTER JOIN `cargo__Business_Processes` ON 
((`cargo__Business_Forms`.`Business_Form_Parent` HOLDS `cargo__Business_Processes`.`Business_Process_Title`)) ORDER BY 
`cargo__Business_Processes`.`_pageName`,`cargo__Business_Processes`.`Business_Process_Title`,`cargo__Business_Processes`.`Process_Owner`,`cargo__Business_Processes`.`Business_Process_Upload`,`cargo__Busines s_Forms`.`_pageName` LIMIT 5000 Function: CargoSQLQuery::run Error: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 
'HOLDS `cargo__Business_Processes`.`Business_Process_Title`)) ORDER BY `cargo_' at line 1 (localhost)
I don't know why this is failing for you. (And I also don't know why HOLDS sometimes gets parsed and sometimes doesn't - maybe you're trying out different things.) But what I would recommend is switching to use the "real", instead of "virtual", field name for "Form_Parent". It's a little more syntax, but it's less error-prone. So I would set "tables" to "Business_Forms,Business_Forms__Business_Form_Parent,Business_Processes", and "join on" to "Business_Forms._ID=Business_Forms__Business_Form_Parent._rowID,Business_Forms__Business_Form_Parent._value=Business_Processes.Business_Process_Title". That will hopefully work better. Yaron Koren (talk) 22:48, 3 December 2020 (UTC)
No error now. Thanks. Unfortunately, the results are still only showing one business form when it should show 3.
Which column is this? And do you want it to show a different row for each value, or all the values in one row? Yaron Koren (talk) 01:23, 4 December 2020 (UTC)
The list sits in the Business_Form_Parent field. The Special:CargoTables shows the list in one row as a comma deliminated list (and the list is one large link which isn't correct). The list looks fine through the template. The template code is
{{#arraymap:{{{Business_Form_Parent|}}}|,|x|[[x]]}}

I got it to work through List (,) of String!! Now I get three rows. Thank you so much for walking me through this.
It's strange that you need to make that change in order to get it to work... it should have worked as a list of Page as well. It makes me think that there was something wrong with the declaration, and the field wasn't really a list before, or something like that. But anyway, the key thing is that it works! Yaron Koren (talk) 04:06, 4 December 2020 (UTC)
When I said it was page I meant "Page". I will try List (,) of Page now. Just Page gave me results I could use to demonstrate to my client (they didn't notice the missing rows). Once you had me switch the join statement it stopped working. Once I put list of string back in it worked. I find new stuff in this software every day. It is a lot of fun. Thanks!

Great, I'm happy to hear that. Hopefully you're finding things besides just bugs. :) Yaron Koren (talk) 18:13, 4 December 2020 (UTC)

During Table Declaration, any performance gains from reducing string size down from 300 characters?

When declaring a table, many of the Field Types have a default max size of 300 characters. If a given table has a large amount of these parameters (50+ strings in my case) but none need to be that long, would setting the Size of each to something smaller (say 20 characters, in my case) have any noticeable or significant impact on performance of Cargo queries to the table? Thanks! Ertosiangel (talk) 16:08, 5 December 2020 (UTC)

I don't know... that sounds like a MySQL performance question. (Or whatever the DB system you're using is.) Yaron Koren (talk) 13:45, 7 December 2020 (UTC)

Occasionally a page saves twice to cargo table. How to delete double entries?

From time to time, a new page will save itself twice to its associated cargo table, creating two identical lines in the table. So far, previous times this has happened resaving the page corrected the issue, but this time it's not working. Even deleting the page only removed 1 line from the cargo table, leaving the extra entry behind. Recreating the page brought the double line back instead of overwriting the one already present.

Is there a way to manually delete a single entry from the cargo table without having to recreate the entire table?Ertosiangel (talk) 01:05, 7 December 2020 (UTC)

From what you're describing, it sounds like there's something badly set in that row - maybe it has the wrong _pageID value or something. The only thing I can think of to fix it - other than recreating the table - is to go manually into the database and delete that one row. Yaron Koren (talk) 13:46, 7 December 2020 (UTC)

Cargo with VisualEditor?

When I use VisualEditor to edit any page with Cargo query, that part of content will be displayed as if it put in a nowiki tag. Is this a bug? If it's bug of VisualEditor, is there any way to fix this? Thanks you! 240E:3A1:644:8BE6:61CB:5A18:5815:C30E 14:37, 20 December 2020 (UTC)

Order by Floats gives out of order results

I'm having trouble when using Floats in the Order By section. Rather than reading as numbers, the results look like they are being compared as strings. Specifically it looks like they are being ordered digit by digit starting on the left side. This means something as simple as "order by = Weight" provides weird results something like 98.1 9.7 96.4 955.1 94.2. What's the best method of correcting this? Thanks!

What is the exact type specified for that field ("Weight" or whatever it is) in the #cargo_declare call? Yaron Koren (talk) 04:21, 30 December 2020 (UTC)
Weight = Float
I just tried this, and I can't replicate this error - for me, "Float" values get ordered correctly. My only guess is that there is some tiny error in either the declaration or the query, causing something incorrect to happen. Yaron Koren (talk) 15:33, 31 December 2020 (UTC)
Did your test include values of different lengths? The problem is invisible if all of the values are the same length with decimals in the same position. I ask because I've run into this same issue on multiple wikis.
It did, yes. If possible, could you go into the database itself and see if the actual DB table for that Cargo table has the correct type for that field? Yaron Koren (talk) 14:36, 4 January 2021 (UTC)

Rendering HTML output of Cargo queries

When querying against Cargo tables, is there some way to have the output render as HTML rather than as plain text? I ask because we query against some stored template data to provide event lists, but that event data has schema.org markup on it. As a result, it can look a little silly; see https://segaretro.org/Amusement_Machine_Show and https://segaretro.org/Japan_Amusement_Expo for examples. - Scarred Sun (talk) 22:10, 30 December 2020 (UTC)

Yes, I can see the problem right in the "events" table. There's a lot of formatting there. I don't know if there's any way to un-escape the HTML. What I would recommend instead is to turn the "location" field into three or four fields: venue, city/state (maybe that should be two), and country. That way, you can have the template itself add the relevant schema.org tags, instead of having to enter them by hand every time. That should simplify both data storage and data entry. I should add that it may also make sense to have the "venue" field be of type "Page" (and displayed as a link), so that extra information about the venue - like the Wikipedia link - can just show up on the venue's page, and doesn't have to be stored on each event page. It looks like you already have a "venues" table, so this might be pretty easy to accomplish. Yaron Koren (talk) 16:13, 31 December 2020 (UTC)
Return to "Cargo/Archive August to December 2020" page.