]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/backend/PearDB.php
Cleanup to get rid of PHP warning.
[SourceForge/phpwiki.git] / lib / WikiDB / backend / PearDB.php
1 <?php // -*-php-*-
2 rcs_id('$Id: PearDB.php,v 1.7 2001-10-29 17:57:24 dairiki Exp $');
3
4 //require_once('DB.php');
5 require_once('lib/WikiDB/backend.php');
6 require_once('lib/FileFinder.php');
7 require_once('lib/ErrorManager.php');
8
9 class WikiDB_backend_PearDB
10 extends WikiDB_backend
11 {
12     function WikiDB_backend_PearDB ($dbparams) {
13         // Find and include PEAR's DB.php.
14         $pearFinder = new PearFileFinder;
15         $pearFinder->includeOnce('DB.php');
16
17         // Install filter to handle bogus error notices from buggy DB.php's.
18         global $ErrorManager;
19         $ErrorManager->pushErrorHandler(array($this, '_pear_notice_filter'));
20         
21         // Open connection to database
22         $dsn = $dbparams['dsn'];
23         $this->_dbh = DB::connect($dsn, true); //FIXME: true -> persistent connection
24         $dbh = &$this->_dbh;
25         if (DB::isError($dbh)) {
26             trigger_error("Can't connect to database: "
27                           . $this->_pear_error_message($dbh),
28                           E_USER_ERROR);
29         }
30         $dbh->setErrorHandling(PEAR_ERROR_CALLBACK,
31                                array($this, '_pear_error_callback'));
32         $dbh->setFetchMode(DB_FETCHMODE_ASSOC);
33
34         $prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : '';
35
36         $this->_table_names
37             = array('page_tbl'     => $prefix . 'page',
38                     'version_tbl'  => $prefix . 'version',
39                     'link_tbl'     => $prefix . 'link',
40                     'recent_tbl'   => $prefix . 'recent',
41                     'nonempty_tbl' => $prefix . 'nonempty');
42
43         $this->_lock_count = 0;
44     }
45     
46     /**
47      * Close database connection.
48      */
49     function close () {
50         if (!$this->_dbh)
51             return;
52         if ($this->_lock_count) {
53             trigger_error("WARNING: database still locked"
54                           . " (lock_count = $this->_lock_count)\n<br>",
55                           E_USER_WARNING);
56         }
57         $this->_dbh->setErrorHandling(PEAR_ERROR_PRINT);        // prevent recursive loops.
58         $this->unlock('force');
59
60         $this->_dbh->disconnect();
61         $this->_dbh = false;
62     }
63
64
65     /*
66      * Test fast wikipage.
67      */
68     function is_wiki_page($pagename) {
69         $dbh = &$this->_dbh;
70         extract($this->_table_names);
71         return $dbh->getOne(sprintf("SELECT $page_tbl.id"
72                                     . " FROM $nonempty_tbl INNER JOIN $page_tbl USING(id)"
73                                     . " WHERE pagename='%s'",
74                                     $dbh->quoteString($pagename)));
75     }
76         
77     function get_all_pagenames() {
78         $dbh = &$this->_dbh;
79         extract($this->_table_names);
80         return $dbh->getCol("SELECT pagename"
81                             . " FROM $nonempty_tbl INNER JOIN $page_tbl USING(id)");
82     }
83             
84     /**
85      * Read page information from database.
86      */
87     function get_pagedata($pagename) {
88         $dbh = &$this->_dbh;
89         $page_tbl = $this->_table_names['page_tbl'];
90
91         //trigger_error("GET_PAGEDATA $pagename", E_USER_NOTICE);
92
93         $result = $dbh->getRow(sprintf("SELECT * FROM $page_tbl WHERE pagename='%s'",
94                                        $dbh->quoteString($pagename)),
95                                DB_FETCHMODE_ASSOC);
96         if (!$result)
97             return false;
98         return $this->_extract_page_data($result);
99     }
100
101     function  _extract_page_data(&$query_result) {
102         extract($query_result);
103         $data = empty($pagedata) ? array() : unserialize($pagedata);
104         $data['hits'] = $hits;
105         return $data;
106     }
107
108     function update_pagedata($pagename, $newdata) {
109         $dbh = &$this->_dbh;
110         $page_tbl = $this->_table_names['page_tbl'];
111
112         // Hits is the only thing we can update in a fast manner.
113         if (count($newdata) == 1 && isset($newdata['hits'])) {
114             // Note that this will fail silently if the page does not
115             // have a record in the page table.  Since it's just the
116             // hit count, who cares?
117             $dbh->query(sprintf("UPDATE $page_tbl SET hits=%d WHERE pagename='%s'",
118                                 $newdata['hits'], $dbh->quoteString($pagename)));
119             return;
120         }
121
122         $this->lock();
123         $data = $this->get_pagedata($pagename);
124         if (!$data) {
125             $data = array();
126             $this->_get_pageid($pagename, true); // Creates page record
127         }
128         
129         @$hits = (int)$data['hits'];
130         unset($data['hits']);
131
132         foreach ($newdata as $key => $val) {
133             if ($key == 'hits')
134                 $hits = (int)$val;
135             else if (empty($val))
136                 unset($data[$key]);
137             else
138                 $data[$key] = $val;
139         }
140
141         $dbh->query(sprintf("UPDATE $page_tbl"
142                             . " SET hits=%d, pagedata='%s'"
143                             . " WHERE pagename='%s'",
144                             $hits,
145                             $dbh->quoteString(serialize($data)),
146                             $dbh->quoteString($pagename)));
147
148         $this->unlock();
149     }
150
151     function _get_pageid($pagename, $create_if_missing = false) {
152         
153         $dbh = &$this->_dbh;
154         $page_tbl = $this->_table_names['page_tbl'];
155         
156         $query = sprintf("SELECT id FROM $page_tbl WHERE pagename='%s'",
157                          $dbh->quoteString($pagename));
158
159         if (!$create_if_missing)
160             return $dbh->getOne($query);
161
162         $this->lock();
163         $id = $dbh->getOne($query);
164         if (empty($id)) {
165             $max_id = $dbh->getOne("SELECT MAX(id) FROM $page_tbl");
166             $id = $max_id + 1;
167             $dbh->query(sprintf("INSERT INTO $page_tbl"
168                                 . " (id,pagename,hits)"
169                                 . " VALUES (%d,'%s',0)",
170                                 $id, $dbh->quoteString($pagename)));
171         }
172         $this->unlock();
173         return $id;
174     }
175
176     function get_latest_version($pagename) {
177         $dbh = &$this->_dbh;
178         extract($this->_table_names);
179         return
180             (int)$dbh->getOne(sprintf("SELECT latestversion"
181                                       . " FROM $page_tbl"
182                                       . "  INNER JOIN $recent_tbl USING(id)"
183                                       . " WHERE pagename='%s'",
184                                       $dbh->quoteString($pagename)));
185     }
186
187     function get_previous_version($pagename, $version) {
188         $dbh = &$this->_dbh;
189         extract($this->_table_names);
190         
191         return
192             (int)$dbh->getOne(sprintf("SELECT version"
193                                       . " FROM $version_tbl"
194                                       . "  INNER JOIN $page_tbl USING(id)"
195                                       . " WHERE pagename='%s'"
196                                       . "  AND version < %d"
197                                       . " ORDER BY version DESC"
198                                       . " LIMIT 1",
199                                       $dbh->quoteString($pagename),
200                                       $version));
201     }
202     
203     /**
204      * Get version data.
205      *
206      * @param $version int Which version to get.
207      *
208      * @return hash The version data, or false if specified version does not
209      *              exist.
210      */
211     function get_versiondata($pagename, $version, $want_content = false) {
212         $dbh = &$this->_dbh;
213         extract($this->_table_names);
214                 
215         assert(!empty($pagename));
216         assert($version > 0);
217         
218         //trigger_error("GET_REVISION $pagename $version $want_content", E_USER_NOTICE);
219         // FIXME: optimization: sometimes don't get page data?
220
221         if ($want_content) {
222             $fields = "*";
223         }
224         else {
225             $fields = ("$page_tbl.*,"
226                        . "mtime,minor_edit,versiondata,"
227                        . "content<>'' AS have_content");
228         }
229
230         $result = $dbh->getRow(sprintf("SELECT $fields"
231                                        . " FROM $page_tbl"
232                                        . "  INNER JOIN $version_tbl USING(id)"
233                                        . " WHERE pagename='%s' AND version=%d",
234                                        $dbh->quoteString($pagename), $version),
235                                DB_FETCHMODE_ASSOC);
236
237         return $this->_extract_version_data($result);
238     }
239
240     function _extract_version_data(&$query_result) {
241         if (!$query_result)
242             return false;
243
244         extract($query_result);
245         $data = empty($versiondata) ? array() : unserialize($versiondata);
246
247         $data['mtime'] = $mtime;
248         $data['is_minor_edit'] = !empty($minor_edit);
249         
250         if (isset($content))
251             $data['%content'] = $content;
252         elseif ($have_content)
253             $data['%content'] = true;
254         else
255             $data['%content'] = '';
256
257         // FIXME: this is ugly.
258         if (isset($pagename)) {
259             // Query also includes page data.
260             // We might as well send that back too...
261             $data['%pagedata'] = $this->_extract_page_data($query_result);
262         }
263
264         return $data;
265     }
266
267
268     /**
269      * Create a new revision of a page.
270      */
271     function set_versiondata($pagename, $version, $data) {
272         $dbh = &$this->_dbh;
273         $version_tbl = $this->_table_names['version_tbl'];
274         
275         $minor_edit = (int) !empty($data['is_minor_edit']);
276         unset($data['is_minor_edit']);
277         
278         $mtime = (int)$data['mtime'];
279         unset($data['mtime']);
280         assert(!empty($mtime));
281
282         @$content = (string) $data['%content'];
283         unset($data['%content']);
284
285         unset($data['%pagedata']);
286         
287         $this->lock();
288         $id = $this->_get_pageid($pagename, true);
289
290         // FIXME: optimize: mysql can do this with one REPLACE INTO (I think).
291         $dbh->query(sprintf("DELETE FROM $version_tbl"
292                             . " WHERE id=%d AND version=%d",
293                             $id, $version));
294
295         $dbh->query(sprintf("INSERT INTO $version_tbl"
296                             . " (id,version,mtime,minor_edit,content,versiondata)"
297                             . " VALUES(%d,%d,%d,%d,'%s','%s')",
298                             $id, $version, $mtime, $minor_edit,
299                             $dbh->quoteString($content),
300                             $dbh->quoteString(serialize($data))));
301
302         $this->_update_recent_table($id);
303         $this->_update_nonempty_table($id);
304         
305         $this->unlock();
306     }
307     
308     /**
309      * Delete an old revision of a page.
310      */
311     function delete_versiondata($pagename, $version) {
312         $dbh = &$this->_dbh;
313         extract($this->_table_names);
314
315         $this->lock();
316         if ( ($id = $this->_get_pageid($pagename)) ) {
317             $dbh->query("DELETE FROM $version_tbl"
318                         . " WHERE id=$id AND version=$version");
319             $this->_update_recent_table($id);
320             // This shouldn't be needed (as long as the latestversion
321             // never gets deleted.)  But, let's be safe.
322             $this->_update_nonempty_table($id);
323         }
324         $this->unlock();
325     }
326
327     /**
328      * Delete page from the database.
329      */
330     function delete_page($pagename) {
331         $dbh = &$this->_dbh;
332         extract($this->_table_names);
333         
334         $this->lock();
335         if ( ($id = $this->_get_pageid($pagename, 'id')) ) {
336             $dbh->query("DELETE FROM $version_tbl  WHERE id=$id");
337             $dbh->query("DELETE FROM $recent_tbl   WHERE id=$id");
338             $dbh->query("DELETE FROM $nonempty_tbl WHERE id=$id");
339             $dbh->query("DELETE FROM $link_tbl     WHERE linkfrom=$id");
340             $nlinks = $dbh->getOne("SELECT COUNT(*) FROM $link_tbl WHERE linkto=$id");
341             if ($nlinks) {
342                 // We're still in the link table (dangling link) so we can't delete this
343                 // altogether.
344                 $dbh->query("UPDATE $page_tbl SET hits=0, pagedata='' WHERE id=$id");
345             }
346             else {
347                 $dbh->query("DELETE FROM $page_tbl WHERE id=$id");
348             }
349             $this->_update_recent_table();
350             $this->_update_nonempty_table();
351         }
352         $this->unlock();
353     }
354             
355
356     // The only thing we might be interested in updating which we can
357     // do fast in the flags (minor_edit).   I think the default
358     // update_versiondata will work fine...
359     //function update_versiondata($pagename, $version, $data) {
360     //}
361
362     function set_links($pagename, $links) {
363         // Update link table.
364         // FIXME: optimize: mysql can do this all in one big INSERT.
365
366         $dbh = &$this->_dbh;
367         extract($this->_table_names);
368
369         $this->lock();
370         $pageid = $this->_get_pageid($pagename, true);
371
372         $dbh->query("DELETE FROM $link_tbl WHERE linkfrom=$pageid");
373
374         if ($links) {
375             foreach($links as $link) {
376                 if (isset($linkseen[$link]))
377                     continue;
378                 $linkseen[$link] = true;
379                 $linkid = $this->_get_pageid($link, true);
380                 $dbh->query("INSERT INTO $link_tbl (linkfrom, linkto)"
381                             . " VALUES ($pageid, $linkid)");
382             }
383         }
384         $this->unlock();
385     }
386     
387     /**
388      * Find pages which link to or are linked from a page.
389      */
390     function get_links($pagename, $reversed = true) {
391         $dbh = &$this->_dbh;
392         extract($this->_table_names);
393
394         if ($reversed)
395             list($have,$want) = array('linkee', 'linker');
396         else
397             list($have,$want) = array('linker', 'linkee');
398
399         $qpagename = $dbh->quoteString($pagename);
400         
401         $result = $dbh->query("SELECT $want.*"
402                               . " FROM $link_tbl"
403                               . "  INNER JOIN $page_tbl AS linker ON linkfrom=linker.id"
404                               . "  INNER JOIN $page_tbl AS linkee ON linkto=linkee.id"
405                               . " WHERE $have.pagename='$qpagename'"
406                               //. " GROUP BY $want.id"
407                               . " ORDER BY $want.pagename",
408                               DB_FETCHMODE_ASSOC);
409         
410         return new WikiDB_backend_PearDB_iter($this, $result);
411     }
412
413     function get_all_pages($include_deleted) {
414         $dbh = &$this->_dbh;
415         extract($this->_table_names);
416
417         if ($include_deleted) {
418             $result = $dbh->query("SELECT * FROM $page_tbl ORDER BY pagename");
419         }
420         else {
421             $result = $dbh->query("SELECT $page_tbl.*"
422                                   . " FROM $nonempty_tbl INNER JOIN $page_tbl USING(id)"
423                                   . " ORDER BY pagename");
424         }
425
426         return new WikiDB_backend_PearDB_iter($this, $result);
427     }
428         
429     /**
430      * Title search.
431      */
432     function text_search($search = '', $fullsearch = false) {
433         $dbh = &$this->_dbh;
434         extract($this->_table_names);
435         
436         $table = "$nonempty_tbl INNER JOIN $page_tbl USING(id)";
437         $fields = "$page_tbl.*";
438         $callback = '_sql_match_clause';
439         
440         if ($fullsearch) {
441             $table .= (" INNER JOIN $recent_tbl ON $page_tbl.id=$recent_tbl.id"
442                        . " INNER JOIN $version_tbl"
443                        . "   ON $page_tbl.id=$version_tbl.id"
444                        . "   AND latestversion=version" );
445             $fields .= ",$version_tbl.*";
446             $callback = '_fullsearch_sql_match_clause';
447         }
448
449         
450         $search_clause = $search->makeSqlClause(array($this, $callback));
451         
452         $result = $dbh->query("SELECT $fields FROM $table"
453                               . " WHERE $search_clause"
454                               . " ORDER BY pagename");
455         
456         return new WikiDB_backend_PearDB_iter($this, $result);
457     }
458
459     function _sql_match_clause($word) {
460         $word = $this->_dbh->quoteString($word);
461         return "LOWER(pagename) LIKE '%$word%'";
462     }
463
464     function _fullsearch_sql_match_clause($word) {
465         $word = $this->_dbh->quoteString($word);
466         return "LOWER(pagename) LIKE '%$word%' OR content LIKE '%$word%'";
467     }
468
469     /**
470      * Find highest hit counts.
471      */
472     function most_popular($limit) {
473         $dbh = &$this->_dbh;
474         extract($this->_table_names);
475
476         $limitclause = $limit ? " LIMIT $limit" : '';
477         $result = $dbh->query("SELECT $page_tbl.*"
478                               . " FROM $nonempty_tbl INNER JOIN $page_tbl USING(id)"
479                               . " ORDER BY hits DESC"
480                               . " $limitclause");
481
482         return new WikiDB_backend_PearDB_iter($this, $result);
483     }
484
485     /**
486      * Find recent changes.
487      */
488     function most_recent($params) {
489         $limit = 0;
490         $since = 0;
491         $include_minor_revisions = false;
492         $exclude_major_revisions = false;
493         $include_all_revisions = false;
494         extract($params);
495
496         $dbh = &$this->_dbh;
497         extract($this->_table_names);
498
499         $pick = array();
500         if ($since)
501             $pick[] = "mtime >= $since";
502         
503         if ($include_all_revisions) {
504             // Include all revisions of each page.
505             $table = "$page_tbl INNER JOIN $version_tbl USING(id)";
506
507             if ($exclude_major_revisions) {
508                 // Include only minor revisions
509                 $pick[] = "minor_edit <> 0";
510             }
511             elseif (!$include_minor_revisions) {
512                 // Include only major revisions
513                 $pick[] = "minor_edit = 0";
514             }
515         }
516         else {
517             $table = ( "$page_tbl INNER JOIN $recent_tbl USING(id)"
518                        . " INNER JOIN $version_tbl ON $version_tbl.id=$page_tbl.id");
519                 
520             if ($exclude_major_revisions) {
521                 // Include only most recent minor revision
522                 $pick[] = 'version=latestminor';
523             }
524             elseif (!$include_minor_revisions) {
525                 // Include only most recent major revision
526                 $pick[] = 'version=latestmajor';
527             }
528             else {
529                 // Include only the latest revision (whether major or minor).
530                 $pick[] ='version=latestversion';
531             }
532         }
533
534         $limitclause = $limit ? " LIMIT $limit" : '';
535         $whereclause = $pick ? " WHERE " . join(" AND ", $pick) : '';
536
537         // FIXME: use SQL_BUFFER_RESULT for mysql?
538         $result = $dbh->query("SELECT $page_tbl.*,$version_tbl.*"
539                               . " FROM $table"
540                               . $whereclause
541                               . " ORDER BY mtime DESC"
542                               . $limitclause);
543
544         return new WikiDB_backend_PearDB_iter($this, $result);
545     }
546
547     function _update_recent_table($pageid = false) {
548         $dbh = &$this->_dbh;
549         extract($this->_table_names);
550
551         $maxmajor = "MAX(CASE WHEN minor_edit=0 THEN version END)";
552         $maxminor = "MAX(CASE WHEN minor_edit<>0 THEN version END)";
553         $maxversion = "MAX(version)";
554
555         $pageid = (int)$pageid;
556
557         $this->lock();
558
559         $dbh->query("DELETE FROM $recent_tbl"
560                     . ( $pageid ? " WHERE id=$pageid" : ""));
561         
562         $dbh->query( "INSERT INTO $recent_tbl"
563                      . " (id, latestversion, latestmajor, latestminor)"
564                      . " SELECT id, $maxversion, $maxmajor, $maxminor"
565                      . " FROM $version_tbl"
566                      . ( $pageid ? " WHERE id=$pageid" : "")
567                      . " GROUP BY id" );
568         $this->unlock();
569     }
570
571     function _update_nonempty_table($pageid = false) {
572         $dbh = &$this->_dbh;
573         extract($this->_table_names);
574
575         $pageid = (int)$pageid;
576
577         $this->lock();
578
579         $dbh->query("DELETE FROM $nonempty_tbl"
580                     . ( $pageid ? " WHERE id=$pageid" : ""));
581
582         $dbh->query("INSERT INTO $nonempty_tbl (id)"
583                     . " SELECT $recent_tbl.id"
584                     . " FROM $recent_tbl INNER JOIN $version_tbl"
585                     . "               ON $recent_tbl.id=$version_tbl.id"
586                     . "                  AND version=latestversion"
587                     . "  WHERE content<>''"
588                     . ( $pageid ? " AND $recent_tbl.id=$pageid" : ""));
589
590         $this->unlock();
591     }
592
593
594     /**
595      * Grab a write lock on the tables in the SQL database.
596      *
597      * Calls can be nested.  The tables won't be unlocked until
598      * _unlock_database() is called as many times as _lock_database().
599      *
600      * @access protected
601      */
602     function lock($write_lock = true) {
603         if ($this->_lock_count++ == 0)
604             $this->_lock_tables($write_lock);
605     }
606
607     /**
608      * Actually lock the required tables.
609      */
610     function _lock_tables($write_lock) {
611         trigger_error("virtual", E_USER_ERROR);
612     }
613     
614     /**
615      * Release a write lock on the tables in the SQL database.
616      *
617      * @access protected
618      *
619      * @param $force boolean Unlock even if not every call to lock() has been matched
620      * by a call to unlock().
621      *
622      * @see _lock_database
623      */
624     function unlock($force = false) {
625         if ($this->_lock_count == 0)
626             return;
627         if (--$this->_lock_count <= 0 || $force) {
628             $this->_unlock_tables();
629             $this->_lock_count = 0;
630         }
631     }
632
633     /**
634      * Actually unlock the required tables.
635      */
636     function _unlock_tables($write_lock) {
637         trigger_error("virtual", E_USER_ERROR);
638     }
639     
640     /**
641      * Callback for PEAR (DB) errors.
642      *
643      * @access protected
644      *
645      * @param A PEAR_error object.
646      */
647     function _pear_error_callback($error) {
648         if ($this->_is_false_error($error))
649             return;
650         
651         $this->_dbh->setErrorHandling(PEAR_ERROR_PRINT);        // prevent recursive loops.
652         $this->close();
653         trigger_error($this->_pear_error_message($error), E_USER_ERROR);
654     }
655
656     /**
657      * Detect false errors messages from PEAR DB.
658      *
659      * The version of PEAR DB which ships with PHP 4.0.6 has a bug in that
660      * it doesn't recognize "LOCK" and "UNLOCK" as SQL commands which don't
661      * return any data.  (So when a "LOCK" command doesn't return any data,
662      * DB reports it as an error, when in fact, it's not.)
663      *
664      * @access private
665      * @return bool True iff error is not really an error.
666      */
667     function _is_false_error($error) {
668         $code = $error->getCode();
669         $query = $this->_dbh->last_query;
670         return ($code == DB_ERROR
671                 && ! DB::isManip($query)
672                 && preg_match('/^\s*"?(LOCK|UNLOCK)\s/', $query));
673     }
674
675     function _pear_error_message($error) {
676         $class = get_class($this);
677         $message = "$class: fatal database error\n"
678              . "\t" . $error->getMessage() . "\n"
679              . "\t(" . $error->getDebugInfo() . ")\n";
680
681         return $message;
682     }
683
684     /**
685      * Filter PHP errors notices from PEAR DB code.
686      *
687      * The PEAR DB code which ships with PHP 4.0.6 produces spurious
688      * errors and notices.  This is an error callback (for use with
689      * ErrorManager which will filter out those spurious messages.)
690      * @see _is_false_error, ErrorManager
691      * @access private
692      */
693     function _pear_notice_filter($err) {
694         return ( $err->isNotice()
695                  && preg_match('|DB[/\\\\]common.php$|', $err->errfile)
696                  && $err->errline == 126
697                  && preg_match('/Undefined offset: +0\b/', $err->errstr) );
698     }
699 };
700
701 class WikiDB_backend_PearDB_iter
702 extends WikiDB_backend_iterator
703 {
704     function WikiDB_backend_PearDB_iter(&$backend, &$query_result) {
705         if (DB::isError($query_result)) {
706             // This shouldn't happen, I thought.
707             $backend->_pear_error_callback($query_result);
708         }
709         
710         $this->_backend = &$backend;
711         $this->_result = $query_result;
712     }
713     
714     function next() {
715         $backend = &$this->_backend;
716         if (!$this->_result)
717             return false;
718
719         $record = $this->_result->fetchRow(DB_FETCHMODE_ASSOC);
720         if (!$record) {
721             $this->free();
722             return false;
723         }
724         
725         $pagedata = $backend->_extract_page_data($record);
726         $rec = array('pagename' => $record['pagename'],
727                      'pagedata' => $pagedata);
728
729         if (!empty($record['version'])) {
730             $rec['versiondata'] = $backend->_extract_version_data($record);
731             $rec['version'] = $record['version'];
732         }
733         
734         return $rec;
735     }
736
737     function free () {
738         if ($this->_result) {
739             $this->_result->free();
740             $this->_result = false;
741         }
742     }
743 }
744
745 // (c-file-style: "gnu")
746 // Local Variables:
747 // mode: php
748 // tab-width: 8
749 // c-basic-offset: 4
750 // c-hanging-comment-ender-p: nil
751 // indent-tabs-mode: nil
752 // End:   
753 ?>