Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bd5200d

Browse filesBrowse files
1 parent 00a6baa commit bd5200d
Copy full SHA for bd5200d

File tree

2 files changed

+9
-4
lines changed
Filter options

2 files changed

+9
-4
lines changed

‎wire/core/Field.php

Copy file name to clipboardExpand all lines: wire/core/Field.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,9 @@ public function getTable() {
12481248
$table = $this->setTable;
12491249
} else {
12501250
$name = $this->settings['name'];
1251-
if(!strlen($name)) throw new WireException("Field 'name' is required");
1251+
$length = strlen($name);
1252+
if(!$length) throw new WireException("Field 'name' is required");
1253+
if($length > 58) $name = substr($name, 0, 58); // 'field_' + 58 = 64 max
12521254
$table = self::tablePrefix . $name;
12531255
}
12541256
if(self::$lowercaseTables) $table = strtolower($table);
@@ -1265,6 +1267,7 @@ public function getTable() {
12651267
*/
12661268
public function setTable($table = null) {
12671269
$table = empty($table) ? '' : $this->wire()->sanitizer->fieldName($table);
1270+
if(strlen($table) > 64) $table = substr($table, 0, 64);
12681271
$this->setTable = $table;
12691272
}
12701273

‎wire/core/Fields.php

Copy file name to clipboardExpand all lines: wire/core/Fields.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,14 @@ public function ___save(Saveable $item) {
388388
// even if only the case has changed.
389389
$schema = $item->type->getDatabaseSchema($item);
390390
if(!empty($schema)) {
391-
foreach(array($table, "tmp_$table") as $t) {
391+
list(,$tmpTable) = explode(Field::tablePrefix, $table, 2);
392+
$tmpTable = "tempf_$tmpTable";
393+
foreach(array($table, $tmpTable) as $t) {
392394
if(!$database->tableExists($t)) continue;
393395
throw new WireException("Cannot rename to '$item->name' because table `$table` already exists");
394396
}
395-
$database->exec("RENAME TABLE `$prevTable` TO `tmp_$table`"); // QA
396-
$database->exec("RENAME TABLE `tmp_$table` TO `$table`"); // QA
397+
$database->exec("RENAME TABLE `$prevTable` TO `$tmpTable`"); // QA
398+
$database->exec("RENAME TABLE `$tmpTable` TO `$table`"); // QA
397399
}
398400
$item->prevTable = '';
399401
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.