Browse Source

Minor - Internal: fixes to CLI scripts about language checks

Yannick Warnier 6 years ago
parent
commit
efe7202181
2 changed files with 8 additions and 7 deletions
  1. 1 1
      main/cron/lang/check_parse_lang.php
  2. 7 6
      main/cron/lang/langstats.class.php

+ 1 - 1
main/cron/lang/check_parse_lang.php

@@ -27,7 +27,7 @@ foreach ($langs as $lang) {
             $out = [];
             if (is_file($file)) {
                 //$terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true));
-                @exec('php5 -l '.$file, $out);
+                @exec('php -l '.$file, $out);
                 if (substr($out[0], 0, 2) != 'No') {
                     echo $out[0]."\n";
                     $ok = false;

+ 7 - 6
main/cron/lang/langstats.class.php

@@ -14,12 +14,12 @@
  * goal of this DB is to get stats on the usage of language vars for a common
  * user. This class requires the SQLite extension of PHP to be installed. The
  * check for the availability of sqlite_open() should be made before calling
- * the constructor (preferrably).
+ * the constructor (preferably).
  */
 class langstats
 {
     public $db; //database connector
-    public $error; //errores almacenados
+    public $error; //stored errors
     public $db_type = 'sqlite';
 
     public function __construct($file = '')
@@ -97,7 +97,7 @@ class langstats
      * @param string The language term used
      * @param string The file from which the language term came from
      *
-     * @return bool true
+     * @return mixed
      */
     public function add_use($term, $term_file = '')
     {
@@ -114,6 +114,7 @@ class langstats
         while ($row = $ress->fetchArray(SQLITE3_BOTH)) {
             $num = $row[3];
             $num++;
+            $i++;
             $res = $this->db->query(
                 'UPDATE lang_freq SET term_count = '.$num.' WHERE id = '.$row[0]
             );
@@ -124,7 +125,6 @@ class langstats
             } else {
                 return $row[0];
             }
-            $i++;
         }
         if ($i == 0) {
             //No term found in the table, register as new term
@@ -139,6 +139,7 @@ class langstats
                 return $this->db->lastInsertRowID();
             }
         }
+        return true;
     }
 
     /**
@@ -164,13 +165,13 @@ class langstats
     /**
      * Clear all records in lang_freq.
      *
-     * @return bool true
+     * @return resource true
      */
     public function clear_all()
     {
         $res = sqlite_query($this->db, 'DELETE FROM lang_freq WHERE 1=1');
 
-        return $list;
+        return $res;
     }
 
     /**