sync
authorjohn <john@roojs.com>
Tue, 2 Oct 2018 09:52:16 +0000 (17:52 +0800)
committerjohn <john@roojs.com>
Tue, 2 Oct 2018 09:52:16 +0000 (17:52 +0800)
UpdateDatabase.php
UpdateDatabase/VerifyExtensions.php

index fe6656e..70693bb 100644 (file)
@@ -157,7 +157,6 @@ class Pman_Core_UpdateDatabase extends Pman
     
     function get($args, $opts=array())
     {
-         
         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
    
         $this->checkSystem();
@@ -197,7 +196,14 @@ class Pman_Core_UpdateDatabase extends Pman
         echo "Checi options\n";
         $this->checkOpts($opts);
         
-          
+        $response = $this->curl("http://localhost{$this->local_base_url}/Core/UpdateDatabase/VerifyExtensions");
+        $json = json_decode($response, true);
+        
+        if(empty($json['data']) || $json['data'] != 'DONE'){
+            echo $response. "\n";
+            echo "Please install the above extensions and restart the apache.\n";
+            exit;
+        }
         
         // do this first, so the innodb change + utf8 fixes column max sizes
         
@@ -986,7 +992,6 @@ class Pman_Core_UpdateDatabase extends Pman
         }
         HTML_FlexyFramework::get()->generateDataobjectsCache(true);
         
-         
         $this->updateDataEnums();
         $this->updateDataGroups();
         $this->updateDataCompanies();
@@ -995,10 +1000,6 @@ class Pman_Core_UpdateDatabase extends Pman
         
         $c = DB_DataObject::Factory('I18n');
         $c->buildDB();
-         
-       
-        
-        
     }
     
     function fixMysqlInnodb()
index 6f54338..10763a5 100644 (file)
@@ -1,11 +1,54 @@
 <?php
 
-require_once 'Pman_Core_UpdateDatabase';
+require_once 'Pman.php';
 
-class VerifyExtensions extends Pman_Core_UpdateDatabase
+class Pman_Core_UpdateDatabase_VerifyExtensions extends Pman
 {
+    static $cli_opts = array(
+
+    );
+    
+    function getAuth()
+    {
+        return true;
+    }
+    
     function get($base, $opts = array())
     {
-        print_r($this->required_extensions);exit;
+        $extensions = $error = array();
+        
+        $ff = HTML_FlexyFramework::get();
+        
+        foreach($this->modulesList() as $m) {
+            
+            $fd = $ff->rootDir. "/Pman/$m/UpdateDatabase.php";
+            
+            if (!file_exists($fd)) {
+                continue;
+            }
+            require_once $fd;
+            $cls = new ReflectionClass('Pman_'. $m . '_UpdateDatabase');
+            $props = $cls->getDefaultProperties();
+            
+            if(!empty($props['required_extensions'])) {
+                $extensions = array_merge($extensions, $props['required_extensions']);
+            }
+        }
+        
+        foreach ($extensions as $e){
+            
+            if(extension_loaded($e)) {
+                continue;
+            }
+            
+            $error[] = "Error: Please install php extension: {$e}";
+        }
+        
+        if(!empty($error)) {
+            $this->jerr($error);
+        }
+        
+        $this->jok("DONE");
+        
     }
 }
\ No newline at end of file