[Mapbender-commits] r10316 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Nov 5 21:07:19 PST 2019
Author: armin11
Date: 2019-11-05 21:07:18 -0800 (Tue, 05 Nov 2019)
New Revision: 10316
Modified:
trunk/mapbender/http/classes/class_mb_log.php
Log:
Workaround to suppress blocking of mapbender error log files, if the php script was invoked from cli by another user - e.g. by cronjobs. now all the logs will be echo'd in such a case!
Modified: trunk/mapbender/http/classes/class_mb_log.php
===================================================================
--- trunk/mapbender/http/classes/class_mb_log.php 2019-11-05 12:42:08 UTC (rev 10315)
+++ trunk/mapbender/http/classes/class_mb_log.php 2019-11-06 05:07:18 UTC (rev 10316)
@@ -68,31 +68,38 @@
break;
}
}
- if (is_dir($this->dir)) {
- $logfile = $this->dir . $this->filename_prefix . date("Y_m_d") . ".log";
- if ($h = fopen($logfile,"a")) {
- $content = date("Y.m.d, H:i:s") . "," . $callerinfo . $n .chr(13).chr(10);
- if(!fwrite($h,$content)){
+ if (php_sapi_name() === 'cli' OR defined('STDIN')) {
+ $content = date("Y.m.d, H:i:s") . "," . $callerinfo . $n .chr(13).chr(10);
+ echo $content;
+ $this->result = true;
+ $this->message = "Successful. Invoked from cli - error is echod!";
+ } else {
+ if (is_dir($this->dir)) {
+ $logfile = $this->dir . $this->filename_prefix . date("Y_m_d") . ".log";
+ if ($h = fopen($logfile,"a")) {
+ $content = date("Y.m.d, H:i:s") . "," . $callerinfo . $n .chr(13).chr(10);
+ if(!fwrite($h,$content)){
+ $this->result = false;
+ $this->message = "Unable to write " . $logfile;
+ return false;
+ }
+ fclose($h);
+ $this->result = true;
+ $this->message = "Successful.";
+ return true;
+ }
+ else {
$this->result = false;
- $this->message = "Unable to write " . $logfile;
+ $this->message = "Unable to open or generate " . $logfile;
return false;
}
- fclose($h);
- $this->result = true;
- $this->message = "Successful.";
- return true;
}
else {
$this->result = false;
- $this->message = "Unable to open or generate " . $logfile;
+ $this->message = "Directory " . $this->dir . " is not valid.";
return false;
}
}
- else {
- $this->result = false;
- $this->message = "Directory " . $this->dir . " is not valid.";
- return false;
- }
}
else {
$this->result = false;
@@ -187,4 +194,4 @@
*/
public $message = "";
}
-?>
\ No newline at end of file
+?>
More information about the Mapbender_commits
mailing list