Topic on Extension talk:JsonConfig/Flow

How to make page_content_model column in MySQL page table to automatically be set to 'json' instead of 'wikitext' for *.json pages in Data namespace?

1
Jasonkhanlar (talkcontribs)

How can I configure this extension to use the JsonContentHandler class for `'pattern' => '/.\.json$/'` page titles? In MySQL database, I want to be able to create pages that end in ".json" for the `page_content_model` column to be "json" value by default, instead of "wikitext" content model type. Is this possible with JsonConfig extension?

Here is my LocalSettings.php configuration attempt so far:

   $wgJsonConfigModels['Json.JsonConfig'] = 'JsonContentHandler';
   //$wgJsonConfigModels['Json.JsonConfig'] = [];
   //$wgJsonConfigModels['Json.JsonConfig']['class'] = 'JsonConfig\JCDataContent';
   //$wgJsonConfigModels['Json.JsonConfig']['view'] = 'JsonConfig\JCDefaultContentView';
   //$wgJsonConfigModels['Json.JsonConfig'] = 'JsonConfig\JCDataContent';
   $wgJsonConfigs['JSON.JsonConfig'] = [
       'cacheExp' => 86400,
       'cacheKey' => ,
       'flaggedRevs' => false,
       'isLocal' => true,
       'license' => 'CC0-1.0',
       'model' => 'Json.JsonConfig',
       'namespace' => 486,
       'nsName' => 'Data',
       'nsTalk' => 'Data_talk',
       'pattern' => '/.\.json$/',
       //'pattern' => '/^Json:./',
       'store' => true
    ];

Edited to add: Almost, and I guess it's good enough, but if I change 1 line above to:

   $wgJsonConfigModels['Json.JsonConfig'] = null;

then it seems to work. The MySQL database page table page_content_model column value shows as "Json.JsonConfig" instead of "json" which is probably because of the configuration (which works, and is good enough for now), but otherwise I am still curious if there is any way to configure this so that the value will be "json" to use the existing content model type that appears to be the exact same (but I didn't verify this)

Also see https://phabricator.wikimedia.org/T305571 which is what I read through to come to this solution.


Also, when I try to edit a *.json page (that I manually changed the content model type at wiki/Special:ChangeContentModel to 'json') with the models configuration above (= null for "Json.JsonConfig" key), when I try to visit a page with the 'json' content model type, instead of the 'Json.JsonConfig' model type, when I try to edit the page I see:

Content format not supported

The content format application/json+pretty is not supported by the content model JSON.

From a standpoint of the data types being practically exactly the same, and humanly capable of support capabilities, this type of error message seems inconvenient, and probably more of a database technical constraint than an actual inability to produce similar visual user interface capabilities that function practically identically, I would suspect.

   $handler->isSupportedFormat( $this->contentFormat )

Perhaps is there a way that this can evaluate as true in includes/EditPage.php in such a condition?

Also see https://phabricator.wikimedia.org/T307978

Reply to "How to make page_content_model column in MySQL page table to automatically be set to 'json' instead of 'wikitext' for *.json pages in Data namespace?"