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

Check if var is array before using count in installer diff

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 3.3.6-RC1
    • 3.3.5
    • Installation system
    • None
    • PHP 8.0.8

      Running installer "Update files" leads to an exception in diff.php:  

      PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, bool given in phpbb/includes/diff/diff.php:172 
      

       

      The test in is_empty assumes $edit->orig and $edit->final are always arrays, but they're booleans in some cases:

       

      class diff_op_delete extends diff_op
      {
      	function __construct($lines)
      	{
      		$this->orig = $lines;
      		$this->final = false;
      	}
       
       
      	function &reverse()
      	{
      		$reverse = new diff_op_add($this->orig);
      		return $reverse;
      	}
      }
       
      class diff_op_add extends diff_op
      {
      	function __construct($lines)
      	{
      		$this->final = $lines;
      		$this->orig = false;
      	}
       
       
      	function &reverse()
      	{
      		$reverse = new diff_op_delete($this->final);
      		return $reverse;
      	}
      }
       
       
      

       I'm not familiar with this code, but a workaround might be adding a test of is_array.

       

            Marc Marc
            HB HB
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: