Jump to content

Extension talk:Cargo/Archive January to April 2023

From mediawiki.org
Latest comment: 1 year ago by SovereignGFC in topic 500 Row Limit (Not Just Display)

Pins on Openlayers map not clickable on mobile

I can't get the pins on Openlayers maps to be clickable on mobile (or whatever the word is - touchable?). The same query with Google maps works all right. Jonathan3 (talk) 13:23, 9 January 2023 (UTC)Reply

Any ideas? :-) Jonathan3 (talk) 22:42, 27 January 2023 (UTC)Reply

Stripmarkers displayed in query output when using Template Styles Extension on wikitext field

We frequently use templates to inject additional information or styling into wikitext, some of which gets stored in the Cargo tables. When the styling is handled by Common.css, all behavior is normal. If the CSS is moved such that it's managed by the TemplateStyles extension, then the Cargo Query will begin to display Strip Markers in the output. How can this be resolved without moving styling back into Common.css?


I attempted to add a link to an example of this error, but Mediawiki would not allow me. 67.191.180.153 18:47, 10 January 2023 (UTC)Reply

Do you mean that this error can be seen on a public wiki? If so, could you put the URL here without the "http" part? Yaron Koren (talk) 03:57, 11 January 2023 (UTC)Reply
I set up a demo of the error here. The page is a query which displays a wikitext summary. Cargo behaved as intended in the past, but after introducing TemplateStyles, cargo now displays the stripmarkers for the wikitext fileds' template calls. www.dustloop.com/w/User:PrivateTarkus/sandbox 67.191.180.153 05:51, 12 January 2023 (UTC)Reply
As a temporary solution, I've disabled Templatestyles for templates which frequently appear within Cargo fields. As expected, this workaround does resolve the issue for now. It seems to be a problem of cross-compatability between Templatestyles and Cargo, @Yaron Koren. 67.191.180.153 14:05, 16 January 2023 (UTC)Reply

Sort from largest to smallest

Hello, how can I sort the rows in the table so that the table starts from 10 to 1, and not 1 to 10. I use Lua. -- Oleksii 212.80.47.83 07:47, 18 January 2023 (UTC)Reply

Just add " DESC" at the end of the "order by" value. Yaron Koren (talk) 19:02, 18 January 2023 (UTC)Reply

Compound Query ordering

Cargo 3.3.1

MW 1.39.0


Is it possible to set the Order by so that it affects all the queries in a compound query?


Example query

{{#cargo_compound_query:
tables=Publication, Book
;fields=Book.Title = Book Title, Book.BookType = Type, DATE_FORMAT(MIN(Publication.PublicationDate), "%M %Y")= Publication Date, Book.System = System, Book.Series = Series
;where=Publication.PubAuthors HOLDS '{{{Author}}}'
;join on=Book.Title=Publication.Title
;group by=Book._pageID
;order by=MIN(Publication.PublicationDate)|tables=PublicationBook, Publication, Book, Publication=DatePub
;fields=Book.Title = Book Title, Book.BookType = Type, DATE_FORMAT(MIN(DatePub.PublicationDate), "%M %Y")= Publication Date, Book.System = System, Book.Series = Series
;where=PublicationBook.AuthorsContent HOLDS '{{{Author}}}' and ISNULL(Publication.Title) = 1
;join on=PublicationBook.TitleContent=Publication.Title, PublicationBook.TitleContent=Book.Title, PublicationBook._pageName=DatePub._pageName
;order by=MIN(DatePub.PublicationDate)|format=template|template=Artists}}

This has two queries, but the results are displayed in order for each individual query. Temujen510 (talk) 20:12, 21 January 2023 (UTC)Reply

Unfortunately, no. Yaron Koren (talk) 01:22, 23 January 2023 (UTC)Reply

Page references in columns not updated after moving page

What is the expected behavior for a Page data type in a Cargo column? I had expected that when I move a page, all references to that page in Cargo table columns would then be updated, but that doesn't appear to be happening. What is the best approach to keeping two tables, one of which references the other's page name, in sync after page moves? Nicholasalanbrown (talk) 02:08, 5 February 2023 (UTC)Reply

No, what's in Cargo just reflects what's in the wikitext (well, usually). You can do something like joining on the _pageData table and using its _pageNameOrRedirect field, but I would recommend just using the Replace Text extension. Yaron Koren (talk) 03:27, 6 February 2023 (UTC)Reply

Hide "Go to date" part of calendar

This part of the calendar doesn't look well when the screen is narrow. What is the best way to hide it? I see that one of the calendars linked to on the documentation page is https://icannwiki.org/IG_Hub/Calendar and it does not have the "Go to date" part. Thanks. Jonathan3 (talk) 08:25, 14 February 2023 (UTC)Reply

I'd still be interested in a parameter to remove this. It only appears on recent Cargo versiosn (e.g. on https://discoursedb.org/wiki/Opinion_calendar but not on https://icannwiki.org/IG_Hub/Calendar). I've managed to hide it with CSS, but the lack of id's makes it imperfect:
.fc-left p {
  display: none;
}

.fc-left .oo-ui-widget {
  display: none;
}

I am trying to put a link to a pre-filtered drilldown on a wiki page. The link looks fine when I hover over it, but I actually click on it the "&" and other special characters get changed. For example, instead of what it should be and is in the hover over Special:Drilldown/Person&Section=Allergy it becomes Special:Drilldown/Person%26Section%3DAllergy, and when I click on it I get an error Error: Table Person&Section=Allergy_and_Clinical_Immunology&AppointmentType=GFT not found. How would I build a link to a drilldown in a wiki page? Tenbergen (talk) 16:10, 15 February 2023 (UTC)Reply

Right - the only solution I can think of is to make an external link (with the full "http..."), instead of an internal link. Yaron Koren (talk) 16:47, 15 February 2023 (UTC)Reply
That works for explicit links, thanks! I was trying to generate the links inside a query (I have an aggregate query that provides counts, and want to link to a drilldown that would list the values that are counted). Some of the values have spaces in them, so the only way I can think of to make this work is to enable the "replace" function in SQL and then turn the spaces into "+" to generate the link. This works (CONCAT("[https://.../index.php?title=Special:Drilldown/Person&Section=", REPLACE(Person__Section._value, ' ', '+') ... ), but REPLACE seems to be an especially problematic function to enable. Is there a better solution to generate that link? Tenbergen (talk) 18:06, 15 February 2023 (UTC)Reply
Oh, I see. That seems fine - I don't see anything wrong with using REPLACE(). Yaron Koren (talk) 20:10, 15 February 2023 (UTC)Reply
My concern with enabling the replace function was that it might allow re-writing things inside an SQL query, e.g. SQL injection. Maybe I am being paranoid. Tenbergen (talk) 19:17, 16 February 2023 (UTC)Reply

"Recreate data" issue with Mediawiki 1.39.1

I'm getting the following error. I have ran update.php since upgrading Mediawiki and Cargo. Any ideas?


Error 1054: Unknown column 'tl_namespace' in 'where clause'

Function: SpecialCargoRecreateData::getNumPagesThatCallTemplate

Query: SELECT COUNT(*) AS total FROM `page`,`templatelinks` WHERE (tl_from=page_id) AND tl_namespace = 10 AND tl_title = 'CMTS'

Backtrace:

from /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1618)

#0 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1602): Wikimedia\Rdbms\Database->getQueryException()

#1 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1576): Wikimedia\Rdbms\Database->getQueryExceptionAndLog()

#2 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(952): Wikimedia\Rdbms\Database->reportQueryError()

#3 /var/www/html/wiki/includes/libs/rdbms/database/Database.php(1708): Wikimedia\Rdbms\Database->query()

#4 /var/www/html/wiki/includes/libs/rdbms/database/DBConnRef.php(103): Wikimedia\Rdbms\Database->select()

#5 /var/www/html/wiki/includes/libs/rdbms/database/DBConnRef.php(325): Wikimedia\Rdbms\DBConnRef->__call()

#6 /var/www/html/wiki/extensions/Cargo/includes/specials/SpecialCargoRecreateData.php(164): Wikimedia\Rdbms\DBConnRef->select()

#7 /var/www/html/wiki/extensions/Cargo/includes/specials/SpecialCargoRecreateData.php(79): SpecialCargoRecreateData->getNumPagesThatCallTemplate()

#8 /var/www/html/wiki/extensions/Cargo/includes/CargoRecreateDataAction.php(43): SpecialCargoRecreateData->execute()

#9 /var/www/html/wiki/includes/MediaWiki.php(542): CargoRecreateDataAction->show()

#10 /var/www/html/wiki/includes/MediaWiki.php(322): MediaWiki->performAction()

#11 /var/www/html/wiki/includes/MediaWiki.php(904): MediaWiki->performRequest()

#12 /var/www/html/wiki/includes/MediaWiki.php(562): MediaWiki->main()

#13 /var/www/html/wiki/index.php(50): MediaWiki->run()

#14 /var/www/html/wiki/index.php(46): wfIndexMain()

#15 {main} Brian Coulter (talk) 05:36, 16 February 2023 (UTC)Reply

Please make sure you're using version 3.3.1 or higher of Cargo. Yaron Koren (talk) 13:39, 16 February 2023 (UTC)Reply
Sure enough, I was on version 3.2. I thought I was on the latest version. Thank you. Brian Coulter (talk) 15:28, 16 February 2023 (UTC)Reply

Error using Display Format Tree

I have a query that uses format=tree. The query works fine with default format, but when it includes the tree format I get

An error occurred while attempting to preview your changes.
[Y@6B0PewgK-G5pKpZ7wu1AAAAA8] Caught exception of type TypeError

When I enable debug, it gives

[Y@0OWaDWU8Gc8kr4BU0dggAAAA8] /index.php?title=Org_Chart&action=submit TypeError: array_key_exists(): Argument #2 ($array) must be of type array, CargoFieldDescription given
Backtrace:
from /.../extensions/Cargo/includes/formats/CargoTreeFormat.php(40)

This CargoTreeFormat.php(40) is

if ( array_key_exists( 'isList', $fieldDescriptions[$this->mParentField] ) ) {

What is actually wrong here? I think an exception isn't being trapped as intended, but I don't understand what. What do I need to change? Tenbergen (talk) 19:23, 16 February 2023 (UTC)Reply

Wow! It must have been a long time since anyone tried to use the "tree" format, because there were various things that were not working there - that "isList" check was just one of them. I just checked in a fix, so it all should work better. Yaron Koren (talk) 21:37, 16 February 2023 (UTC)Reply
That fixed it! Yes, it's been a problem for a long time, I just had not got back to troubleshooting it. Thanks! Tenbergen (talk) 00:12, 17 February 2023 (UTC)Reply

Add table row [edit link] when using format=template

I'm displaying results in a table, using format=template for the rows. How can I add a Page Forms edit link next to each row? I know this is possible using format=table by adding the parameter "edit link=yes", but I haven't figured out how to do it when using format=template. Note that I'm using unique numbers as the pagename for each country.

Template:Country

<noinclude>

{{#cargo_declare:_table=Countries

|Continent=String

|Name=String

|Capital=String

|Population=Integer

}}

</noinclude>

Template:Country row

<includeonly>

<tr>

<td>[[{{{Continent|}}}]]</td>

<td>[[{{{Name|}}}]]</td>

<td>[[{{{Capital|}}}]]</td>

<td>[[{{{Name|}}}]]</td>

<td>{{#formlink:form=Country|link text=edit| *****target country page/row ID***** }}

</tr>

</includeonly>

Template:List of countries

<includeonly>

{{#cargo_query:table=Countries

|fields=Continent,Name,Capital,Population

|where=Continent='{{{1|{{PAGENAME}}}}}'

|format=template

|template=Country row

|named args=yes

|intro=<table><tr><th>Continent</th><th>Name</th><th>Capital</th><th>Population</th></tr>

|outro=</table>

}}

</includeonly>

120.28.64.1 09:23, 19 February 2023 (UTC)Reply

It sounds like you need to add _pageName to the list of fields in the query - and then have #formlink include target={{{_pageName}}}. Yaron Koren (talk) 16:09, 20 February 2023 (UTC)Reply
Thank you very much! 120.28.64.1 17:29, 21 February 2023 (UTC)Reply

Database error when trying to concat a list field in Cargo Query

I was doing some troubleshooting and tried to run a query in the Special Cargo Query. The query is

{{#cargo_query:
tables=Person
|fields=CONCAT("xxx", Person.SecretaryTo, "yyy")
|where=_pageName="Tina Tenbergen"
}}

where SecretaryTo is of type "List of Page, delimiter: ,". When I run the query with a text field I get no error. The query runs and provides sort of the expected result when I just use the field, no Concat. But I think I have some blanks or other problem, so I wanted to add the xs before and the ys after. When I do that, get a red crash:

[Y-angD@M5u2uPkXmix1j2QAAAA8] 2023-02-22 23:38:40: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"

With debugging enabled it becomes

[Y-amLT@M5u2uPkXmix1jdwAAAA8] /index.php?title=Special%3ACargoQuery&tables=Person&fields=CONCAT%28%22xxx%22%2C+Person.SecretaryTo%2C+%22yyy%22%29&where=_pageName%3D%22Tina+Tenbergen%22&join_on=&group_by=&having=&order_by%5B0%5D=&order_by_options%5B0%5D=ASC&limit=&offset=&format= Wikimedia\Rdbms\DBQueryError: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading or after adding a new extension?
Please see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Upgrading and https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:How_to_debug for more information.
Error 1054: Unknown column 'mw_cargo__Person.SecretaryTo' in 'field list'
Function: CargoQueryPage::reallyDoQuery
Query: SELECT CONCAT("xxx", `mw_cargo__Person`.`SecretaryTo`, "yyy") AS `SecretaryTo, "yyy")` FROM `mw_cargo__Person` WHERE (_pageName="Tina Tenbergen") ::ORDER BY CONCAT("xxx",`mw_cargo__Person`.`SecretaryTo__full` , "yyy") LIMIT 1001
Backtrace:
from /home/<my wiki>/includes/libs/rdbms/database/Database.php(1618)
  1. 0 /home/<my wiki>/includes/libs/rdbms/database/Database.php(1602): Wikimedia\Rdbms\Database->getQueryException(string, integer, string, string)
  2. 1 /home/<my wiki>/includes/libs/rdbms/database/Database.php(1576): Wikimedia\Rdbms\Database->getQueryExceptionAndLog(string, integer, string, string)
  3. 2 /home/<my wiki>/includes/libs/rdbms/database/Database.php(952): Wikimedia\Rdbms\Database->reportQueryError(string, integer, string, string, boolean)
  4. 3 /home/<my wiki>/includes/libs/rdbms/database/Database.php(1708): Wikimedia\Rdbms\Database->query(string, string, integer)
  5. 4 /home/<my wiki>/includes/specialpage/QueryPage.php(540): Wikimedia\Rdbms\Database->select(array, array, array, string, array, array)
  6. 5 /home/<my wiki>/includes/specialpage/QueryPage.php(726): QueryPage->reallyDoQuery(integer, integer)
  7. 6 /home/<my wiki>/extensions/Cargo/includes/specials/SpecialCargoQuery.php(36): QueryPage->execute(NULL)
  8. 7 /home/<my wiki>/includes/specialpage/SpecialPage.php(701): SpecialCargoQuery->execute(NULL)
  9. 8 /home/<my wiki>/includes/specialpage/SpecialPageFactory.php(1428): SpecialPage->run(NULL)
  10. 9 /home/<my wiki>/includes/MediaWiki.php(316): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
  11. 10 /home/<my wiki>/includes/MediaWiki.php(904): MediaWiki->performRequest()
  12. 11 /home/<my wiki>/includes/MediaWiki.php(562): MediaWiki->main()
  13. 12 /home/<my wiki>/index.php(50): MediaWiki->run()
  14. 13 /home/<my wiki>/index.php(46): wfIndexMain()
  15. 14 {main}

I suspect something about lists isn't handled right in this context. Tenbergen (talk) 23:37, 22 February 2023 (UTC)Reply

A list field is not a string, so it's not surprising that the CONCAT() failed. (And actually, list fields aren't even really fields at all - they're "virtual" fields.) I think you can get this query working by replacing Person.SecretaryTo with Person.SecretaryTo__full. Yaron Koren (talk) 15:45, 23 February 2023 (UTC)Reply
Thanks, I got it working with __full. Error Fatal exception of type "Wikimedia\Rdbms\DBQueryError wasn't very helpful, though, and not all query builders would have access to enable debug to show something more helpful. So, I posted it in case you want to turn the error into something more descriptive. Thanks for your help! Tenbergen (talk) 22:31, 2 March 2023 (UTC)Reply

Duplicate results in Special:Drilldown

Any news on this?

Thanks. Jonathan3 (talk) 10:41, 2 March 2023 (UTC)Reply

No, sorry - I'm guessing it's still a problem? Yaron Koren (talk) 14:49, 2 March 2023 (UTC)Reply
Yes, I'm afraid so - quite a big one, for some tables at least.
I had a look at the code and added a suggestion on the Phabricator task. Jonathan3 (talk) 21:40, 2 March 2023 (UTC)Reply

Hidden category for pages containing Cargo queries

Is it possible to set this up? Thanks. Jonathan3 (talk) 22:59, 6 March 2023 (UTC)Reply

The cargo_backlinks DB table holds the IDs of all pages containing queries - maybe that's good enough? Yaron Koren (talk) 16:55, 7 March 2023 (UTC)Reply
That sounds all right. Can it be queried from a wiki page? Jonathan3 (talk) 21:58, 8 March 2023 (UTC)Reply
Not really with the current software... what's the ultimate goal? Yaron Koren (talk) 23:25, 8 March 2023 (UTC)Reply
I'm considering changing a Cargo table's structure, and wanted to update queries where necessary. I considered writing a short script querying the cargo_backlinks table, but there aren't that many Cargo queries so I think I can just use Extension:ReplaceText (to search for {{#cargo_query). Jonathan3 (talk) 22:39, 16 March 2023 (UTC)Reply

List not populated

Hi! First of all, thanks for creating this extension :D I have some issues however, that I'm trying to sort out. Right now, my main table is not completely getting populated. It should have ~250,000 rows, but it just stops, sometimes at 300, sometimes at 17,0000, but never near expected. I have tried creating replacement tables, but has no effect. Does anyone by any chance know what could be the issue here? Dajasj (talk) 14:55, 16 March 2023 (UTC)Reply

I would try populating the table from the command line, by calling cargoRecreateData.php - it might work better, or it might point to whatever is crashing the recreate process. Yaron Koren (talk) 15:01, 16 March 2023 (UTC)Reply
If you're using MW 1.38+ and web UI to recreate cargo table then you'll hit this issue (&action=recreatedata), the problem is https://github.com/wikimedia/mediawiki-extensions-Cargo/blob/master/includes/specials/SpecialCargoRecreateData.php#L163 where tl_target_id should actually be a lt_id from linktarget, not the page_id of the ID of the template, following is an updated function that joins with linktarget table to get the correct numPages for creating table recrate jobs. Pandafox1 (talk) 09:50, 18 April 2023 (UTC)Reply
public function getNumPagesThatCallTemplate( $dbw, $templateTitle ) {
$conds = [ "tl_from=page_id" ];
if ( class_exists( 'MediaWiki\CommentFormatter\CommentBatch' ) ) {
// MW 1.38+
$conds[] = "tl_target_id = lt_id";
$conds['lt_namespace'] = $templateTitle->getNamespace();
$conds['lt_title'] = $templateTitle->getDBkey();
} else {
$conds['tl_namespace'] = $templateTitle->getNamespace();
$conds['tl_title'] = $templateTitle->getDBkey();
}
$res = $dbw->select(
[ 'page', 'templatelinks', 'linktarget' ],
'COUNT(*) AS total',
$conds,
__METHOD__,
[]
);
$row = $res->fetchRow();
return intval( $row['total'] );
} Pandafox1 (talk) 09:55, 18 April 2023 (UTC)Reply

cargoRecreateData.php not working properly with --replacement parameter

I changed a field of an existing table from String to List (;) of String and ran cargoRecreateData.php with the --replacement parameter. The prefix_cargo__Tablename__NEXT__fieldname table was created, but when switching in the replacement table using the web interface the "NEXT" tables were not dropped (I've not noticed whether that is normal or not) but more importantly no prefix_cargo__Tablename__fieldname was created. This meant that the associated Page Form form didn't work.

I dropped the NEXT tables manually and ran cargoRecreateData.php without the --replacement parameter and it all worked as expected.

MW 1.35.8, Cargo 3.3.1 (dac6b0d). Jonathan3 (talk) 21:53, 19 March 2023 (UTC)Reply

It sounds like the problem is with the switch call via the web interface, not with cargoRecreateData.php - no? Yaron Koren (talk) 17:20, 20 March 2023 (UTC)Reply
Yes, agreed. Jonathan3 (talk) 19:18, 20 March 2023 (UTC)Reply

Error: the string "`" cannot be used within #cargo_query

I started getting this error since Cargo 3.4.1. In my case, I have a label for a column that contains a space, i.e. COUNT(live_songs._ID)=No. shows, and then I'm trying also sort on this column with `No. shows` DESC. This used to work. I can fix it by using COUNT(live_songs._ID) DESC instead, but without seeing the query plan, I think I'm experiencing a slower query because it's not using the same value already calculated in the SELECT clause. I don't know if that's really true, though.

What is the recommendation on sorting or grouping by columns with spaces in their names? MusikAnimal talk 16:52, 20 March 2023 (UTC)Reply

Sorry about that - yes, backticks were recently disallowed in #cargo_query, for better or for worse. Yes, I would recommend just sorting on the COUNT call. I don't think it will be slower, but I don't know for sure. You could test it with a no-spaces alias. Yaron Koren (talk) 17:29, 20 March 2023 (UTC)Reply
I also have the same problem, this is the only code I am managing in my personal wiki using the Cargo extension --Hispano76 (talk) 17:35, 20 March 2023 (UTC)Reply
What is the #cargo_query call that is failing? Yaron Koren (talk) 17:42, 20 March 2023 (UTC)Reply
That's the thing. i'm not using #cargo_query: anywhere and i only use the image thing; to use the data collected in Special:Drilldown to better manage the articles i make, ehm, like using the special page as a dictionary or database to create lists or people pages. --Hispano76 (talk) 17:49, 20 March 2023 (UTC)Reply
So what is the error you are seeing? Yaron Koren (talk) 19:11, 20 March 2023 (UTC)Reply
It occurs on two different special page, for example:
Special:CargoTables/Personas:     Error: the string "`" cannot be used within #cargo_query.
When entering one of the conditions of Special:Drilldown/Personas?_single&Genero=Mujeres:    [8729a925e7f3a54509d6b65f] 2023-03-20 19:22:12: Excepción grave de tipo "MWException"
Even when recreating the table, the error persists. --Hispano76 (talk) 19:28, 20 March 2023 (UTC)Reply
Please try using the latest Cargo code, if you are not already; there have been some fixes for this "backticks" change, including one last week that may fix at least the Special:Drilldown problem. Yaron Koren (talk) 19:47, 20 March 2023 (UTC)Reply

Cannot Create Cargo Tables

SOLVED: I think the problem is that my table name was "STAT_Faction." I removed the underscore...and now it behaves.

Might want to update the error text I saw below (testing, shockingly, dashes) to include underscores as not allowed either.

Error: table name "Dash-Test" cannot contain any of the following characters: .,-<>(){}[]\/

Original description of problem

  • MediaWiki 1.39.2
  • PHP 7.4.33 (litespeed)
  • MySQL 8.0.32-cll-lve
  • ICU 64.2

Using Page Forms 5.6.

Tried to create a basic one-parameter template/table (a single text field). Neither SSH nor Create Data Table worked. I confirmed the MediaWiki user has all permissions to the MediaWiki table. Enabling $wgShowSQLErrors = true; and $wgShowExceptionDetails = true; revealed no error messages when running Create Data Table from a Template page.

I temporarily edited ext.cargo.recreatedata.js to log its error in my browser console. It's a database problem of some kind--"internal_api_error_DBQueryError" that doesn't expand (it's not a JSON object with more detail than just the message).

More data, used the old college try and here's what it was trying to send: Going to submit the following query string to MWAPI: {"action":"cargorecreatetables","format":"json","template":"Faction"}

SovereignGFC (talk) 11:28, 22 March 2023 (UTC)Reply

Creating and recreating tables with underscores in their names works for me. What version of Cargo are you running? And what error(s) did you see when running cargoRecreateData.php from the command line, if any? Yaron Koren (talk) 14:53, 22 March 2023 (UTC)Reply
Cargo version is 3.4.1.
When executing from SSH on the command line, no errors were displayed. SovereignGFC (talk) 20:45, 26 March 2023 (UTC)Reply
Okay - so what happened when you ran cargoRecreateData.php? Yaron Koren (talk) 02:07, 27 March 2023 (UTC)Reply
That's what is weird. Literally nothing. No output, no errors, no actions taken in the database. SovereignGFC (talk) 01:16, 28 March 2023 (UTC)Reply
Let me see if I understand this right: you had exactly one table defined, "STAT_Faction". Calling cargoRecreateData.php at that point did nothing. Then you renamed the table to "STATFaction", and calling cargoRecreateData.php started to work (and still works). Is that correct? Yaron Koren (talk) 14:52, 28 March 2023 (UTC)Reply
That is correct.
I tried to debug it as described above but couldn't really get any useful data.
Since it works for you I'll just assume there's something weird with my web host/server and not put underscores in table names. SovereignGFC (talk) 12:29, 29 March 2023 (UTC)Reply
Could it be that just resaving the template fixed the issue, somehow? I'd be very curious to know whether, if you changed the table name back to having an underscore, the problem came back. Yaron Koren (talk) 12:48, 29 March 2023 (UTC)Reply
Get this...I accidentally created a table with an underscore today.
I have no idea what changed.
Ghosts. SovereignGFC (talk) 02:05, 6 April 2023 (UTC)Reply

Missing Columns in CSV

I believe this is a bug. If you output to CSV, and not all rows have the fields you selected, then the output will not have that column in the headers or result set at all. If you output to Table it does. If you output to JSON only the records that have that field will include it. I did not test any other formats but they may be affected as well. I suspect the columns are selected based on the first result set, which is missing the column in my case, and only further rows have it. This is all from a single table. May be related to virtual list fields. BalmyRemission (talk) 17:05, 23 March 2023 (UTC)Reply

Do you mean that this only happens if list fields contain empty values? Or does it happen for empty values in all kinds of fields? Yaron Koren (talk) 02:49, 24 March 2023 (UTC)Reply
I didn't previously do extensive testing. Here's an example query (edit: I can't seem to post external links, so please visit poewiki dot net, go to CargoQuery, and fill in `items` for tables, `name, drop_areas, acquisition_tags, removal_version` for fields, and `rarity_id="unique"` for WHERE, and set the output format to CSV) where you can see the CSV is missing `drop_areas`, `acquisition_tags` and `removal_version`, and not just in the header, but in the result set as well. The first two are lists, and the last one is a string. If you modify the query at the bottom to output in table or json, those fields show up and are populated normally, but notice they aren't assigned for every row (since they have no data). I thought I ran into the problem in another combination of displays, but I can't remember where and it may have just been csv as well but from one of the other ways to invoke the cargo api. I just tried api.php and ApiSandbox now with json and that one is OK. CargoExport also shows the problem when dumping to CSV but again JSON is fine. So it seems like the problem is only with CSV and only if some of your fields are not populated for every row? And that it affects regular fields and virtual list fields. Hope this helps! BalmyRemission (talk) 04:04, 24 March 2023 (UTC)Reply
I see the problem on your wiki, yes - although I can't reproduce that same issue locally. There's at least one other strange thing happening on your wiki, which is that submitting Special:CargoQuery twice (i.e., modifying the values and submitting again) results in all the values going blank. You're using a somewhat old version of Cargo on that wiki - could that be the cause of both of these problems? Or maybe your wiki has some custom modifications? Yaron Koren (talk) 13:27, 24 March 2023 (UTC)Reply
Thank you for your time troubleshooting this Yaron, I've reported this to the admins of poewiki and we'll see what they say. I have no access to other wikis so didn't have a way to narrow my testing further. BalmyRemission (talk) 15:22, 24 March 2023 (UTC)Reply

_ID on Cargo Table View

BEST SOLUTION: Use the Cargo query page, select desired fields, and export as Excel or CSV to accomplish the goal of dump and distribute data with IDs to a distributed team.

I am writing because I'd like to enable viewing _ID on the page Special:CargoTables/<TableName> rather than having to use the Cargo query page.

It seems the return from tableSchemas on line 101 of CargoTables.php (v3.4.1) returns a BLOB column that only has the custom columns. This also seems to be integrated into how the rest of the page works (both for the column names and the data).

I keep tugging on things and finding more threads. Ultimately I'd need to mess with the query to include _ID but every time I dump it, it's a giant wad that my new-to-MediaWiki brain panics on seeing.

Cargo table view
Cargo table view

SovereignGFC (talk) 13:40, 29 March 2023 (UTC)Reply

Why do you want to see the _ID value? Yaron Koren (talk) 16:28, 29 March 2023 (UTC)Reply
I'm using _ID as a primary/foreign key to join tables together. SovereignGFC (talk) 19:13, 29 March 2023 (UTC)Reply
Fine, but why do you need to see its values in Special:CargoTables? Yaron Koren (talk) 02:34, 30 March 2023 (UTC)Reply
Essentially I am looking for the fastest way to "dump and distribute" IDs to a distributed team.
It seems the best way to do this is actually using the Cargo query page, select desired fields, and export as CSV/Excel. SovereignGFC (talk) 15:23, 31 March 2023 (UTC)Reply
I see, okay - yes, that seems better than using Special:CargoTables. Yaron Koren (talk) 15:26, 31 March 2023 (UTC)Reply
Indeed it is. And now I've run into something else that you may be able to help me see a better way.
Using the ID as a link between tables seemed like a great idea...until I realized that re-creating the table (which I do when I add new items) doesn't keep the IDs...
So everything downstream breaks!
It's not a problem with static data like the attached image (there are no more ship types) but for item tables where new items are being discovered all the time and I'm trying to tie them to the characters they belong to, it presents an issue.
Now, if I use Page Forms to create items, it seems to update without requiring recreation. Perhaps the solution is to build out forms, and ONLY add items that way? SovereignGFC (talk) 16:52, 31 March 2023 (UTC)Reply
Maybe you should use _pageID instead of _ID? The _ID field is only useful for tables that contain "list" fields, to join the main table with its "field tables". (I thought that was the kind of join you were talking about.) Yaron Koren (talk) 18:34, 31 March 2023 (UTC)Reply
Ah so _pageID doesn't change when I rebuild/recreate? Thanks! SovereignGFC (talk) 22:21, 31 March 2023 (UTC)Reply
No, it's MediaWiki's own ID for that page, which stays constant. Yaron Koren (talk) 19:03, 10 April 2023 (UTC)Reply

ViewData page (when pressing on "more results") is getting disconnected

Hi, when query has more results and I click on the link below my results it leads me to a page named "Special:ViewData" and it's concat the query as GET params.

In case I have a long query (10k~) due to a a value I checked it's part of a list, when getting to the Special:ViewData page I'm getting an error, it's even not returning 500 but just disconnected.


From my very basic checks it seems that a url longer than 5300~ chars will get this error.

I can't see any exception in my server error log and I can't see anything relevant in mediawiki debug log (I turn it on), there is a way to check what's the issue and fix it?:)


Thank you very much! Koshob (talk) 22:39, 16 April 2023 (UTC)Reply

It sounds like you're using a rather old version of Cargo (Special:ViewData was renamed to Special:CargoQuery a long time ago), so I suppose there's a chance that just upgrading Cargo will fix the problem. Still, I'm guessing that this is just a problem with giant URLs in Apache, or whatever web server you are using. Maybe there's a way to make the query not so gigantic? Yaron Koren (talk) 02:40, 17 April 2023 (UTC)Reply
The main part of the query is checking whether a value is part of list of strings, I can put these inside a template, but I guess that when passing the cargo query in the GET params in the url is will be raw, no?
Any other idea maybe?:)
Thanks! Koshob (talk) 21:14, 19 April 2023 (UTC)Reply
Okay, it's a giant list of values. Right, a template wouldn't work. The only solution I can think of that might work is putting all those values into their own Cargo table - maybe through a big page that held each value in a separate template call. It would be great if you could then do an inner select, like "where=MyValue IN (SELECT ...)", but Cargo doesn't allow that. But maybe you could do it with a join, like "tables=RealData,ComparisonStrings |join on=RealData.MainString=ComparisonStrings.TheString |where=ComparisonStrings.TheString IS NOT NULL". (I'm not sure what the "where" value needs to be, or if there even needs to be one.) Yaron Koren (talk) 14:06, 21 April 2023 (UTC)Reply
Yea, wanted to avoid creating new table and inset all of this data, but it seems that I'll do it, TY! Koshob (talk) 20:55, 21 April 2023 (UTC)Reply

500 Row Limit (Not Just Display)

So I have some categories that I know have 800+ items. There are no duplicates.

I had to re-build the Cargo tables related to these categories during testing...and they only ever now fill to 500 rows.

The symptom is that some queries don't return values when I know the page exists. The item has not been pulled into Cargo however, so the query returns nothing.

Is it because I'm invoking runJobs.php? (I was going to let the jobs run naturally--but only 50-ish jobs finished overnight out of over 900). SovereignGFC (talk) 23:22, 20 April 2023 (UTC)Reply

That definitely sounds like a bug. What versions of MediaWiki and Cargo are you running? Yaron Koren (talk) 14:10, 21 April 2023 (UTC)Reply
  • MediaWiki: 1.39.2
  • Cargo 3.4.1
I just realized something else--when I imported the data in six sections as opposed to all-at-once, the table properly built up to 880+ values. So it does seem like there's some arbitrary cutoff at 500, but only if one attempts to do all of this at once. SovereignGFC (talk) 12:45, 22 April 2023 (UTC)Reply
This turned out to be a bug with MediaWiki 1.39, for at least some installations - thankfully, TK-999 was able to quickly diagnose the problem, and just checked in a fix for it, here. So if you get the latest Cargo code, hopefully recreating data will work correctly again. Yaron Koren (talk) 18:02, 25 April 2023 (UTC)Reply
Just as housekeeping/for future readers, updating Cargo to 3.4.2 resolved the 500 item issue. SovereignGFC (talk) 16:58, 2 May 2023 (UTC)Reply

Newbie query question

I have a Cargo table with cities plus fields like Country and Population. On each city page, I want to display a navigation bar with links to other cities within the same country, like this:

Paris (page title)

LyonMarseilleNantes • Paris • Toulouse


The query below works, but instead of specifying the country in WHERE=, I want to set a parameter to get the country from the current city page:

{{#cargo_query:table=Cities

|fields=_pageName

|format=list

|where=Country="France"

|delimiter=&nbsp;•

}}

120.28.64.103 09:38, 29 April 2023 (UTC)Reply

Is this display done within the main template? If so, you can probably get it working by just substituting {{{Country|}}} in place of France in the query. If not, you'll probably have to do something more complicated, like joining the Cities table to itself. Yaron Koren (talk) 15:11, 1 May 2023 (UTC)Reply

Cargo, Infoboxes, New Paragraph Breaks

So I'm beginning to think the reason my Infoboxes are looking funky is related to how Cargo returns data.

Here is an infobox invoked via pure text/wiki markup.
Here's one that was populated via Cargo.
For some reason the text for every row is being rendered in a separate paragraph break outside the usual class...

SovereignGFC (talk) 16:13, 29 April 2023 (UTC)Reply

Is each of those a separate query? If so, then yes, extra HTML tags are the problem - and you can get rid of those by adding a |no html to each #cargo_query call. Yaron Koren (talk) 15:13, 1 May 2023 (UTC)Reply
I'll try it, thanks! EDIT: I ended up going back to just letting Cargo handle it in "infobox" mode as that was working okay. SovereignGFC (talk) 14:53, 2 May 2023 (UTC)Reply