Make GeSHi autoloading really work
[phorkie.git] / src / phorkie / SetupCheck.php
index c459e2af546d251c981fc9f0888dc525e9f53072..36d66c07328f9b952e897099d8c907c2a2b98892 100644 (file)
@@ -24,8 +24,9 @@ class SetupCheck
     {
         $cfg = $GLOBALS['phorkie']['cfg'];
         $this->writableDirs = array(
-            'gitdir' => $cfg['gitdir'],
-            'workdir' => $cfg['workdir'],
+            'gitdir'  => Tools::foldPath($cfg['gitdir']),
+            'workdir' => Tools::foldPath($cfg['workdir']),
+            'cachedir' => Tools::foldPath($cfg['cachedir']),
         );
         $this->elasticsearch = $cfg['elasticsearch'];
     }
@@ -39,17 +40,28 @@ class SetupCheck
         $sc->checkGit();
         $sc->checkDatabase();
         $sc->checkMimeTypeDetection();
+        $sc->checkRemoteForking();
 
         return $sc->messages;
     }
 
     public function checkConfigFiles()
     {
+        if (!isset($GLOBALS['phorkie']['cfgfiles'])
+            || count($GLOBALS['phorkie']['cfgfiles']) == 0
+        ) {
+            $this->info('No config files registered');
+            return;
+        }
+
         foreach ($GLOBALS['phorkie']['cfgfiles'] as $file => $loaded) {
             if ($loaded) {
-                $this->ok('Loaded config file: ' . $file);
+                $this->ok('Loaded config file: ' . Tools::foldPath($file));
             } else {
-                $this->info('Possible config file: ' . $file . ' (not loaded)');
+                $this->info(
+                    'Possible config file: ' . Tools::foldPath($file)
+                    . ' (not loaded)'
+                );
             }
         }
     }
@@ -62,7 +74,7 @@ class SetupCheck
             }
         }
 
-        if (!class_exists('geshi', true)) {
+        if (!class_exists('GeSHi', true)) {
             $geshi = stream_resolve_include_path(
                 $GLOBALS['phorkie']['cfg']['geshi']
             );
@@ -97,8 +109,9 @@ class SetupCheck
         if ($retval !== 0) {
             $this->fail('Running git executable failed.');
         }
-        if (!preg_match('#^git version ([0-9.]+(rc[0-9]+)?)$#', $line, $matches)) {
+        if (!preg_match('#^git version ([0-9.]+(rc[0-9]+)?)(?: \(Apple Git-\d+\))?$#', $line, $matches)) {
             $this->fail('git version output format unexpected: ' . $line);
+            return;
         }
         if (version_compare($matches[1], '1.7.5') < 0) {
             $this->fail(
@@ -128,8 +141,25 @@ class SetupCheck
     public function checkMimeTypeDetection()
     {
         $rp = new Repository_Post();
-        if ($rp->getType('<?php echo "foo"; ?>') != 'php') {
-            $this->fail('MIME type detection fails');
+        $type = $rp->getType('<?php echo "foo"; ?>', true);
+        if ($type != 'php') {
+            $msg = 'MIME type detection fails';
+            if ($type instanceof \PEAR_Error) {
+                $msg .= '. Error: ' . $type->getMessage();
+            }
+            $this->fail($msg);
+        }
+    }
+
+    public function checkRemoteForking()
+    {
+        if (!isset($GLOBALS['phorkie']['cfg']['git']['public'])
+            || $GLOBALS['phorkie']['cfg']['git']['public'] == ''
+        ) {
+            $this->fail(
+                'No public git URL prefix configured.'
+                . ' Remote forking will not work'
+            );
         }
     }