Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[2.x] Extension Manager: queued tasks fail on PostgreSQL (output NOT NULL, command varchar(50))

Cerrado Apto para principiantes
#5,116 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, sql
Área
databases

Línea de trabajo

Comienza en extensions/package-manager/src/Task/Task.php, en Task::build(), que guarda una tarea pendiente sin establecer la columna NOT NULL output; el issue ya incluye una corrección candidata. Después, revisa el esquema de extension_manager_tasks en extensions/package-manager/migrations (probablemente la migración original de creación de tabla más una nueva migración de cambio) para ampliar command más allá de varchar(50). Se considera terminado cuando se puede crear una tarea encolada y guardar el comando de actualización global en PostgreSQL/SQLite/MySQL estricto: verifica con php flarum migrate en una base de datos estricta y ejecutando la ruta de creación de tareas del extension manager o sus tests existentes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Current Behavior

With the queue enabled ('queue' => ['driver' => 'database']) and "queue jobs" turned on in the Extension Manager, two schema problems in extension_manager_tasks break tasks on PostgreSQL. MySQL in non-strict mode silently stores '' and truncates, so they go unnoticed there.

1. Every queued task fails to be created. Task::build() saves a pending task without setting output, but the column is mediumText('output') with no ->nullable(). The admin UI shows "Database query failed. This may be caused by an incompatibility between an extension and your database driver." and the log has:

SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column "output" of relation "extension_manager_tasks" violates not-null constraint
DETAIL:  Failing row contains (1, pending, extension_update, null, fof/links, null, 2026-10-07 01:02:45, null, null, null, null).

2. The Global Update is recorded as failed after Composer has finished. command is string('command', 50), but the global update command is 56 characters (update --prefer-dist --no-dev -a --with-all-dependencies). Composer completes, then Task::end() cannot save the row:

SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(50)
(SQL: update "extension_manager_tasks" set "status" = failure, "command" = update --prefer-dist --no-dev -a --with-all-dependencies, ...)

The job then stops, so the steps after the update never run: a pending migration from an updated extension stayed unapplied until I ran php flarum migrate by hand.

Steps to Reproduce
  1. Install Flarum 2.x on PostgreSQL and enable the Extension Manager.
  2. Set 'queue' => ['driver' => 'database'] in config.php and enable queued jobs in the Extension Manager settings.
  3. Click "Update" on any extension: the task is never created and the alert above appears (bug 1).
  4. With output made nullable, click "Run Global Update": Composer finishes, but the task ends as failed with the varchar(50) error (bug 2).
Expected Behavior

Tasks are created, and the global update is recorded as successful, on PostgreSQL (and SQLite or strict MySQL) just as on non-strict MySQL.

Environment
  • Flarum version: core v2.0.0-rc.8, flarum/extension-manager v2.0.0-rc.5 (the same code is unchanged on 2.x)
  • Website URL: private test site
  • Webserver: Caddy with PHP-FPM
  • Hosting environment: VPS
  • PHP version: 8.5.4
  • Database: PostgreSQL 18.6
  • Browser: not relevant (server side)
Possible Solution

Set output to an empty string when building a task, and widen command to text (a major update lists every extension, so 255 may also be too short). The patch below applies cleanly to 2.x. I applied the equivalent schema change on our install, and both kinds of task now save.

diff --git a/extensions/package-manager/src/Task/Task.php b/extensions/package-manager/src/Task/Task.php
--- a/extensions/package-manager/src/Task/Task.php
+++ b/extensions/package-manager/src/Task/Task.php
@@ -68,6 +68,8 @@ class Task extends AbstractModel
         $task->operation = $operation;
         $task->package = $package;
         $task->status = static::PENDING;
+        // The output column is NOT NULL; PostgreSQL and SQLite reject a pending task without it.
+        $task->output = '';
         $task->created_at = Carbon::now();
 
         $task->save();
diff --git a/extensions/package-manager/migrations/2026_10_07_000000_change_command_column_to_text_in_extension_manager_tasks_table.php b/extensions/package-manager/migrations/2026_10_07_000000_change_command_column_to_text_in_extension_manager_tasks_table.php
new file mode 100644
--- /dev/null
+++ b/extensions/package-manager/migrations/2026_10_07_000000_change_command_column_to_text_in_extension_manager_tasks_table.php
@@ -0,0 +1,26 @@
+<?php
+
+/*
+ * This file is part of Flarum.
+ *
+ * For detailed copyright and license information, please view the
+ * LICENSE file that was distributed with this source code.
+ */
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Schema\Builder;
+
+return [
+    'up' => function (Builder $schema) {
+        // Composer commands such as the global update are longer than 50 characters.
+        // MySQL in non-strict mode truncates them; PostgreSQL rejects the row.
+        $schema->table('extension_manager_tasks', function (Blueprint $table) {
+            $table->text('command')->nullable()->change();
+        });
+    },
+    'down' => function (Builder $schema) {
+        $schema->table('extension_manager_tasks', function (Blueprint $table) {
+            $table->string('command', 50)->nullable()->change();
+        });
+    }
+];
Additional Context

The Extension Manager's Dispatcher silently skips a new request while another task is pending or running, so after bug 1 the UI gives no further feedback on retries.

Lenguaje dominante
PHP
Estrellas
6.8k
Forks
889
Merge medio
14 h 13 min
PR fusionados (30 d)
140

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de flarum/framework

Todos los issues de flarum/framework

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.