Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fixMultipleAliveRevision.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 include_once ('FDL/freedom_util.php');
8 
9 $usage = new ApiUsage();
10 $usage->setDefinitionText("Fixed multiple alive revision problem");
11 $usage->verify();
12 
13 global $action;
14 $dbaccess = $action->dbaccess;
15 if ($dbaccess == "") {
16  error_log("Freedom Database not found : action->dbaccess");
17  exit(1);
18 }
19 
20 $multipleList = array();
21 $sql = "SELECT m AS id, z.initid AS initid FROM (SELECT min(id) AS m, initid, count(initid) AS c FROM docread WHERE locked != -1 AND doctype != 'T' GROUP BY docread.initid) AS z where z.c > 1";
23 if ($err != "") {
24  error_log(sprintf("Error searching for multiple alive revision: %s", $err));
25  exit(1);
26 }
27 
28 foreach ($multipleList as $el) {
29  print sprintf("Fixing mutiple alive revision for (initid='%s', id='%s')\n", $el['initid'], $el['id']);
30  $res = array();
31  $sql = sprintf("UPDATE doc SET locked = -1 WHERE initid = %s AND id = %s AND locked != -1 AND doctype != 'T'", pg_escape_string($el['initid']) , pg_escape_string($el['id']));
32  $err = simpleQuery($dbaccess, $sql, $res);
33  if ($err != "") {
34  error_log(sprintf("Error fixing multiple alive revision for (initid='%s', id='%s'): %s", $el['initid'], $el['id'], $err));
35  exit(1);
36  }
37 }
38 
39 exit(0);
print
Definition: checklist.php:49
switch($command) exit
Definition: checkVault.php:46
global $action
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
Definition: Lib.Common.php:484
if($dbaccess=="") $multipleList
Verify arguments for wsh programs.
← centre documentaire © anakeen