CC'ing to Wikitech-l. Some more review:
* The way NUMBEROFBOOKS is calculated (scanning the page namespace) is
not acceptable, performance-wise. It needs to work like
NUMBEROFPAGES, etc., with a site_stats row or similar.
* The allbooks-regex message might not be a great way of doing things:
** Since results will have to be stored in various ways, like the
count being stored in site_stats, it's probably not feasible to change
the regex used without running a maintenance script. A config option
might therefore be better.
** Directly inputting the regex into a query is VERY VERY BAD! It's
an immediate SQL injection attack. Also, it will cause the query to
break in the presence of things like single quotes. Use
Database::addQuotes() here.
* Generating AllBooks using a REGEXP query is . . . maybe not ideal,
altogether. Usually we have a flag in the table, for instance,
page_is_redirect. It might be okay given that you'd "just" be
scanning a few times as many rows, in the average case, and only for
views of a certain special page. But a flag would be nice.
* If you're using the Xml functions, you don't have to use
htmlspecialchars explicitly. It will double-escape the variable.
* Variable names that are in Italian are kind of funny, but not really
in accordance with our coding standards. :) $conta -> $count,
$numero -> $number
This is only a quick glance, mind you. I haven't actually tested it
and probably won't find the time to do so.
Overall, I'm not sure this is the best way to tackle the problem. Has
Wikibooks considered, for instance, having the books' "main pages" be
in the main namespace, and the various pages be in a namespace like
"Page"? Then the problem is partly solved right away: you can use
Special:AllPages set to the main namespace to get a list of books.
For NUMBEROFBOOKS, you just need PAGESINNAMESPACE to be enabled, which
is fairly feasible at some point if someone's willing to do a little
optimization work, since it's a generally-requested feature.
On Thu, Apr 17, 2008 at 5:33 PM, mike.lifeguard
<mike.lifeguard(a)gmail.com> wrote:
If you remember back in November we were asked what
would be on a technical
wishlist for Wikibooks. One of the things we said[2] we wanted was a way to
list all books & enumerate them (all *books* as opposed to all pages). Ramac
and Pietrodn have been working on an extension[2] which does this.
Darklama and I have taken an initial look at things, and Simetrical found
one error that has been corrected. Anyone who is technically-minded is
invited to review & test the code. Everyone else is invited to discuss
improvements.
The extension is documented at
mediawiki.org, but here's a quick overview
for the sake of convenience:
*Adds the {{NUMBEROFBOOKS}} variable
*Adds [[Special:AllBooks]], which lists all books in specified namespaces
*List books beginning at some prefix using ?offset=whatever
*The regex used to determine what is a book and what isn't is a system
message, so administrators may edit it, though the default should work for
most (all?) Wikibooks languages
After this much time with apparently no interest in developing anything for
Wikibooks it's exciting to finally see such active development on something
needed specifically for this project. Many thanks to Ramac and Pietrodn for
their work, and also those who have helped them along the way. Hopefully
this is the beginning of a trend, and more tools will be developed to
fulfill our wishlist!
-Mike.lifeguard
[1]
http://lists.wikimedia.org/pipermail/textbook-l/2007-November/001164.html
[2]
http://www.mediawiki.org/wiki/Extension:AllBooks
_______________________________________________
Textbook-l mailing list
Textbook-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/textbook-l