pkgreqfuncs: Don't leave out non-default ClosureComment column

Message ID 20190730174658.32129-1-johannes@kyriasis.com
State Accepted, archived
Headers show
Series
  • pkgreqfuncs: Don't leave out non-default ClosureComment column
Related show

Commit Message

Johannes Löthberg July 30, 2019, 5:46 p.m. UTC
Since 09cb61a (schema: Remove invalid default values for TEXT columns,
2017-04-15) the PackageRequests.ClosureComment field no longer has a
default value.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
---
 web/lib/pkgreqfuncs.inc.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Eli Schwartz July 30, 2019, 6:21 p.m. UTC | #1
On 7/30/19 1:46 PM, Johannes Löthberg wrote:
> Since 09cb61a (schema: Remove invalid default values for TEXT columns,
> 2017-04-15) the PackageRequests.ClosureComment field no longer has a
> default value.

Hotfixed by lfleischer and now people can submit requests once more.

One would think it would be nice to have default values, but apparently
only expressions can be default values for TEXT, and expressions, meanwhile,
- are only supported for some storage engines, and
- only available in mysql >= 8.0.13

Hopefully none of the other fields that dropped their defaults in commit
09cb61a will ever have an assumed default used. I think all the others
should need user input stored when first adding the row, which is fine...

Patch

diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php
index b8be7e5..079df38 100644
--- a/web/lib/pkgreqfuncs.inc.php
+++ b/web/lib/pkgreqfuncs.inc.php
@@ -165,10 +165,10 @@  function pkgreq_file($ids, $type, $merge_into, $comments) {
 
 	$q = "INSERT INTO PackageRequests ";
 	$q.= "(ReqTypeID, PackageBaseID, PackageBaseName, MergeBaseName, ";
-	$q.= "UsersID, Comments, RequestTS) VALUES (" . $type_id . ", ";
+	$q.= "UsersID, Comments, ClosureComment, RequestTS) VALUES (" . $type_id . ", ";
 	$q.= $base_id . ", " .  $dbh->quote($pkgbase_name) . ", ";
 	$q.= $dbh->quote($merge_into) . ", " . $uid . ", ";
-	$q.= $dbh->quote($comments) . ", " . strval(time()) . ")";
+	$q.= $dbh->quote($comments) . ", '', " . strval(time()) . ")";
 	$dbh->exec($q);
 	$request_id = $dbh->lastInsertId();