Whoops \ Exception \ ErrorException (E_WARNING)
Attempt to read property "parent" on null Whoops\Exception\ErrorException thrown with message "Attempt to read property "parent" on null" Stacktrace: #9 Whoops\Exception\ErrorException in /data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/CarData.php:31 #8 Whoops\Run:handleError in /data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/CarData.php:31 #7 THEME\CarPriceList\Components\CarData:getCarData in /data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/CarData.php:23 #6 THEME\CarPriceList\Components\CarData: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/Single.php:18 #3 THEME\ViewModel\Single:__construct in /data/websites/motori/web/app/themes/motori/single-car.php:9 #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/CarData.php31
8
Whoops\Run handleError
/web/app/themes/motori/src/CarPriceList/Components/CarData.php31
7
THEME\CarPriceList\Components\CarData getCarData
/web/app/themes/motori/src/CarPriceList/Components/CarData.php23
6
THEME\CarPriceList\Components\CarData 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/Single.php18
3
THEME\ViewModel\Single __construct
/web/app/themes/motori/single-car.php9
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/CarData.php
    protected \WP_Post $car;
 
 
    public function __construct( $data, array $context) {
        
        $this->car = $data;
    }
 
    
    public function getData() : ComponentData {
 
        return new ComponentData( self::NAME, $this->getCarData() );
    }
 
 
    protected function getCarData() : array {
        
        // Trova il termine genitore
        $termModel = $this->getModelTerm( $this->car->ID );
        $termBrand = $this->getBrandTerm( $termModel->parent );
        
    
        $brandSlug = $termBrand->slug;
        $modelSlug = $termModel->slug;
        $carSlug   = get_post_meta( $this->car->ID, 'dbauto_car_slug', true);
 
        $apiBase = BLZ_DB_AUTO;
 
        $response = wp_remote_get( "{$apiBase}/motori.it/brands/{$brandSlug}/models/{$modelSlug}/cars/{$carSlug}", [ 'sslverify' => false ] );
 
        if ( is_wp_error( $response ) ) {
            return [];
        }
 
        $data = wp_remote_retrieve_body( $response );
       
        return json_decode($data, true);
    }
 
 
/data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/CarData.php
    protected \WP_Post $car;
 
 
    public function __construct( $data, array $context) {
        
        $this->car = $data;
    }
 
    
    public function getData() : ComponentData {
 
        return new ComponentData( self::NAME, $this->getCarData() );
    }
 
 
    protected function getCarData() : array {
        
        // Trova il termine genitore
        $termModel = $this->getModelTerm( $this->car->ID );
        $termBrand = $this->getBrandTerm( $termModel->parent );
        
    
        $brandSlug = $termBrand->slug;
        $modelSlug = $termModel->slug;
        $carSlug   = get_post_meta( $this->car->ID, 'dbauto_car_slug', true);
 
        $apiBase = BLZ_DB_AUTO;
 
        $response = wp_remote_get( "{$apiBase}/motori.it/brands/{$brandSlug}/models/{$modelSlug}/cars/{$carSlug}", [ 'sslverify' => false ] );
 
        if ( is_wp_error( $response ) ) {
            return [];
        }
 
        $data = wp_remote_retrieve_body( $response );
       
        return json_decode($data, true);
    }
 
 
/data/websites/motori/web/app/themes/motori/src/CarPriceList/Components/CarData.php
 
use THEME\ViewModel\Common\Component;
use THEME\ViewModel\Common\ComponentData;
 
class CarData implements Component {
 
    const NAME = 'car_data';
 
    protected \WP_Post $car;
 
 
    public function __construct( $data, array $context) {
        
        $this->car = $data;
    }
 
    
    public function getData() : ComponentData {
 
        return new ComponentData( self::NAME, $this->getCarData() );
    }
 
 
    protected function getCarData() : array {
        
        // Trova il termine genitore
        $termModel = $this->getModelTerm( $this->car->ID );
        $termBrand = $this->getBrandTerm( $termModel->parent );
        
    
        $brandSlug = $termBrand->slug;
        $modelSlug = $termModel->slug;
        $carSlug   = get_post_meta( $this->car->ID, 'dbauto_car_slug', true);
 
        $apiBase = BLZ_DB_AUTO;
 
        $response = wp_remote_get( "{$apiBase}/motori.it/brands/{$brandSlug}/models/{$modelSlug}/cars/{$carSlug}", [ 'sslverify' => false ] );
 
        if ( is_wp_error( $response ) ) {
            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/Single.php
<?php
 
namespace THEME\ViewModel;
 
use THEME\ViewModel\Post\Content\Templates\Template;
 
use THEME\ViewModel\Post\Components;
use THEME\ViewModel\Post\CachedComponents;
 
class Single extends Base {
 
    protected Template $postTemplate;
 
    public function __construct(\WP_Post $post, $postTemplate) {
 
        $this->data = $post;
 
        parent::__construct();
 
 
        // assign the post template (default is 'Single')
        $this->postTemplate = (new $postTemplate);
 
        // init the post template 
        // (includes content details as well)
        $this->setPost();
    }
 
 
    /**
     * Writes the basic page info
     */
    protected function initContext(): array
    {
        $context = [
            'type'        => 'single_post',
            'is_electric' =>  false,
            'infinite'    => 'false'
        ];
    
/data/websites/motori/web/app/themes/motori/single-car.php
<?php
 
use THEME\Utils\Timber;
use THEME\CarPriceList\ViewModel\SingleCar;
use THEME\ViewModel\Post\Content\Templates;
 
if (have_posts()) {
    // load data
    $data = (new SingleCar($posts[0], Templates\Minimal::class))->getContext();
 
    Timber::render('single-version.twig', $data, 600);
}
 
/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 /car/volkswagen-golf-variant-2020-10-etsi-evo-dsg-life-1/
USER nginx
HOME /var/lib/nginx
HTTP_REFERER https://staging.motori.it/listino-nuovo//volkswagen-golf-variant-2020
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 18.218.108.184
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 40594
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 1746334321.5605
REQUEST_TIME 1746334321
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