Latest comment: 9 months ago2 comments2 people in discussion
Hello All,
I have been using Semantic MediaWiki for a number of years, but it can't seem to perform a requirement I have so thought I'd try Cargo (after seeking adice from GitHub's copilot), but I am still running into an issue.
What I'm trying to achieve is to create an asset management tool, I have a form that populates the component of an asset, there will be multiple components that will make up an asset. What I want it to do is manage the configuration management, when a component is updated the person doing the maintenance will update the component to state the modifcation has taken place. This could also be used for maintenance of systems as well.
When the maintainer updates the component this would automatically pull through to the overall asset that details which is the current modification status and when the next modification date is set.
I have three templates that make up the component:
<noinclude>
{{#cargo_declare:_table=AssetDetail
|Asset=Page
|License=Wikitext
}}
</noinclude>
{{#cargo_store:_table=AssetDetail
|Asset={{{Asset|No asset set}}}
|License=[{{{License link|https://domain/waas/index.php?title=No_license_link_provided}}} {{{License|No license text set}}}]
}}
[[Category:Asset components]]
[[Category:{{{Asset|No asset set}}}]]
{{#default_form:Component management}}
This page was last updated on [[Last updated::{{REVISIONDAY}}/{{REVISIONMONTH}}/{{REVISIONYEAR}}]] by [[Last edited by::{{REVISIONUSER}}]].
This component is for the '''[[Admin:{{{Asset|No asset set}}}|{{{Asset|No asset set}}}]]''' asset.<br>
'''License:'''<br>
[{{{License link|https://domain/waas/index.php?title=No_license_link_provided}}} {{{License|No license text set}}}] <br>
'''Description:'''<br>
{{{Component description|No description set}}}
{| class="wikitable"
! Component
! Current version
! Next version
! Component last updated
! Component next update scheduled
! Is this the current install version?
! Is this the next version?
|-
The form is Form:Component management, should note, the form field isn't showing at the moment. There are other issues with I am working with the supplier with.
The second part of this is the asset managment, the Template:Asset management has the following code:
<noinclude>
{{#cargo_declare:_table=AssetInfo
|Asset=Text
|AssetDescription=Text
|LastUpdated=Date
|LastEditedBy=Text
}}
</noinclude>
{{#cargo_store:_table=AssetInfo
|Asset={{PAGENAME}}
|AssetDescription={{{Asset description|Asset description not set.}}}
|LastUpdated={{REVISIONDAY}}/{{REVISIONMONTH}}/{{REVISIONYEAR}}
|LastEditedBy={{REVISIONUSER}}
}}
This page was last updated on [[Last updated::{{REVISIONDAY}}/{{REVISIONMONTH}}/{{REVISIONYEAR}}]] by [[Last edited by::{{REVISIONUSER}}]].
'''Asset:''' [[Asset::{{{Asset|No asset set}}}]]
==Asset description==
{{{Asset description|Asset description not set.}}}
==Asset components==
===Current version===
{{#cargo_query:
tables=ComponentInfo=CI, AssetDetail=AD
|join on=CI.LatestVersion=AD.Asset
|fields=CI.Component, CI.CurrentVersion, CI.LatestVersion, CI.ComponentLastUpdated, CI.ComponentNextUpdateScheduled, AD.License
|where=AD.Asset="{{PAGENAME}}" AND CI.LatestVersion="Yes"
|format=wikitable
|order by=CI.ComponentLastUpdated
|limit=100
}}
===Next version===
{{#cargo_query:
tables=ComponentInfo=CI, AssetDetail=AD
|join on=CI.LatestVersion=AD.Asset
|fields=CI.Component, CI.CurrentVersion, CI.NextVersion, CI.ComponentLastUpdated, CI.ComponentNextUpdateScheduled, AD.License
|where=AD.Asset="{{PAGENAME}}" AND CI.NextVersion="Yes" <> "Template:Component information body"
|format=wikitable
|order by=CI.ComponentNextUpdateScheduled
|limit=100
}}
[[Category:Asset management]]
[[Category:{{PAGENAME}}]]
{{#default_form:Asset management}}
[[Category:Asset management]]
[[Category:{{PAGENAME}}]]
{{#default_form:Asset management}}
But rather than showing me the row that has been delcared as being the current version it shows me the toprow which isn't the current version. Is what I'm trying to achieve possible? If it is possible, have you any pointers as to what I'm doing wrong? Squeak24 (talk) 08:45, 2 April 2025 (UTC)Reply
I'm glad Copilot recommended Cargo! For the question - are you talking about the query that includes the fields "CI.CurrentVersion, CI.LatestVersion"? If so, isn't it showing both?
As a side note, the part of the form that says "Please note this form does not work with Internet Exporer" looks strange - no one uses IE any more. (I would have guessed that this was AI-generated, but AI probably wouldn't make that spelling mistake - maybe it's a copy/paste from an old form.) Yaron Koren (talk) 14:11, 2 April 2025 (UTC)Reply
Sorry, I'm not sure I understand either question. What do _pageData and Items have to do with it? What exactly is being duplicated? And what do you mean by "update existing orders"? (You can obviously update data by editing any page containing data.) Yaron Koren (talk) 04:39, 6 April 2025 (UTC)Reply
here are the duplicate tables neverwinter.fandom.com/ru/wiki/Набор эпических ошейников на выбор?action=pagevalues pagevalues and this is a template neverwinter.fandom.com/ru/wiki/Template:Содержит
I think the problem is that I call the template 15 times together with cargo_store, fandom updated the wiki to 1.43, and now this template does not work as before.
Previously, it saved to the Contains table only 1 time
Okay, now I understand - you were describing the text at this URL. It sounds like there's a duplicate row in either the cargo_tables or the cargo_pages DB table - probably cargo_pages, since it doesn't seem to happen for every page that has a row in the table. If/when this happens, I assume just recreating the table would make the problem go away... have you tried that? Yaron Koren (talk) 17:18, 6 April 2025 (UTC)Reply
There are no duplicates on the other pages because I haven't updated them yet. If I make a null edit there, the duplicates will appear too.
I created a new template and a new table, but there are still duplicates on the PageValues page, even though there are no duplicates in the actual table — everything displays correctly there. These duplicates don't affect the functionality — items on the pages display correctly without any duplicates.
Latest comment: 8 months ago3 comments2 people in discussion
Hi,
currently encountered a strange behavior or problem while using Cargo Query. On any table I tried filter with the where clause like table.field='String' (of course with existing tables and fields and strings) I get with the first query perfect results although the query string escapes the = like &where=table.field%3D'String'& and in wikitext |where=table.field='String'. Same in fields (escapes = and ,) &fields=table._pageName%3DName%2Ctable.field%2Ctable.fieldb%2C.
If I go for the next or previous the query still works but it already altered and escapes the ' like &where=table.field%3D%26%23039%3BString%26%23039%3B& or in the wikitext output |where=table.field=&# 039;String&# 039; (need to add a space by hand &# 039;).
And of course going one more back or forth breaks with Error in "where" parameter: the string "#" cannot be used within #cargo_query. because the # that escaped in is causing a problem. If I alter the where statement by hand back to 'String' it works of course again.
Currently on MediaWiki 1.43.1 (e3c2412) and Cargo 3.8 (b6cc262).
Sorry about the problem, and thanks for reporting it! This bug had apparently been there for about six months. I just checked in what I think is a fix for it, here. Yaron Koren (talk) 23:22, 29 April 2025 (UTC)Reply
Latest comment: 8 months ago2 comments2 people in discussion
Hi there, I'm just starting out with Cargo for the first time. I'm thinking of writing an extension that uses Cargo. Basically my use case is this: some files on my wiki have some Cargo data associated with it. I want to write an extension with a special page that takes a file as argument, and the page then displays the custom data in a specific way (and does some data wrangling, constructs custom HTML based on the data, and so on). I've figured out, at the very least, that I can do custom queries this way:
$cdb = CargoUtils::getDB();
$res = $cdb->select(
'my_table',
['my_data'],
['file' => $filename],
);
if ($row = $res->fetchRow()) {
var_dump($row); // my_data and so on
}
What I'm wondering is, is this the proper way to do it, and is there some documentation for it? I'm pretty new to making MediaWiki extensions as well as to Cargo so any thoughts from someone with experience would be appreciated. If anyone knows extensions others have made that do this, I'd like to know about it so I can look at their code. Thanks! Dada78641 (talk) 15:40, 5 May 2025 (UTC)Reply
I don't think there's any documentation for running Cargo queries from PHP - and I don't know of any other extensions that use Cargo data - but that does look like the right way to do it. I hope you can get it working! Yaron Koren (talk) 20:07, 5 May 2025 (UTC)Reply
Where does the pagination section of the table need to be able to be translated into other languages?
Latest comment: 7 months ago2 comments2 people in discussion
I want to know where the paginated section of the footer of the table for the query needs to be able to be translated into other languages.
If not, is there any alternative way to translate into other languages, thank you.
Showing 1 to 5 of 45 entries
Previous12345…9Next公子猫 (talk) 17:22, 8 May 2025 (UTC)Reply
I assume you're talking about the "dynamic table" format. That one uses the DataTables JavaScript library, which by default is English-only. There are i18n plugins you can add (basically, a JSON file for each language) to provide language support - I think no one has asked about adding non-English support until now. (The true MediaWiki solution would be to do it through MW's own i18n messages, but that is a lot more work.) It does make sense to add some of these. Yaron Koren (talk) 17:11, 9 May 2025 (UTC)Reply
Latest comment: 7 months ago1 comment1 person in discussion
I got this when running MW's update.php today. I guess it's not a problem, as Cargo works all right, but I thought I'd ask here just in case. Thanks. Jonathan3 (talk) 10:34, 25 May 2025 (UTC)Reply
Latest comment: 6 months ago4 comments2 people in discussion
I have a table with a column of type list of pages. Some queries against that table provide the expected results, some no results. One difference seems to be that the pages that are not successfully compared with "HOLDS" use Help:Magic_words#DISPLAYTITLE. I made a demo page of he problem. Tenbergen (talk) 21:03, 6 June 2025 (UTC)Reply
We had this issue and it turned out that some magic words are needlessly HTML encoded like the {{PAGENAME}} you have in your non-working Previous_Location field example. Wrapping these in {{#titleparts:{{PAGENAME}}}} fixed the issue in the HOLDS field for us (we run the latest Cargo version and 1.43.1). Hope that helps! FrozenPlum (talk) 17:21, 18 June 2025 (UTC)Reply
Also, some blank results for us came from ' used in titles, which were fixed by changing the Cargo query to use " double quotes, or {{#replace:{{#titleparts:{{PAGENAME}}}}|'|\’}} which also surprisingly worked! FrozenPlum (talk) 17:25, 18 June 2025 (UTC)Reply
Seems your last example is not working because there are no spaces after "Previous Location" in the templates shown in the working version (spaces only appear in the page text itself, which is not stored by the template). The alternative to fix that one, perhaps, is to either remove the space (Cargo takes these literally), or to join on the _pageData table if you want to search the _fullText field (i.e., full text of the page and not just the template values)? FrozenPlum (talk) 17:37, 18 June 2025 (UTC)Reply
Summing the values of a column via SUM() - Resolved
Latest comment: 7 months ago1 comment1 person in discussion
This started as a question (I felt dumb for not getting SUM(fieldname) to work in Cargo to give a column total). Now I resolved it, hopefully this is a time-saver PSA for others.
Putting |fields = SUM(gmax)=total didn't give me a column total gmax rather it just listed every gmax value, as a comma-separated list, and no combination of grouping seemed work either??? (I'm probably missing something obvious, if so please do educate me)!
My query, and its nested |intro= query, to give the gmax column total above the table:
{{#cargo_query: table = Battles
|fields = m=Mine, b=Battle, gph=Gold Per Hour, gmax=Maximum
|where = _pageNamespace="0" AND gmax IS NOT NULL
|group by = _ID
|order by = m ASC
|format = table
|limit = 100
|intro = The Gold capacity of all mines is: {{#expr:{{#cargo_query: table = Battles
|fields = TRIM(gmax) <!-- needed, removes commas from number values -->
|where = _pageNamespace="0" AND m IS NOT NULL AND gmax IS NOT NULL
|group by = _ID <!-- to eliminate duplicates -->
|format = list
|delimiter = + <!-- turns the comma-separated into + separated -->
|template = CargoSum
|limit=100
|no html
}}}}
}}
The values output by the |intro= subquery, thanks to the + delimiter setting:
What I'm wondering is if there is a way that we could put the data storing template and the display on the same page, but not display the data storing template. Is there any kind of tag that I could use to not display the data storing template, that would still allow the data to be in the table?
I'm not sure I understand the question, but Cargo storage is done separately from display of data - so if all a template contains is #cargo_declare and #cargo_store calls, nothing will be displayed. Yaron Koren (talk) 05:23, 2 July 2025 (UTC)Reply
So the way we are doing it (which might be completely wrong) is we have a very basic template that adds data to the CardData table. Then on the articles where we actually want the data to display we have a collection of Lua modules that basically styles around a query to the CardData table.
So the CardData page (the raw data) looks like just a very basic wiki table. This works great because it's easy to add or edit the data:
But, that doesn't look very nice to the end users, so we have another page entirely that calls to a lua module and makes things just look nicer (and adds some additional queries from other tables):
What I'm wondering is if there is a way that we could put the two things on the same page, but only display the second prettier one. (Hopefully that makes more sense) Blinkingline (talk) 16:37, 2 July 2025 (UTC)Reply
It sounds like you want the template that holds the data to sometimes display the data (as a simple table), and sometimes not. Is that it? If so, you could always add another parameter to the template, like "display=", and then use #if or #ifeq within the template to display or not display, based on that parameter. Yaron Koren (talk) 16:45, 2 July 2025 (UTC)Reply
Latest comment: 5 months ago7 comments2 people in discussion
Hi,
I have question regarding the recurring event capability on the Cargo extension. Suppose I have a weekly meeting occurring at 07:00 until 08:00 and I would like to make a form (e.g., via PageForm) so that the user can generate the recurring events easily.
Yes, it works with the Datetime type (I'm pretty sure). You would need to have a template parameter for each parameter of #recurring_event that you want to populate (which may be all of them), and then a form field for each of those template parameters. Does that answer your question? Yaron Koren (talk) 13:48, 7 July 2025 (UTC)Reply
Hi Yaron, thanks for the reply.
I am newbie to MediaWiki and I have been stuck for a couple of weeks applying the recurrent event feature for my wiki calendar.
So just give you another information after your reply, this is the template that I have:
How interesting - that's actually a PHP issue, where your PHP installation doesn't have the "calendar" library where that function is defined. I didn't realize that could happen. Is it possible for you to get that library added? Yaron Koren (talk) 19:55, 7 July 2025 (UTC)Reply
I see, thanks for the answer.
Alright, I'll contact the sysadmin for the installation.
Hi @Yaron Koren, finally the calendar module is enabled and script above work perfectly. Now as an example I generated an instance of "Weekly test", and it has now list of Start_Time and list End_Time as Datetime.
The question is how can i handle the query of this list of a field? I have been thinking to use #cargo_compound_query, but not quite sure though. Any workaround that I can follow? ~2025-126455 (talk) 12:08, 17 July 2025 (UTC)Reply
It's great that you got the storage working! Unfortunately, the handling of #recurring_event is not quite as sophisticated as what you need - there is no way to set both a start and end date/time for each instance of the event, as you've discovered. It's possible to set separate lists of start and end dates, as you've done, but I don't believe there's a way to combine the two. To actually have a separate start and end value for each event instance, I believe you'd need to use a separate, multiple-instance template (that's sort of a Page Forms concept), and enter all the data in manually, rather than using #recurring_event. The alternative, I think, is to only store start times, and just state somewhere on the wiki that meetings run for one hour. Yaron Koren (talk) 15:05, 17 July 2025 (UTC)Reply
Latest comment: 4 months ago2 comments2 people in discussion
The infobox links to a page on discoursedb.org, which requires viewers to log in to view pages. Additionally, the page to make an account on that site is broken, so new users cannot view the example. Could we put another example in the infobox that is publicly viewable? I admin a small wiki which uses Cargo, but I don't know if I can put a link to my wiki here due to CoI. 183231bcb (talk) 19:37, 8 August 2025 (UTC)Reply
Sorry about that problem - discoursedb.org was temporarily shut down to deal with an AI bot deluge. It's fully viewable again now, as of about a week ago. Yaron Koren (talk) 18:04, 18 August 2025 (UTC)Reply
Latest comment: 4 months ago5 comments2 people in discussion
Error in "where" parameter: the string "--" cannot be used within #cargo_query.
My wiki has a table with YouTube video id as key, which causes problems with some rows. If possible, I would like to stick with entering YouTube IDs for end users. However, if this is an unavoidable limitation, I will have to find another method. Are there any other options? Indeedfore (talk) 11:17, 18 August 2025 (UTC)Reply
Do you mean that each user's YouTube ID is their page name, and those YouTube IDs sometimes contain "--", and in order to display a user's videos you need to do a query like where=_pageName={{PAGENAME}}, which fails? If all of those are true, you could do something like where=_pageID={{PAGEID}} instead. Yaron Koren (talk) 18:09, 18 August 2025 (UTC)Reply
No. A row in the videos table can be included multiple times on a single page, and the template variable queries the ID of the video designated as the representative video in the infobox. Indeedfore (talk) 18:30, 18 August 2025 (UTC)Reply
Alright, I think I get it. This is a hack, and I apologize for making you do the extra work, but it might work: replace dashes with a character that won't show up in the ID, then replace them back in the SQL. An example might be where=YouTube_ID=REPLACE('{{#replace:{{Main YouTube ID}}|-|+}}', '+', '-'). I haven't tried this, but hopefully it works! You might need to add 'REPLACE' to $wgCargoAllowedSQLFunctions. Yaron Koren (talk) 20:07, 18 August 2025 (UTC)Reply
Latest comment: 4 months ago1 comment1 person in discussion
The grey/white diagonal "busy" effect happens for less than a second, but no autocomplete values display. Any ideas how to fix? It works all right on a different wiki in a normal (not _parentTables) field. Thanks. Jonathan3 (talk) 22:38, 30 August 2025 (UTC)Reply
It's not recommended, because generally there have been fixes to work with each MW version that were done too late to end up in the corresponding Cargo branch, and were never back-ported - probably the documentation should explicitly say that. Yaron Koren (talk) 13:51, 15 September 2025 (UTC)Reply
Latest comment: 3 months ago1 comment1 person in discussion
I've tried to narrow down the scope of this reproducible issue, but this is just too strange.
Only with specific combinations of field names and types in _parentTables does the following error occur when visiting the child table page via Drilldown:
Error 1054: Unknown column 'aabbcc.fieldInt' in 'SELECT'
Function: CargoFilter::getAllValues
Query: SELECT `aabbcc`.`fieldInt` AS value,COUNT(DISTINCT `childTable_alias`.`_pageID`) AS total FROM `cargo__childTable` `childTable_alias` GROUP BY `aabbcc`
'aabbcc' is not a table name but a field name in the child table where _parentTables is declared. What is happening there? Additionally, the casing has been changed to lowercase, differing from the original.
The combination found is as follows:
The presence of (hidden) in _remoteField
The name of _remoteField contains the string ‘ID’
An additional Integer field exists in parent table
In other words, the error does not occur if even one of these three conditions is not met.
Latest comment: 3 months ago2 comments1 person in discussion
The problem is that the white/grey even/odd colouring seems to be worked out per column rather than per row, which usually leaves the whole thing looking wrong. One solution would be to re-start the colouring for each row, though I've not checked to see whether that would still look bad. The other would be to remove the grey colour. What options do I have? Thanks. Jonathan3 (talk) 09:17, 7 October 2025 (UTC)Reply
Latest comment: 2 months ago6 comments2 people in discussion
Hello,
I have the following error message running a #cargo_query
Error 1054: Unknown column 'cargo__Outcomes._pageID' in 'SELECT'
Function: CargoSQLQuery::run Query: SELECT `cargo__Outcomes`.`_pageID` AS `cargo_backlink_page_id_Outcomes`,`OUReference` AS `OUReference`,`OUDescription` AS `OUDescription`,`OUSRReference` AS `OUSRReference` FROM `cargo__Outcomes` `Outcomes` ORDER BY `cargo__Outcomes`.`_pageID`,`OUReference`,`OUDescription`,`OUSRReference` LIMIT 100
Installed software :
MariaDB 11.4.5
PHP 8.4.5
MediaWiki 1.43.3
BlueSpice 5.1.1
Cargo 3.7
PageForms 5.9.
I am logged as a sysop with recreatecargodata, deletecargodata and runcargoqueries permissions.
Okay, now I think I understand (though I still don't know how "sfr=w" got in there). The first thing I would suggest is to upgrade to the latest version of Cargo - it could be that whatever issues you're seeing have been fixed already. Yaron Koren (talk) 14:09, 10 October 2025 (UTC)Reply
English speakers usually call that a "table", not an "array". The word "array" brings to mind things like data structures in programming languages. Hence the confusion. - dcljr (talk) 10:15, 25 October 2025 (UTC)Reply
Oh, okay. If you're asking about those DB settings, the first four are mandatory, so they don't have a default value. The last one, $wgCargoDBfilePath, also doesn't have a default value, but it too is actually mandatory, if you are using SQLite. So it's not quite correct to call it optional, but maybe there is no ideal description. Yaron Koren (talk) 22:52, 27 October 2025 (UTC)Reply
Cargo and Approved Revs
Latest comment: 2 months ago6 comments3 people in discussion
(moved here from talk /fr pending form 6 years)
Cargo does not used the approved revision to store data
Médiawiki 1.33.0 Cargo 2.2 Approved Revs 1.1
When I approve a source page it disappears from the table
Please use your own signature here, instead of the one from 2019. Are you seeing these two problems? And if so, what versions are you using of MW, Cargo and AR? Yaron Koren (talk) 23:01, 27 October 2025 (UTC)Reply
I guess you're asking whether they are still seeing these problems, and what versions they are currently using. Given User:Levreauj's contributions (including globally), I think it's very unlikely they will be replying here. (But I have pinged them in this message, anyway. The way the comment was posted here, they will not have gotten a ping before now.) - dcljr (talk) 21:40, 29 October 2025 (UTC)Reply
Yes, but what I mean is, the original poster already gave the versions of MW, Cargo, and AR they were using. So why are you asking for them again? I can guarantee you, Wladek92 is not reporting a problem. He simply moved the other user's comment to here because it had gone unnoticed in its original location. - dcljr (talk) 07:34, 31 October 2025 (UTC)Reply
I've just noticed that when you select one filter two new ones appear - Other and None. Selecting any filter with "Other" I think will have the same effect as I had hoped for.
However, I'm not sure what choosing a filter "or None" does in these circumstances. I think that should only be possible when there are some fields without values, but it always appears. Jonathan3 (talk) 10:06, 29 October 2025 (UTC)Reply
Cargo store and {{REVISIONUSER}}
Latest comment: 1 month ago1 comment1 person in discussion
Hello Everyone.
I am trying to store the user creating a page using a Cargo template - PageForms form, by using {{REVISIONUSER}}.
I am able to get and display the value of {{REVISIONUSER}} in the template, and even pass it to the form, but when I try to pass it to {#cargo_store}}, the value passed by cargo_store to the table, either is blank or literal, depending how it is passed.
Thank you in advance, I need to pass the actual user creating the page (which is displayed in the template and in the form) to the Cargo Table. It is hours of trying and still cannot figure out how to do it.
{"error":{"code":"db_error","info":"A database query error has occurred. This may indicate a bug in the software.","docref":"See https://rs.miraheze.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."},"servedby":"mw183"}
I guess it was caused by the _pageName, which starts with an underscore _? When I use other fields for JOIN_ON there was no problem. ZMY (A-TC-G) 10:01, 12 December 2025 (UTC)Reply
Latest comment: 16 days ago2 comments2 people in discussion
I've had this for years across different wikis. For some reason, the storage of categories in _pageData._categories is unreliable. Either it (rightly) contains ALL categories or (sometimes wrongly) NO categories, and I can't work out why. Is there some way to ensure it works right? Thanks. Jonathan3 (talk) 15:06, 18 December 2025 (UTC)Reply
The storage of categories is different from the storage of all other values in the _pageData table, in that it relies on hooks rather than being done immediately on page save. I don't know how to make it more reliable, though. Yaron Koren (talk) 17:38, 22 December 2025 (UTC)Reply