]> git.joonet.de Git - adminer.git/commitdiff
Allow using number_type() as pattern
authorJakub Vrana <jakub@vrana.cz>
Tue, 6 Feb 2018 13:52:12 +0000 (14:52 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 6 Feb 2018 13:52:12 +0000 (14:52 +0100)
adminer/include/adminer.inc.php
adminer/include/editing.inc.php
adminer/include/functions.inc.php
editor/include/adminer.inc.php

index 6b82bc0ba88c7896d2485b3019d5a7ceb4c2493f..44dae5c94b8f2b1b95b795d766e92b0c106daf11 100644 (file)
@@ -820,7 +820,7 @@ class Adminer {
                                                foreach ($row as $key => $val) {
                                                        $field = $fields[$key];
                                                        $row[$key] = ($val !== null
-                                                               ? unconvert_field($field, preg_match('~' . number_type() . '~', $field["type"]) && $val != '' ? $val : q($val))
+                                                               ? unconvert_field($field, preg_match(number_type(), $field["type"]) && $val != '' ? $val : q($val))
                                                                : "NULL"
                                                        );
                                                }
index 8fb46b21de427b65bc1d0fec0fbec5819e70c1e9..ff34638ded63e08862b2913bc162a26876565435 100644 (file)
@@ -155,7 +155,7 @@ echo optionlist(array_merge($extra_types, $structured_types), $type);
 <?php echo script("mixin(qsl('select'), {onfocus: function () { lastType = selectValue(this); }, onchange: editingTypeChange});", ""); ?>
 <td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> aria-labelledby="label-length"><?php echo script("mixin(qsl('input'), {onfocus: editingLengthFocus, oninput: editingLengthChange});", ""); ?><td class="options"><?php //! type="number" with enabled JavaScript
        echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
-       echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match('~' . number_type() . '~', $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
+       echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match(number_type(), $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
        echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
        echo ($foreign_keys ? "<select name='" . h($key) . "[on_delete]'" . (preg_match("~`~", $type) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist(explode("|", $on_actions), $field["on_delete"]) . "</select> " : " "); // space for IE
 }
@@ -181,7 +181,7 @@ function process_type($field, $collate = "COLLATE") {
        global $unsigned;
        return " $field[type]"
                . process_length($field["length"])
-               . (preg_match('~' . number_type() . '~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
+               . (preg_match(number_type(), $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
                . (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " $collate " . q($field["collation"]) : "")
        ;
 }
index dac6908144cf3bd54ba5d5ec75fafeb594eaabe4..1576a21b9ae4ce8e23def5785c22b12e08574a34 100644 (file)
@@ -45,7 +45,7 @@ function number($val) {
 * @return string
 */
 function number_type() {
-       return '(?<!o)int(?!er)|numeric|real|float|double|decimal|money'; // not point, not interval
+       return '((?<!o)int(?!er)|numeric|real|float|double|decimal|money)'; // not point, not interval
 }
 
 /** Disable magic_quotes_gpc
index 241e917bb6f2ccbc48797c3ce922fa9dcc337c0b..d69667880d24e71b08dd3a90470e6f4c4f21f39e 100644 (file)
@@ -197,7 +197,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                if ($link) {
                        $return = "<a href='$link'" . (is_url($link) ? target_blank() : "") . ">$return</a>";
                }
-               if (!$link && !like_bool($field) && preg_match('~' . number_type() . '~', $field["type"])) {
+               if (!$link && !like_bool($field) && preg_match(number_type(), $field["type"])) {
                        $return = "<div class='number'>$return</div>"; // Firefox doesn't support <colgroup>
                } elseif (preg_match('~date~', $field["type"])) {
                        $return = "<div class='datetime'>$return</div>";
@@ -342,7 +342,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                        if (($key < 0 ? "" : $col) . $val != "") {
                                $conds = array();
                                foreach (($col != "" ? array($col => $fields[$col]) : $fields) as $name => $field) {
-                                       if ($col != "" || is_numeric($val) || !preg_match('~' . number_type() . '~', $field["type"])) {
+                                       if ($col != "" || is_numeric($val) || !preg_match(number_type(), $field["type"])) {
                                                $name = idf_escape($name);
                                                if ($col != "" && $field["type"] == "enum") {
                                                        $conds[] = (in_array(0, $val) ? "$name IS NULL OR " : "") . "$name IN (" . implode(", ", array_map('intval', $val)) . ")";