Whoops \ Exception \ ErrorException (E_WARNING)
Trying to access array offset on value of type null Whoops\Exception\ErrorException thrown with message "Trying to access array offset on value of type null" Stacktrace: #9 Whoops\Exception\ErrorException in /data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/ModelData.php:64 #8 Whoops\Run:handleError in /data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/ModelData.php:64 #7 THEME\CarPriceList\Components\ModelData:getModelData in /data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/ModelData.php:38 #6 THEME\CarPriceList\Components\ModelData:getData in /data/websites/motori/web/app/themes/motori/src/ViewModel/Common/HasComponents.php:15 #5 THEME\ViewModel\Base:loadComponents in /data/websites/motori/web/app/themes/motori/src/ViewModel/Base.php:34 #4 THEME\ViewModel\Base:__construct in /data/websites/motori/web/app/themes/motori/src/ViewModel/Archive.php:40 #3 THEME\ViewModel\Archive:__construct in /data/websites/motori/web/app/themes/motori/taxonomy-listino.php:17 #2 include in /data/websites/motori/web/wp/wp-includes/template-loader.php:106 #1 require_once in /data/websites/motori/web/wp/wp-blog-header.php:19 #0 require in /data/websites/motori/web/index.php:6
Stack frames (10)
9
Whoops\Exception\ErrorException
/web/app/themes/motori/src/CarPriceList/Components/ModelData.php64
8
Whoops\Run handleError
/web/app/themes/motori/src/CarPriceList/Components/ModelData.php64
7
THEME\CarPriceList\Components\ModelData getModelData
/web/app/themes/motori/src/CarPriceList/Components/ModelData.php38
6
THEME\CarPriceList\Components\ModelData getData
/web/app/themes/motori/src/ViewModel/Common/HasComponents.php15
5
THEME\ViewModel\Base loadComponents
/web/app/themes/motori/src/ViewModel/Base.php34
4
THEME\ViewModel\Base __construct
/web/app/themes/motori/src/ViewModel/Archive.php40
3
THEME\ViewModel\Archive __construct
/web/app/themes/motori/taxonomy-listino.php17
2
include
/web/wp/wp-includes/template-loader.php106
1
require_once
/web/wp/wp-blog-header.php19
0
require
/web/index.php6
/data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/ModelData.php
 
        return new ComponentData(self::NAME, $model);
    }
 
 
    protected function getModelData() : array {
 
        $apiBase = BLZ_DB_AUTO;
 
        $data = wp_remote_get( "{$apiBase}/motori.it/brands/{$this->brandSlug}/models/{$this->modelSlug}?d67s", [ 'sslverify' => false ] );
 
        if ( is_wp_error( $data ) ) {
            return [];
        }
 
        $body = wp_remote_retrieve_body( $data );
 
        $data = json_decode($body, true);
 
        $data['description'] = $data['description'] ? $this->formatText( $data['description'] ) : '';
        $data['excerpt'] = $data['excerpt'] ? $data['excerpt']  : '';
 
 
        
        return $data;
    }
 
 
    public function getModelCars() {
        $apiBase = BLZ_DB_AUTO;
    
        $response = wp_remote_get("{$apiBase}/motori.it/brands/{$this->brandSlug}/models/{$this->modelSlug}/cars", ['sslverify' => false]);
    
        if (is_wp_error($response)) {
            return [];
        }
    
        $body = wp_remote_retrieve_body($response);
        $data = json_decode($body, true);
    
/data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/ModelData.php
 
        return new ComponentData(self::NAME, $model);
    }
 
 
    protected function getModelData() : array {
 
        $apiBase = BLZ_DB_AUTO;
 
        $data = wp_remote_get( "{$apiBase}/motori.it/brands/{$this->brandSlug}/models/{$this->modelSlug}?d67s", [ 'sslverify' => false ] );
 
        if ( is_wp_error( $data ) ) {
            return [];
        }
 
        $body = wp_remote_retrieve_body( $data );
 
        $data = json_decode($body, true);
 
        $data['description'] = $data['description'] ? $this->formatText( $data['description'] ) : '';
        $data['excerpt'] = $data['excerpt'] ? $data['excerpt']  : '';
 
 
        
        return $data;
    }
 
 
    public function getModelCars() {
        $apiBase = BLZ_DB_AUTO;
    
        $response = wp_remote_get("{$apiBase}/motori.it/brands/{$this->brandSlug}/models/{$this->modelSlug}/cars", ['sslverify' => false]);
    
        if (is_wp_error($response)) {
            return [];
        }
    
        $body = wp_remote_retrieve_body($response);
        $data = json_decode($body, true);
    
/data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/ModelData.php
 
        
        // rileva il termine corrente
        $termModel = get_term($data->object->term_id);
 
 
        // Verifica se il termine ha un genitore
        if ($termModel && $termModel->parent) {
            // Ottieni il termine genitore
            $termBrand = get_term($termModel->parent);
        }
 
        $this->modelSlug = $termModel->slug;
        $this->brandSlug = $termBrand->slug;
 
    }
    
    public function getData() : ComponentData {
 
        $modelData = $this->getModelData();
        $modelCars = $this->getModelCars();
 
        // Unisci i due array
        $model = array_merge($modelData, $modelCars);
 
 
 
        return new ComponentData(self::NAME, $model);
    }
 
 
    protected function getModelData() : array {
 
        $apiBase = BLZ_DB_AUTO;
 
        $data = wp_remote_get( "{$apiBase}/motori.it/brands/{$this->brandSlug}/models/{$this->modelSlug}?d67s", [ 'sslverify' => false ] );
 
        if ( is_wp_error( $data ) ) {
            return [];
        }
/data/websites/motori/web/app/themes/motori/src/ViewModel/Common/HasComponents.php
<?php
 
namespace THEME\ViewModel\Common;
 
trait HasComponents {
 
    protected array $components = [];  // list of components that yield data
    protected object|null $data = null;  // basic data of the current object ( post, term, queried_object, etc.)
    protected array $context    = [];  // data gathered while loading components from the compontent's list
    
    protected function loadComponents() {
 
        foreach($this->components as $component) {
 
            $component_instance = ( new $component( $this->data, $this->context) )->getData();
 
            $this->context[$component_instance->name] = $component_instance->data;
 
        }
    }
 
    public function getContext() {
 
        return $this->context;
    }
}
/data/websites/motori/web/app/themes/motori/src/ViewModel/Base.php
 * expose getContext() to the view
 *
 */
abstract class Base {
 
    use HasComponents;
    use CanPurgeCachedComponents;
 
 
    public function __construct() {
 
        $this->context = $this->initContext();
 
        $this->components = array_merge(
            $this->listBasicComponents(),
            $this->listComponents(),
            $this->listStructureComponents()
        );
 
        $this->loadComponents();
    }
 
 
    protected function listBasicComponents() : array {
 
        return [
            Components\Domain::class,
            Components\IsMobile::class,
            Components\AssetsDir::class,
            Components\GoogleTagManager::class,
            Components\Menus::class,
            BrandModelList::class,
        ];
    }
 
    /**
     * componenti da calcolare sempre dopo l'esecuzione degli 
     * altri hook
     *
     * @return array
/data/websites/motori/web/app/themes/motori/src/ViewModel/Archive.php
    
    //protected $archiveTemplate;
    
    protected $paged;
    
    
    public function __construct( $postTemplate = PostTemplates\Minimal::class, $archiveTemplate = 'Archive' ) {
 
        global $wp_query; // peccato originale avere la wp_query;
 
        $this->data = (object) [
            'object'    => get_queried_object(),
            'paged'     => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1,
            'tot_pages' => $wp_query->max_num_pages,
            'posts'     => $wp_query->posts,
        ];
    
        $this->postTemplate = new $postTemplate ;
        
        parent::__construct();
 
        // set the archiveTemplate (default 'Archive') 
        // $this->archiveTemplate = $archiveTemplate;
 
        $this->setArticles();
    }
 
 
    /**
     * Writes the basic page info
     */
    protected function initContext(): array
    {
        $context = [
            'type'        => 'archive',
            'is_electric' =>  false,
            'infinite'    => 'false'
        ];
    
        // Controlla se lo slug della categoria corrente è 'auto-elettriche'
/data/websites/motori/web/app/themes/motori/taxonomy-listino.php
<?php
 
 
use THEME\Utils\Timber;
use THEME\CarPriceList\ViewModel\Brand;
use THEME\CarPriceList\ViewModel\Model;
 
 
 
$term = get_queried_object();
 
 
$paged = (get_query_var('paged') && get_query_var('paged') !== 0) ? get_query_var('paged') : 1;
 
if ( $term->parent ) {
 
    $data = ( new Model )->getContext( $term );
 
    Timber::render( 'single-model.twig', $data );
 
} else {
 
 
    // load data
    $data = ( new Brand )->getContext();
 
    $template = $paged <= 1 ? 'single-brand.twig' : 'archive-paged.twig';
 
    Timber::render( $template, $data );
    
}
 
 
 
/data/websites/motori/web/wp/wp-includes/template-loader.php
            }
 
            break;
        }
    }
 
    if ( ! $template ) {
        $template = get_index_template();
    }
 
    /**
     * Filters the path of the current template before including it.
     *
     * @since 3.0.0
     *
     * @param string $template The path of the template to include.
     */
    $template = apply_filters( 'template_include', $template );
    if ( $template ) {
        include $template;
    } elseif ( current_user_can( 'switch_themes' ) ) {
        $theme = wp_get_theme();
        if ( $theme->errors() ) {
            wp_die( $theme->errors() );
        }
    }
    return;
}
 
/data/websites/motori/web/wp/wp-blog-header.php
<?php
/**
 * Loads the WordPress environment and template.
 *
 * @package WordPress
 */
 
if ( ! isset( $wp_did_header ) ) {
 
    $wp_did_header = true;
 
    // Load the WordPress library.
    require_once __DIR__ . '/wp-load.php';
 
    // Set up the WordPress query.
    wp();
 
    // Load the theme template.
    require_once ABSPATH . WPINC . '/template-loader.php';
 
}
 
/data/websites/motori/web/index.php
<?php
/**
 * WordPress View Bootstrapper
 */
define('WP_USE_THEMES', true);
require __DIR__ . '/wp/wp-blog-header.php';
 
 

Environment & details:

empty
empty
empty
empty
empty
Key Value
SERVER_SOFTWARE nginx/1.26.2
REQUEST_URI /listino/opel/ampera/
USER nginx
HOME /var/lib/nginx
HTTP_REFERER https://staging.motori.it/listino/opel/ampera
HTTP_ACCEPT_ENCODING gzip, br, zstd, deflate
HTTP_USER_AGENT Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HTTP_ACCEPT */*
HTTP_CONNECTION close
HTTP_X_FORWARDED_FOR 160.79.108.177
HTTP_HOST staging.motori.it
HTTP_X_FORWARDED_PORT 443
HTTP_X_FORWARDED_PROTO https
REDIRECT_STATUS 200
SERVER_NAME staging.motori.it
SERVER_PORT 443
SERVER_ADDR 10.50.50.197
REMOTE_PORT 49074
REMOTE_ADDR 10.50.50.12
GATEWAY_INTERFACE CGI/1.1
HTTPS on
REQUEST_SCHEME https
SERVER_PROTOCOL HTTP/1.0
DOCUMENT_ROOT /data/websites/motori/web
DOCUMENT_URI /index.php
SCRIPT_NAME /index.php
CONTENT_LENGTH
CONTENT_TYPE
REQUEST_METHOD GET
QUERY_STRING
SCRIPT_FILENAME /data/websites/motori/web/index.php
FCGI_ROLE RESPONDER
PHP_SELF /index.php
REQUEST_TIME_FLOAT 1745880936.4132
REQUEST_TIME 1745880936
WP_ENV development
WP_HOME https://staging.motori.it
WP_SITEURL https://staging.motori.it/wp
WP_DEBUG true
WP_CACHE false
WPLANG it_IT
WP_POST_REVISIONS 3
DB_NAME motori
DB_USER USRmotori
DB_PASSWORD M0t0r1.Bl4z3
DB_HOST localhost
DISABLE_WP_CRON true
ASSETS_DIR /app/themes/motori/assets
GTM_ID GTM-XXXXXX
AUTH_KEY E094PtbN,/./X6J)N>X}iRr2X@qzrp<)*n!<1kps=WXH11Ho^1)^#,,/N`RQ%4PA
SECURE_AUTH_KEY rek_-EaoK.j{F>G%}^{Kw+npcA[tI&MW0_:3|Liq*E/]U/ve{M`tRW7[,SX-?G|b
LOGGED_IN_KEY Y;LL^L-^5a5nG&?I;e[nj0<5<;&pprgWk9Eq-Ozp>H6DZwl)3LUtdxQJ-b*mXA/w
NONCE_KEY 1R!zPZ.mPoo=[i1B[dUi2a13}0:>G{BToB:OX_(S8zT+PZ7nlEn78.#t0u7x?9)&
AUTH_SALT e+WE5olbqDvW7C[%Fs}d3n#_@8^,Ha<k&}kBL|:t@*Sl2vs#qT(lw`famVOPZ:!F
SECURE_AUTH_SALT Ks7ArUFaxK%!B`mqAsS;{qC,vpR36AiIcb@N1$[2<^SVY|?11$PV&P[PPzta,N<Z
LOGGED_IN_SALT 8lh7Q,HpTM}CMRtES%GVPD--09e!MUsQbinsA0-lS=qiUFfOaC]*,R?W$Po7UMak
NONCE_SALT m%tOV5u+uWm$e4V|4!y,:K_7`-N=m$unEx>SO:VZGMS)Y!h_ln/#zTJAkM)FK7{2
Key Value
WP_ENV development
WP_HOME https://staging.motori.it
WP_SITEURL https://staging.motori.it/wp
WP_DEBUG true
WP_CACHE false
WPLANG it_IT
WP_POST_REVISIONS 3
DB_NAME motori
DB_USER USRmotori
DB_PASSWORD M0t0r1.Bl4z3
DB_HOST localhost
DISABLE_WP_CRON true
ASSETS_DIR /app/themes/motori/assets
GTM_ID GTM-XXXXXX
AUTH_KEY E094PtbN,/./X6J)N>X}iRr2X@qzrp<)*n!<1kps=WXH11Ho^1)^#,,/N`RQ%4PA
SECURE_AUTH_KEY rek_-EaoK.j{F>G%}^{Kw+npcA[tI&MW0_:3|Liq*E/]U/ve{M`tRW7[,SX-?G|b
LOGGED_IN_KEY Y;LL^L-^5a5nG&?I;e[nj0<5<;&pprgWk9Eq-Ozp>H6DZwl)3LUtdxQJ-b*mXA/w
NONCE_KEY 1R!zPZ.mPoo=[i1B[dUi2a13}0:>G{BToB:OX_(S8zT+PZ7nlEn78.#t0u7x?9)&
AUTH_SALT e+WE5olbqDvW7C[%Fs}d3n#_@8^,Ha<k&}kBL|:t@*Sl2vs#qT(lw`famVOPZ:!F
SECURE_AUTH_SALT Ks7ArUFaxK%!B`mqAsS;{qC,vpR36AiIcb@N1$[2<^SVY|?11$PV&P[PPzta,N<Z
LOGGED_IN_SALT 8lh7Q,HpTM}CMRtES%GVPD--09e!MUsQbinsA0-lS=qiUFfOaC]*,R?W$Po7UMak
NONCE_SALT m%tOV5u+uWm$e4V|4!y,:K_7`-N=m$unEx>SO:VZGMS)Y!h_ln/#zTJAkM)FK7{2
0. Whoops\Handler\PrettyPageHandler