[Wikitech-l] onVerifyFileUpload error message not displayed 'as is' in visual editor upload form

2020-01-22 Thread Tom Schulze
dear all,

i am trying to carry out some custom checks before uploading a file in
mediawiki. i face the challenge that i cannot pass my own error messages
to the visualeditor upload form. whatever error message i declare in the
onVerifyFileUpload hook gets displayed in VE as  This file did not pass
file verification. my error message that i declare in the hook 'gets
aggregated' in UploadFromChunks.php:201. ($this->getVerificationErrorCode())

i also tried other hooks to intercept/manipulate the error but to no
avail (ApiMain::onException,APIGetAllowedParams, APIAfterExecute).

i use mediawiki 1.32.2.

is there a way i did not think of to display a custom error message in
my case?

thank you and kind regards,

tom



___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] content_models table only contains wikitext content model on fresh MW 1.32.3 install

2019-09-19 Thread Tom Schulze

> There have been reports of similar problems with the slots table. Please add
> your experience to the ticket here:
>
> https://phabricator.wikimedia.org/T224949
>
> There is a patch up that should safeguard against my best guess at the cause 
> of
> this. If you can provide additional insights as to exactly how this may 
> happen,
> please do!
>
>
Thank you for your quick reply and for pointing me to the right
direction. I am not sure if it's a mistake on my side, otherwise I'll
gladly contribute.

I assume that the content_model id is lost/not generated somewhere
between my clean MW install and the import of my templates via a script.
I import pages using a custom maintenance script which reads a files'
content from the file system and saves it to the mediawiki db using:

$title = Title::newFromText('Widget:MyWidget');
$wikiPage = new WikiPage( $title );
$newContent = ContentHandler::makeContent( $contentFromFile, $title );
$wikiPage->doEditContent( $newContent );

In the MW Class reference

it says  "If [the modelId parameter for ContentHandler::makeContent()
is] not provided, $title->getContentModel() is used." I assume, that it
checks the namespace among others and uses javascript for Widgets?
Because in my case it's a widget that causes the error. The extension is
installed prior to the importation and the namespace 'Widget' exists.

Is there something wrong with the snippet?

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

[Wikitech-l] content_models table only contains wikitext content model on fresh MW 1.32.3 install

2019-09-18 Thread Tom Schulze
Dear all,

for our deployment procedure we're setting up a clean database with some
prefilled content. I use MW 1.32.3 for that. When I did the fresh
install (minimal installation method) I realized that the
'content_models' database table only contains one row with model_id = 1
and model_name = wikitext.

I then install extensions, run update.php, and import a couple pages,
templates, etc. When setting up Cargo's _pageData table using the
setCargoPageData.php script at a later stage I get the following error
(see backtrace at the very bottom).

Failed to access name from content_models using id = 2

I get this error fixed by inserting the core content models
<https://www.mediawiki.org/wiki/Content_handlers> into the
'content_models' table manually. Accessing the pages afterwards works
fine (Widgets in this case). The widgets themselves work fine, too.

Am I missing something that the core content models are not in the
initial database table 'content_models'? Is this table not filled during
the installation procedure?

Is it actually bad advice to insert the rows manually?

Kind regards and thanks for your support,

Tom


[12081d263c4cc289d8a144d8] [no req]  
MediaWiki\Storage\NameTableAccessException from line 42 of
/var/www/mediawiki/lib/includes/Storage/NameTableAccessException.php:
Failed to access name from content_models using id = 2
Backtrace:
#0 /var/www/mediawiki/lib/includes/Storage/NameTableStore.php(308):
MediaWiki\Storage\NameTableAccessException::newFromDetails(string,
string, integer)
#1 /var/www/mediawiki/lib/includes/Revision/RevisionStore.php(1625):
MediaWiki\Storage\NameTableStore->getName(integer)
#2 /var/www/mediawiki/lib/includes/Revision/RevisionStore.php(1671):
MediaWiki\Revision\RevisionStore->loadSlotRecords(string, integer)
#3 [internal function]:
MediaWiki\Revision\RevisionStore->MediaWiki\Revision\{closure}()
#4 /var/www/mediawiki/lib/includes/Revision/RevisionSlots.php(165):
call_user_func(Closure)
#5 /var/www/mediawiki/lib/includes/Revision/RevisionSlots.php(107):
MediaWiki\Revision\RevisionSlots->getSlots()
#6 /var/www/mediawiki/lib/includes/Revision/RevisionRecord.php(192):
MediaWiki\Revision\RevisionSlots->getSlot(string)
#7 /var/www/mediawiki/lib/includes/Revision/RevisionRecord.php(175):
MediaWiki\Revision\RevisionRecord->getSlot(string, integer, NULL)
#8 /var/www/mediawiki/lib/includes/Revision.php(932):
MediaWiki\Revision\RevisionRecord->getContent(string, integer, NULL)
#9 /var/www/mediawiki/lib/includes/page/WikiPage.php(801):
Revision->getContent(integer, NULL)
#10
/var/www/mediawiki/lib/extensions/Cargo/includes/CargoPageData.php(107):
WikiPage->getContent()
#11
/var/www/mediawiki/lib/extensions/Cargo/maintenance/setCargoPageData.php(88):
CargoPageData::storeValuesForPage(Title)
#12 /var/www/mediawiki/lib/maintenance/doMaintenance.php(94):
SetCargoPageData->execute()
#13
/var/www/mediawiki/lib/extensions/Cargo/maintenance/setCargoPageData.php(103):
require_once(string)
#14 {main}

-- 
Tom Schulze

energypedia consult GmbH
König-Adolf-Str. 12
65191 Wiesbaden

Phone: +49 0611 18195031
Email: t.schu...@energypedia-consult.com
Web: www.energypedia-consult.com | www.webmo.info

Registergericht: Frankfurt, Eintragungs-Nr. HRB 93412 | Sitz: Eschborn | 
Geschäftsführung: Robert Heine 

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] resource loader; 1.32 alpha; 1.32 stable breaking change, loading scripts in widgets

2019-04-05 Thread Tom Schulze
I agree with Bartosz Dziewoński. However, after checking out the code, I
think the reason why I need to change the RLQ push statements is due to
the resources/src/mediawiki.base/mediawiki.base.js modifications in
v1.32 stable.

window.RLQ = {
push: function ( entry ) {
if ( typeof entry === 'function' ) {
entry();
} else {
mw.loader.using( entry[ 0 ], entry[ 1 ] );
}
}
};


It seems hacky, but when using RLQ.push() and mw.loader.using in widgets
I now have to use

 RLQ.push([ [], function () {
  mw.loader.using('mymodule');
 }); 

Otherwise mw.loader.using won't be defined as the anonymous function is
executed instantly (why mw.using.loader is not available globally yet at
this time I dont know for sure).
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

[Wikitech-l] resource loader; 1.32 alpha; 1.32 stable breaking change loading scripts in widgets

2019-04-04 Thread Tom Schulze
dear all,

i experienced breaking changes when loading scripts in the widgets
extension through the resource loader. please check the gitlab snippet
[1] i created. i did not find any documentation and checked the
migration guide [2].

is the code presented in the gitlab snippet good practice? could anyone
point me to existing documentation?

thank you!

tom

[1] https://gitlab.com/snippets/1843172

[2]
https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)#MediaWiki_1.32_(TBA)



___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

[Wikitech-l] Escaping wikitext to JSON-valid string in templates

2018-06-11 Thread Tom Schulze

Hello everyone,

I am having trouble escaping and displaying wikitext in a way that is 
JSON-safe. I did some research but none of the provided 
MagicWords/ParserFUnctions/etc seem to be suited for this purpose. 
Please refer to my gitLab snippet  
to see the sample code of the query, template and widget.


My goal is to build up a structure like this using a widget (to load my 
custom JS), a cargo query and finally a template to display the items 
row by row:


Description
Description


The data is taken from a PageForms textarea form field (the user can 
enter any data she wants). This piece of HTML gets parsed by a custom 
Java Script on page load for further processing. As soon as characters 
like single (') or double quotes (") appear, the whole JSON string gets 
messed up and the JavaScript JSON parser throws errors. Even worse, the 
DOM structure becomes fragmented when single quotes appear. So 
client-side fixing w/ JavaScript is impossible/tedious.


Any solution is welcome, also restricting the types of characters used. 
Ideally, I would just need to wrap the parameter passed from the query 
to the template in some kind of Magic Word which escapes/strips out 
unwanted characters.


What options do I have ? I am open for different approaches...

Kind regards,

Tom

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

[Wikitech-l] function drawmap not defined when loading external js with resourceLoader

2018-06-04 Thread Tom Schulze

Hello everyone,

I have created a public gist 
 
with a minimal working example. I am trying to put JavaScript Code from 
a Widget to an external JS file and load it dynamically with the 
ResourceLoader. However, the developer console returns the following 
error: jQuery.Deferred exception: drawmap is not defined when I am 
accessing the function defined in the external script. Checking the 
state in the developer console with 
'mw.loader.getState("ext.iswiki.display_project_map")' returns: "ready".


When the Resource Loader debug mode is enabled in LocalSettings.php the 
function is found and called.


What am I doing wrong?

Kind regards,

Tom

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l