Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Wikitech

Questions: parser functions, article caching

 

 

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded


questpc at rambler

Oct 23, 2009, 12:04 AM

Post #1 of 2 (226 views)
Permalink
Questions: parser functions, article caching

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[at]lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


roan.kattouw at gmail

Oct 23, 2009, 12:12 AM

Post #2 of 2 (201 views)
Permalink
Re: Questions: parser functions, article caching [In reply to]

2009/10/23 Dmitriy Sintsov <questpc[at]rambler.ru>:
> 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?).
I think purging after the submission of the poll would probably be
good enough, so you wouldn't need disableCache().

Roan Kattouw (Catrope)

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

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.