Hi!
I've made significant cleanup and restructurization of my extension's 
code that I'd like to submit to SVN. Before trying to submit my 
extension, I'd like to ask two important questions related to Parser and 
Article cache.

1. I've implemented my own parser function. The description of function 
is located at the following page:
http://www.mediawiki.org/wiki/Extension:QPoll#qpuserchoice_parser_function

The source code class qp_FunctionsHook is located in 'qp_user.php' file 
inside tgz archive:
http://mediawiki.narod.ru/QPoll_0.6.0.tgz
(if the one cares to take a quick look)

The function seems to work: it returns a string when #qpuserchoice 
function parameters are correct, or
returns an array( 0=>'<span class="error">qpuserchoice: ' . wfMsgHTML( 
'qp_func_' . $this->error_message, htmlspecialchars( $this->pollAddr ), 
htmlspecialchars( $this->question_id ), htmlspecialchars( 
$this->proposal_id ) ) . '</span>', 'isHTML'=>true );
in case of error.

I've recieved a bug report from extension user who complained that 
#iferror check on my function fails. Quick test shows that is true:
* {{#expr: 1 + 1 }} *** displays correct result
* {{#iferror: {{#expr: 1 + 1 }} | error | correct }}   *** #iferror 
returns correct
* {{#expr: 1 + X }} *** displays error message
* {{#iferror: {{#expr: 1 + X }} | error | correct }}  *** #iferror 
returns error
* {{#qpuserchoice: #almaz1}}  *** displays error message (not enough 
function parameters given)
* {{#iferror: {{#qpuserchoice: #almaz1}} | error | correct }} *** 
#iferror returns correct - though there should be an error !!!
* {{#qpuserchoice: #almaz1|3|2}} *** displays correct result (when the 
poll was previousely defined and submitted)
* {{#iferror: {{#qpuserchoice: #almaz1|3|2}} | error | correct }} *** 
#iferror returns correct

(I know that ParserFunctions returns '<strong class="error">', instead 
of span - I've tried that with no change)

When checking for #iferror implementation (in 
'extensions/ParserFunctions/ParserFunctions.php'), the method iferror( 
&$parser, $test = '', $then = '', $else = false ) recieves correct $test 
parameter values from "erroneous" #expr function:
string (105) "<strong class="error">Ошибка выражения: неопознанное слово 
«x»</strong>"
("ru" locale wiki)

but an incorrect value from "erroneous" #qpuserchoice function:
string(33) "UNIQ2c0ad9e32fb631-item-1--QINU"

Positive results are correct strings for both functions, so the problem 
is with error generation.

2. My extension generates dynamical content. Because of that, I use 
$parser->disableCache() in my tag parser hook. But, the dynamical 
content is being changed only in two cases:

a) The user edits the page. In such case, disableCache() is not 
required, because Article cache should be properly flushed by core.

b) The user submits the poll. After the processing of POST data I 
redirect with 302. In such case, which is the best way to conditionally 
flush the cache - will parser->disableCache() work after the POST and 
before the 302? To me it looks that it won't have an effect on the next 
GET after the redirect. Or, I'd better use Article::doPurge() (or, that 
is too slow?).
Dmitriy

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

Reply via email to