Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-8825

Impossible to create (or modify) column as NULL with DBAL for mysql40/41 (and possibly firebird, mss

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Trivial Trivial
    • None
    • 3.0.5
    • None
    • PHP Environment: 5.2.11
      Database: MySQL 5.0.70

      Bug location:
      In includes/db/db_tools.php

      In function sql_prepare_column_data
      (which is called by function perform_schema_changes)

      Scenario:
      In both functions sql_column_add and sql_column_change, sql_prepare_column_data is called in the very beginning like so:

      $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); 

      sql_prepare_column_data, in the (switch) case of mysql40 and mysql41 (and also firebird, mssql, and sqllite), does not at all account for "NULL" property in $column_data[1], always tagging "NOT NULL" to $sql (the sql statement) without checking if the default property ($column_data[1]) is set to NULL
      The only two cases where function sql_prepare_column_data DOES indeed check if the default property is set to NULL and sets it appropriately, is for "oracle" and "postgres" dbms...

      Consider the following snippet of code:

      include($phpbb_root_path . 'includes/db/db_tools.' . $phpEx);$db_tools = new phpbb_db_tools($db);$db_tools->sql_column_add(SESSIONS_TABLE, 'some_column', array('CHAR:10', NULL)); 

      On mysql40 or mysql41, "some_column" gets added to phpbb_sessions table as type char(10) , but the NULL property is set to NOT NULL, opposite to what was intended, leaving the column set to NOT NULL with no default, which breaks sessions because code depends on session getting created first before updating that column data..
      See my post Re: Proxy Revealer Olympus 0.3.3

      Meanwhile, trying to think of a workaround..

            nickvergessen Joas Schilling
            jasmineaura jasmineaura [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: