Skip to content

Commit 1fc5131

Browse files
nilshoerrmannnitriques
authored andcommitted
Handle empty field data (#8)
* Handle empty data a7423d6 * Fix whitespace 38d320e Signed-off-by: Nils Hörrmann <nils.hoerrmann@hananils.de> * Version 2.7.1 37baf98 Signed-off-by: Nils Hörrmann <nils.hoerrmann@hananils.de>
1 parent e282645 commit 1fc5131

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

extension.meta.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
</author>
2222
</authors>
2323
<releases>
24+
<release version="2.7.1" date="2017-08-10" min="2.6.0" max="2.x.x">
25+
- Catch empty field data (prevents empty database rows)
26+
</release>
2427
<release version="2.7.0" date="2017-05-18" min="2.6.0" max="2.x.x">
2528
- Give option to make handle unique or not (default to unique as was before)
2629
- Make sure all entries table always have a UNIQUE KEY on the `entry_id` column
@@ -119,4 +122,4 @@
119122
- This is a complete rewrite of the old extension, it isn't backwards compatible, so don't try to upgrade.
120123
</release>
121124
</releases>
122-
</extension>
125+
</extension>

fields/field.textbox.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,11 @@ public function checkPostFieldData($data, &$message, $entry_id = null) {
531531

532532
public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null) {
533533
$status = self::__OK__;
534+
535+
if (strlen(trim($data)) == 0) {
536+
return array();
537+
}
538+
534539
$formatted = $this->applyFormatting($data);
535540

536541
$result = array(
@@ -810,7 +815,7 @@ private static function replaceAnds($data) {
810815
if (!preg_match('/((\W)and)|(and(\W))/i', $data)) {
811816
return $data;
812817
}
813-
818+
814819
// Negative match?
815820
if (preg_match('/^not(\W)/i', $data)) {
816821
$mode = '-';

0 commit comments

Comments
 (0)