Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-12570

db_text throws an error, when set() is called with the current value

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.1.0-b3
    • Fix Version/s: 3.1.0-b4
    • Component/s: None
    • Labels:
      None

      Description

      			$sql = 'UPDATE ' . $this->table . "
      				SET config_value = '" . $this->db->sql_escape($value) . "'
      				WHERE config_name = '" . $this->db->sql_escape($key) . "'";
      			$result = $this->db->sql_query($sql);
       
      			if (!$this->db->sql_affectedrows($result))
      			{
      				$sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', array(
      					'config_name'	=> $key,
      					'config_value'	=> $value,
      				));
      				$this->db->sql_query($sql);
      			}

      MySQL returns 0 when no value has been updated, so it tries to create the key again.

        Issue Links

          Activity

          Hide
          nickvergessen Joas Schilling added a comment -

          After some more testing it seems to be not easy to fix:

          				$this->db->sql_return_on_error(true);
          				$this->db->sql_query($sql);
          				$this->db->sql_return_on_error(false);

          Does not work for the insert.
          The problem is sql_error() is still called which then calls:

          		if ($this->transaction)
          		{
          			$this->sql_transaction('rollback');
          		}

          so possible other values from the set_array() call are not updated

          Show
          nickvergessen Joas Schilling added a comment - After some more testing it seems to be not easy to fix: $this->db->sql_return_on_error(true); $this->db->sql_query($sql); $this->db->sql_return_on_error(false); Does not work for the insert. The problem is sql_error() is still called which then calls: if ($this->transaction) { $this->sql_transaction('rollback'); } so possible other values from the set_array() call are not updated
          Hide
          EXreaction EXreaction [X] (Inactive) added a comment -

          This issue has come up many times in the past. Just do a select and be done with it.

          Show
          EXreaction EXreaction [X] (Inactive) added a comment - This issue has come up many times in the past. Just do a select and be done with it.

            People

            • Assignee:
              nickvergessen Joas Schilling
              Reporter:
              nickvergessen Joas Schilling
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development