PHP8 compability. The type of the returned variable is incorrect.

Created on 19 May 2022, over 2 years ago
Updated 22 February 2023, almost 2 years ago

Was caught PhanTypeExpectedObjectPropAccess critical error by Phan tool in 1224 line of taxonomy_menu/taxonomy_menu.module "Expected an object instance when accessing an instance property, but saw an expression $t with type non-empty-array".
if (i18n_taxonomy_vocabulary_mode($t->vid, I18N_MODE_LOCALIZE)) {

During investigation I found out, that in fact variable $t is a result of _taxonomy_menu_get_item() (in taxonomy_menu.database.inc), which returns stdClass object or false on failure instead array.

function _taxonomy_menu_get_item($mlid) {
  $result = db_select('taxonomy_menu', 'tm')
    ->condition('mlid', $mlid, '=')
    ->fields('tm', array('tid', 'vid'))
    ->execute();

  return $result->fetch();
} 

Variable $result is object of DatabaseStatementBase class("\drupal\includes\database\database.inc"), which set PDO::FETCH_OBJ through constructor

  protected function __construct($dbh) {
    $this->dbh = $dbh;
    $this->setFetchMode(PDO::FETCH_OBJ);
  }

So, I suggest to change returned type of varible for _taxonomy_menu_get_item().

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ΎBelarus alena_stanul

Live updates comments and jobs are added and updated live.
  • PHP 8.1

    The issue particularly affects sites running on PHP version 8.1.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024