SF.net SVN: phpwiki:[10715] trunk

vargenau--- via phpwiki-checkins <[email protected]>
Newsgroups gmane.comp.web.wiki.phpwiki.checkins
Message-ID <[email protected]>
Revision: 10715
          http://sourceforge.net/p/phpwiki/code/10715
Author:   vargenau
Date:     2021-11-30 18:18:01 +0000 (Tue, 30 Nov 2021)
Log Message:
-----------
FileInfo plugin: posix_getpwuid() and posix_getgrgid() functions are not available by default on CentOS 7

Modified Paths:
--------------
    trunk/INSTALL
    trunk/lib/plugin/FileInfo.php

Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL	2021-11-30 17:50:13 UTC (rev 10714)
+++ trunk/INSTALL	2021-11-30 18:18:01 UTC (rev 10715)
@@ -79,6 +79,10 @@
 or
 apt install php-soap
 
+FileInfo plugin requires posix_getpwuid() and posix_getgrgid() functions
+that are not available by default on CentOS 7. You might need to do:
+yum install php-process
+
 QUICK START INSTRUCTIONS
 
 Copy 'config/config-dist.ini' to 'config/config.ini' and edit the

Modified: trunk/lib/plugin/FileInfo.php
===================================================================
--- trunk/lib/plugin/FileInfo.php	2021-11-30 17:50:13 UTC (rev 10714)
+++ trunk/lib/plugin/FileInfo.php	2021-11-30 18:18:01 UTC (rev 10715)
@@ -35,6 +35,23 @@
  * @author: Reini Urban
  */
 
+// posix_getpwuid() and posix_getgrgid() are not impremented in CentOS 7
+// you need to do:
+// yum install php-process
+if (!function_exists('posix_getpwuid')) {
+    function posix_getpwuid()
+    {
+        return false;
+    }
+}
+
+if (!function_exists('posix_getgrgid')) {
+    function posix_getgrgid()
+    {
+        return false;
+    }
+}
+
 class WikiPlugin_FileInfo
     extends WikiPlugin
 {
@@ -121,11 +138,19 @@
                     break;
                 case 'owner':
                     $o = posix_getpwuid(fileowner($file));
-                    $s[] = $o['name'];
+                    if ($o === false) {
+                        $s[] = 'not implemented';
+                    } else {
+                        $s[] = $o['name'];
+                    }
                     break;
                 case 'group':
                     $o = posix_getgrgid(filegroup($file));
-                    $s[] = $o['name'];
+                    if ($o === false) {
+                        $s[] = 'not implemented';
+                    } else {
+                        $s[] = $o['name'];
+                    }
                     break;
                 case 'name':
                     $s[] = basename($file);

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.