mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merged MDL-13717 Applied hack from Nicklas to fix sitemp etc. It worked for me in a quick test.
This commit is contained in:
parent
a487c55b03
commit
f76fa797eb
@ -176,50 +176,52 @@ function ewiki_database_moodle($action, &$args, $sw1, $sw2) {
|
||||
}
|
||||
break;
|
||||
|
||||
/* Returns an array of __all__ pages, where each entry is made up
|
||||
of the fields from the database requested with the $args array,
|
||||
e.g. array("flags","meta","lastmodified");
|
||||
/* Returns an array of the lastest versions of __all__ pages,
|
||||
where each entry is made up of the fields from the database
|
||||
requested with the $args array, e.g.
|
||||
array("flags","meta","lastmodified");
|
||||
*/
|
||||
case "GETALL":
|
||||
switch ($CFG->dbfamily) {
|
||||
case 'postgres':
|
||||
$sql= "SELECT pagename AS id, ".
|
||||
// All but the latest version eliminated by DISTINCT
|
||||
// ON (pagename)
|
||||
$sql= "SELECT DISTINCT ON (pagename) pagename AS id, ".
|
||||
implode(", ", $args) .
|
||||
" FROM ". $CFG->prefix.EWIKI_DB_TABLE_NAME .
|
||||
" WHERE wiki = ".$wiki_entry->id.
|
||||
" GROUP BY pagename, ".implode(", ", $args);
|
||||
" ORDER BY pagename, version DESC";
|
||||
break;
|
||||
default:
|
||||
case 'mysql':
|
||||
// All but the latest version eliminated by
|
||||
// mysql-specific GROUP BY-semantics
|
||||
$sql= "SELECT pagename AS id, ".
|
||||
implode(", ", $args) .
|
||||
" FROM ". $CFG->prefix.EWIKI_DB_TABLE_NAME .
|
||||
" WHERE wiki = ".$wiki_entry->id.
|
||||
" GROUP BY id, version " ;
|
||||
" GROUP BY id, version DESC " ;
|
||||
default:
|
||||
// All but the latest version are here eliminated in
|
||||
// get_records_sql, since it will return an array
|
||||
// with only one result per id-field value. Note,
|
||||
// that for this to work the query needs to order the
|
||||
// records ascending by version, so later versions
|
||||
// will overwrite previous ones in
|
||||
// recordset_to_array. This is not pretty.
|
||||
$sql= "SELECT pagename AS id, ".
|
||||
implode(", ", $args) .
|
||||
" FROM ". $CFG->prefix.EWIKI_DB_TABLE_NAME .
|
||||
" WHERE wiki = ".$wiki_entry->id.
|
||||
" ORDER BY version";
|
||||
}
|
||||
|
||||
#print "$sql";
|
||||
$result=get_records_sql($sql);
|
||||
$r = new ewiki_dbquery_result($args);
|
||||
|
||||
$drop = "";
|
||||
#while ($result && ($row = mysql_fetch_array($result, MYSQL_ASSOC))) {
|
||||
# $i = EWIKI_CASE_INSENSITIVE ? strtolower($row["id"]) : $row["id"];
|
||||
# if ($i != $drop) {
|
||||
# $drop = $i;
|
||||
# $r->add($row);
|
||||
# }
|
||||
#}
|
||||
#print "<pre>"; print_r($result); print "</pre>";
|
||||
if(!$result) {
|
||||
$result=array();
|
||||
}
|
||||
while(list($key, $val) = each($result)) {
|
||||
$row=get_object_vars($val);
|
||||
$i = EWIKI_CASE_INSENSITIVE ? strtolower($row["id"]) : $row["id"];
|
||||
if ($i != $drop) {
|
||||
$drop = $i;
|
||||
$r->add($row);
|
||||
}
|
||||
if ($result) {
|
||||
foreach($result as $val) {
|
||||
$r->add(get_object_vars($val));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user