WordPress disable Notice and Deprecated in debug.log

I want to get rid of Notice and Deprecated errors in my debug.log

here is my wp-config.php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );

mu-plugins/error-reporting.php
// Disable notices, warnings, deprecated, and strict errors globally

error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED & ~E_USER_DEPRECATED & ~E_STRICT);

// Ensure that display_errors is turned off

ini_set('display_errors', 0);
ini_set('log_errors', 1); // Enable logging of errors to error log

in php.ini

I have Master value error_reporting = 6133
but local value is 8181

How can I override it and make sure plugins won’t override it again?

I tried to change it inside php.ini / wp-config.php / mu-plugin, but it’s still doesn’t work and I’m getting Notices in my debug.log

yii2 why are buttons rendered outside bootstrap modal

<?php
    $yesBtn = Html::submitButton('yes', ['class' => 'btn btn-primary']);
    $noBtn = Html::submitButton('no', ['class' => 'btn btn-secondary']);

    $modal = Modal::begin([
// ...
'footer' => "$noBtn $yesBtn"
    ]);

echo "are you sure?";

    Modal::end();

    echo $modal->run();

I have the above code to render a modal, and have 2 buttons (yesBtn, noBtn) shown on it, but both buttons are rendered outside the modal too (at the bottom of the page, even before clicking the modal’s toggleButton), where i don’t want them.

Why does adding the buttons to the footer render them outside the modal?
Is there a better way to achieve what i’m trying to do?

How to Customize Header and Footer with Elementor in a Theme Without Site Editor Support

Problem:

I’m using a custom theme that doesn’t support the WordPress Site Editor. I want to create a new splash page with a modified header and footer that hides the nav menu. Elementor is enabled.

Question:

How can I use Elementor to edit the existing header and footer templates from my theme and conditionally hide the nav menu for the splash page?

Additional Details:

Theme: custom_theme
Elementor Version: 3.23.4
WordPress Version: 6.5.5

How to get all touched files/classes during the response generation

I’ve used autoload but it’s not giving all the files/classes that’s been used during request

spl_autoload_register(function ($class) {
    $logFile = __DIR__ . '/autoload_log.txt';
    $message = $class . "n";
    file_put_contents($logFile, $message, FILE_APPEND);
}, true, true);

Is there any other way to trace all classes that’s been involved during the page generation?

How to disable product title hyperlink in wooCommerce

I would like to develop wooCommerce custom plugin. For the project requirement product title hyperlink will be disable.For this simple task i define the following script.Please give me the solution How to fix this.I want to use it WordPress custom plugin.

class Custom_WooCommerce_Disable_Title_Link {
    public function __construct() {
        add_action( 'init', array( $this, 'remove_title_hyperlink' ) );
    }

    public function remove_title_hyperlink() {

        remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
        remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );
    }
}

new Custom_WooCommerce_Disable_Title_Link();

I tried about above script. this is doesn’t work

How to implement a different header on each page with WordPress Waymore theme?

I am using the waymore theme of popularfx in WordPress and want to change the header image in my About and Service page.

Currently, the same header image is showing on all pages, but I want a different header banner on my About and Service page

I created header-about.php at wp-content/theme/popularfx/header-about.php

and changed code in page.php

<?php
    if(is_page('about'))
    {
       get_header('about');
    }
   else
   {
       get_header();
   }
  wp_head();
?>

but this code is not working at all.

I also tried different plugins for same unique header, wp header images etc

Laravel Powergrid Table Add Loading on Pagination

I’m fairly new to Laravel, and I’m using PowerGrid to display an employee table. The skeleton loading works fine when the page initially loads, but I would like to add the loading animation when changing the “per page” value or switching between pages.

The PowerGrid component:

final class PowergridTable extends PowerGridComponent
{
    use TableTraits;

    public bool $deferLoading = true;
    public string $loadingComponent = 'components.table-loading';

    public string $sortField = 'created_at';
    public string $sortDirection = 'desc';

    public $year;
    public $month;

    public function setUp(): array
    {
        $this->year = now()->year;
        $this->month = now()->month;

        return [
            Footer::make()
                ->showPerPage()
                ->showRecordCount(),
        ];
    }

    public function datasource(): Builder
    {
        $employees = Employee::query()
            ->select([
                'employees.id as emp_id',
                'employees.first_name',
                'employees.last_name',
            ]);

        return $employees;
    }

    public function relationSearch(): array
    {
        return [];
    }

    public function fields(): PowerGridFields
    {
        $startIndex = $this->paginationStartIndex();

        return PowerGrid::fields()
            ->add('index', fn (Employee $model, $index) => ++$index + $startIndex)
            ->add('company_id', fn (Employee $model) => $model->company_id);
    }

    public function columns(): array
    {
        return [
            Column::make('#', 'index'),
            Column::make(__("main.salary.table.employee"), 'employee_name', 'last_name')
                ->headerAttribute('w-[250px] overflow-hidden whitespace-nowrap')
                ->sortable(),
        ];
    }

    public function filters(): array
    {
        return [
            Filter::inputText('employee_name', 'employees.id')
                ->operators(['contains']),
        ];
    }

    #[LivewireAttributesOn('edit')]
    public function edit($rowId): void
    {
        $this->js('alert(' . $rowId . ')');
    }

    #[On('filter-dates')]
    public function filterSalary($val)
    {
        $data = explode("-", $val);
        $this->year = $data[0];
        $this->month = $data[1];
    }
}
       

The loading component (table-loading.blade.php)

<div class="p-2 space-y-4 animate-pulse">
    {{-- # Column --}}
    <div class="flex items-center gap-4">
        @for ($i = 0; $i < 10; $i++)
            {{-- # Row --}}
            <div>
                <div class="h-2.5 bg-gray-300 rounded-full dark:bg-neutral-500 w-40 mb-2.5"></div>
                <div class="h-2.5 bg-gray-300 rounded-full dark:bg-neutral-500 w-48 mb-2.5"></div>
            </div>
        @endfor
    </div>
    {{-- # Column --}}
    <div class="flex items-center gap-4">
        @for ($i = 0; $i < 10; $i++)
            {{-- # Row --}}
            <div>
                <div class="h-2.5 bg-gray-300 rounded-full dark:bg-neutral-500 w-40 mb-2.5"></div>
                <div class="h-2.5 bg-gray-300 rounded-full dark:bg-neutral-500 w-48 mb-2.5"></div>
            </div>
        @endfor
    </div>
    {{-- # Column --}}
    <div class="flex items-center gap-4">
        @for ($i = 0; $i < 10; $i++)
            {{-- # Row --}}
            <div>
                <div class="h-2.5 bg-gray-300 rounded-full dark:bg-neutral-500 w-40 mb-2.5"></div>
                <div class="h-2.5 bg-gray-300 rounded-full dark:bg-neutral-500 w-48 mb-2.5"></div>
            </div>
        @endfor
    </div>
</div>

To implement the loading skeleton, I tried using wire:loading on the table-loading component like this:

<div wire:loading wire:target='perPage'>
    <div class="p-2 space-y-4 animate-pulse">
        @for ($i = 0; $i < 10; $i++)
            <div class="h-2.5 bg-gray-300 rounded-full dark:bg-neutral-500 w-40 mb-2.5"></div>
            <div class="h-2.5 bg-gray-300 rounded-full dark:bg-neutral-500 w-48 mb-2.5"></div>
        @endfor
    </div>
</div>

However, it doesn’t seem to work as expected when changing the “per page” value or switching between pages. The loading skeleton doesn’t appear during those events.

Is there a proper way to add loading animations for page changes or “per page” value changes in PowerGrid?

XAMPP, Microsoft PHP Drivers for SQL Server Support: cannot find the extensions

I’m having a problem setting up a server using XAMPP.
After setting up everything, PHP throws an error saying that Call to undefined function sqlsrv_connect(), after some more troubleshooting I found out that PHP couldn’t find the extensions. My PHP version is 8.0.3 (BTW when I ran php --version I got this:

PHP Warning:  PHP Startup: Unable to load dynamic library 'php_sqlsrv_83_ts_x64' (tried: C:xamppphpextphp_sqlsrv_83_ts_x64 (Impossibile trovare la procedura specificata), C:xamppphpextphp_php_sqlsrv_83_ts_x64.dll (Impossibile trovare il modulo specificato)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_sqlsrv_83_ts_x64' (tried: C:xamppphpextphp_sqlsrv_83_ts_x64 (Impossibile trovare la procedura specificata), C:xamppphpextphp_php_sqlsrv_83_ts_x64.dll (Impossibile trovare il modulo specificato)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_83_ts_x64' (tried: C:xamppphpextphp_pdo_sqlsrv_83_ts_x64 (Impossibile trovare la procedura specificata), C:xamppphpextphp_php_pdo_sqlsrv_83_ts_x64.dll (Impossibile trovare il modulo specificato)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'php_pdo_sqlsrv_83_ts_x64' (tried: C:xamppphpextphp_pdo_sqlsrv_83_ts_x64 (Impossibile trovare la procedura specificata), C:xamppphpextphp_php_pdo_sqlsrv_83_ts_x64.dll (Impossibile trovare il modulo specificato)) in Unknown on line 0
PHP 8.0.30 (cli) (built: Sep  1 2023 14:15:38) ( ZTS Visual C++ 2019 x64 )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies

The extensions are there:

As well as activated in the right php.ini file:

enter image description here

My extension dir:

extension_dir="C:xamppphpext"

PHP Show MySQL Search result must contain exact keywords but in any order [duplicate]

I am using this php code for MySQL database query:

function search_it() {
    if ( isset( $_GET['s'] ) ) {
        global $wpdb;
        $address_table = $wpdb->prefix . 'my_products';
        $search = $_GET['s'];
    $search = trim($search);         
    $keywords = explode(" ", $search);     
    foreach($keywords as $search) {
        $search = "%{$search}%";
        $where = $wpdb->prepare( 'WHERE name LIKE %s OR price LIKE %d OR id LIKE %d OR market_price LIKE %d OR image_url LIKE %s LIMIT 0,30' , $search, $search, $search, $search, $search );
        }   
    $results = $wpdb->get_results( "SELECT * FROM {$address_table} {$where}" );
        return $results;
    }} 

for example my database have these lines

This is a blue car
This is a white car
This is a red car
This car color is blue
This is a yellow car
This is a blue bike
This car name is bluebird
Blue car looks awesome
       

When i execute the above code, with query blue car
then it will show me all results which contain CAR and all results which contain BLUE
But i want it show me the only results which contain keyword BLUE and CAR even these keywords are saved in any order in database

I want it show me only these results, when i search for blue car

This is a blue car 
This car color is blue
This car name is bluebird
Blue car looks awesome

Above keywords are just for example it would any

WordPress redirect not working for custom post type

I’m building a WordPress site, with two nested custom post types, but I’m experiencing an error. I’m hoping to achieve the following basic structure:

  1. https://website.com/news/ –> shows me my regular wordpress posts
  2. https://website.com/events/ –> shows me custom events listing, my custom type of ‘events’
  3. https://website.com/events/an-event/ –> an example event
  4. https://website.com/events/an-event/ride-01/ –> shows me custom ‘rides’ post type instance

I achieve (1.) on Settings > Permalinks > Custom Structure: /news/%postname%/ – it’s working fine.

I achieve the rest with a custom plugin, code below.

(2.) is working fine.
(3.) is working fine.

My problem is with (4.) – I’m able to create rides, and in the admin panel everything looks fine, even the link to view them. However, when I go to view the post, for example at ‘https://website.com/events/an-event/ride-01/’ I get a 404 error. It looks to me like this should be handled by this line, but isn’t:

add_rewrite_rule( '^/events/([^/]+)/([^/]+)/?$','/index.php?rides=$matches[2]','top' );

When I view https://website.com/index.php?rides=ride-01 I can see my ‘ride’ ok.

How can I view rides with my desired URL as per (4.)? I’ve tried numerous configurations of the ‘rewrite’ and ‘hierarchy’ options but can’t seem to get it to work.

It’s worth noting, every time I make a change I restart my webserver and save the permalinks page to clear any caches.

Thanks!

<?php

/*
Plugin Name: Etc etc.
*/

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

function fun_be_post_type()
{
    $labels = array(
        'name'               => _x('Events', 'post type general name'),
        'singular_name'      => _x('Event', 'post type singular name'),
        'add_new'            => _x('Add New', 'track'),
        'add_new_item'       => __('Add New Event'),
        'edit_item'          => __('Edit Event'),
        'new_item'           => __('New Event'),
        'all_items'          => __('All Events'),
        'view_item'          => __('View Event'),
        'search_items'       => __('Search Events'),
        'not_found'          => __('No events found'),
        'not_found_in_trash' => __('No events found in the Trash'),
        'menu_name'          => 'Events'
    );
    $args = array(
        'labels'        => $labels,
        'rewrite' => array(
            'slug' => 'events', // This controls the base slug that will display before each term
            'with_front' => false // Don't display the category base before "/locations/"
        ),
        'hierarchical' => true,
        'description'   => 'Holds our bike events and event-specific data',
        'public'        => true,
        'publicly_queryable' => true,
        'show_in_rest'  => true,
        'query_var'     => true,
        'capability_type'    => 'post',
        'map_meta_cap' => true,

        'rest_controller_class' => 'WP_REST_Posts_Controller',
        'menu_position' => 5,
        'menu_icon'     => 'data:image/svg+xml;base64,PHN2ZyB3etc...+', // base64 encoded svg menu icon
        'supports'      => array('title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields'),
        'has_archive'   => true,
        'autop'         => false
    );
    register_post_type('events', $args);

    $labels = array(
        "name" => "Rides",
        "singular_name" => "Ride",
    );

    $args = array(
        "labels" => $labels,
        "description" => "",
        "public" => true,
        "show_ui" => true,
        "has_archive" => true,
        "show_in_menu" => true,
        'menu_position' => 6,
        //'with_front' => false,
        "exclude_from_search" => false,
        "capability_type" => "post",
        "map_meta_cap" => true,
        'hierarchical' => false,
        "rewrite" => array("slug" => "events/%event%", "with_front" => false),
        "query_var" => true,
        "supports" => array("title", "revisions", "thumbnail")
    );

    register_post_type("rides", $args);
}
add_action('init', 'fun_be_post_type');


add_action('add_meta_boxes', function () {
    add_meta_box('rides-parent', 'Events', 'rides_attributes_meta_box', 'rides', 'side', 'default');
});

function rides_attributes_meta_box($post)
{
    $pages = wp_dropdown_pages(array('post_type' => 'events', 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column' => 'menu_order, post_title', 'echo' => 0));
    if (! empty($pages)) {
        echo $pages;
    } // end empty pages check
}

add_action('init', function () {

    add_rewrite_rule('^/events/([^/]+)/([^/]+)/?$', '/index.php?rides=$matches[2]', 'top');
});

add_filter('post_type_link', function ($link, $post) {
    if ('rides' == get_post_type($post)) {
        //Lets go to get the parent cartoon-series name
        if ($post->post_parent) {
            $parent = get_post($post->post_parent);
            if (!empty($parent->post_name)) {
                return str_replace('%event%', $parent->post_name, $link);
            }
        } else {
            //to add later
        }
    }
    return $link;
}, 10, 2);

add_filter('manage_rides_posts_columns', 'set_custom_edit_br_columns');

function set_custom_edit_br_columns($columns)
{
    $columns['br_highlight'] = __('Strava ID', 'bike-ride');

    $columns = array(
        'cb' => $columns['cb'],
        'title' => __('Title'),
        'parent_id' => __('Event'),
        'date' => __('Date'),
    );

    return $columns;
}

add_action('manage_rides_posts_custom_column', 'custom_br_column', 10, 2);
function custom_br_column($column, $post_id)
{
    switch ($column) {

        case 'parent_id':
            $post_parent = get_post_parent($post_id);
            $parent_title = get_the_title($post_parent);
            $parent_view_link = get_permalink($post_parent);
            $parent_edit_link = get_edit_post_link($post_parent);
            echo ("
      <a class='row' href='" . $parent_edit_link . "' aria-label='" . $parent_title . " (Edit)'>" . $parent_title . "</a>
      
      <div class='row-actions'><span class='edit'><a href='" . $parent_edit_link . "' aria-label='Edit “" . $parent_title . "”'>Edit</a> | </span><span class='view'><a href='" . $parent_view_link . "' rel='bookmark' aria-label='View “" . $parent_title . "”'>View</a></span></div>
    ");
            break;
    }
}

AJAX mistake make 500 error after insert to database table [duplicate]

im newbie, i have 500 error, when i wanna send new information in DB.

<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible">
    <title>WEB ID</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:opsz,[email protected],100..900&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
</head>
<body>
<div class="change-light">
    <button>Press to <span>Light</span></button>
</div>
<div class="form-block light">
    <div class="header">
        <h1>Создание WEB ID</h1>
        <div class="desc-block">
            <div class="desc">Уже есть WEB ID?</div>
            <a href="#">Найти его здесь ></a>
        </div>
    </div>
    <form>
        <div class="block">
            <input type="text" id="name" placeholder="Имя">
        </div>
        <div class="block">
            <input type="text" id="surname" placeholder="Фамилия">
        </div>
        <div class="hr"></div>
        <div class="block">
            <input type="text" id="dateofbirth" placeholder="Дата рождения">
        </div>
        <div class="block">
            <select name="country" id="country">
                <option value="">Страна</option>
                <option value="Russia">Россия</option>
                <option value="Canada">Канада</option>
            </select>
        </div>
        <div class="block">
            <input type="text" id="email" placeholder="Почта">
        </div>
        <div class="hr"></div>
        <div class="block">
            <input type="password" id="password" placeholder="Пароль">
        </div>
        <div class="block">
            <input type="password" id="repeat_password" placeholder="Повторите пароль">
        </div>
        <div class="errors-block">
            <p></p>
        </div>
        <input type="submit" value="Продолжить">
    </form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="main.js"></script>
</body>
</html>
$('document').ready(function () {
    let register_form = $('.form-block form');
    register_form.on('submit', function (event) {
        event.preventDefault();
        let name = $('#name').val();
        let surname = $('#surname').val();
        let dateofbirth = $('#dateofbirth').val();
        let country = $('#country').val();
        let email = $('#email').val();
        let password = $('#password').val();
        let repeat_password = $('#repeat_password').val();
        let email_mask = /^[w-.]+@[w-]+.[a-z]{2,4}$/i;
        let date_mask = /d{1,2}/d{1,2}/d{2,4}/;

        let noErrors = true;

        $('.error').remove();
        $('.errored').removeClass('errored');

        if (name.length < 1) {
            $('#name').parent().addClass('errored');
            $('#name').after('<div class="error"><span>Заполните это поле</span></div>');
            noErrors = false;
        }
        if (surname.length < 1) {
            $('#surname').parent().addClass('errored');
            $('#surname').after('<div class="error"><span>Заполните это поле</span></div>');
            noErrors = false;
        }
        if (dateofbirth.length < 1 || !date_mask.test(dateofbirth)) {
            $('#dateofbirth').parent().addClass('errored');
            $('#dateofbirth').after('<div class="error"><span>Заполните это поле в формате **/**/****</span></div>');
            noErrors = false;
        }
        if (country.length < 1) {
            $('#country').parent().addClass('errored');
            $('#country').after('<div class="error"><span>Заполните это поле</span></div>');
            noErrors = false;
        }
        if (email.length < 1 || !email_mask.test(email)) {
            $('#email').parent().addClass('errored');
            $('#email').after('<div class="error"><span>Заполните это поле</span></div>');
            noErrors = false;
        }
        if (password.length < 1) {
            $('#password').parent().addClass('errored');
            $('#password').after('<div class="error"><span>Заполните это поле</span></div>');
            noErrors = false;
        }
        if (repeat_password.length < 1 || password !== repeat_password) {
            $('#repeat_password').parent().addClass('errored');
            $('#repeat_password').after('<div class="error"><span>Заполните это поле</span></div>');
            noErrors = false;
        }

        if (noErrors) {
            $.ajax({
                url: 'new_registration.php',
                method: 'POST',
                dataType: 'html',
                data: {
                    "name": name,
                    "surname": surname,
                    "dateofbirth": dateofbirth,
                    "country": country,
                    "email": email,
                    "password": password,
                    "repeat_password": repeat_password
                },
                success: function (data) {
                    console.log('DONE');
                    register_form.trigger('reset');
<?php
$servename = "localhost";
$user = "anar";
$password = "anar";
$database = "webid";

$connection = mysqli_connect($servename,$user,$password,$database);
mysqli_set_charset($connection, "utf8");
if($connection->connect_error){
    die("Ошибка подключения: " . $connection->connect_error);
}
<?php
include 'config.php';

$msg_box = "";
$errors = array();

$name = $_POST['name'];
$surname = $_POST['surname'];
$dateofbirth = $_POST['dateofbirth'];
$country = $_POST['country'];
$email = $_POST['email'];

if ($name = "") $errors[] = "Поле имени не заполнено";
if ($surname = "") $errors[] = "Поле фамилии не заполнено";
if ($dateofbirth = "") $errors[] = "Поле даты не заполнено";
if ($country = "") $errors[] = "Поле страны не заполнено";
if (($email == "") || (filter_var($email, FILTER_VALIDATE_EMAIL) == false)) {
    $errors[] = "Поле email не заполнено!";
}

if ($password = "") $errors[] = "Поле пароля не заполнено";
if ($repeat_password = "") $errors[] = "Поле повтора пароля не заполнено";
if ($password !== $repeat_password) {
    $errors[] = "Пароли не совпадают";
} else {
    $password = password_hash($_POST['password'], PASSWORD_DEFAULT);
}

if (empty($errors)) {
    $stmt = mysqli_prepare($connection, "INSERT INTO users (name, surname, dateofbirth, country, email, password) VALUES (?, ?, ?, ?, ?, ?)");

    mysqli_stmt_bind_param($stmt, "ssssss", $name, $surname, $dateofbirth, $country, $email, $password);

    mysqli_stmt_execute($stmt);
} else {
    echo "есть ошибка";
}


$connection->close();

When i make select * from users – it works right. i wanna create a new user in users via registration form.
console saying Failed to load resource: the server responded with a status of 500 (Internal Server Error) i have problem here:

try {
    r.send(i.hasContent && i.data || null)
} catch (e) {
    if (o)
        throw e
}

Microsoft Graph API PHP ODataError line 36 with no exception message when trying to use filter

I have installed and executed the basic example for MS Graph API through the PHP SDK. The examples contain a class named GraphHelper, which has a method getInbox:

public static function getInbox(): ModelsMessageCollectionResponse {
        $configuration = new MessagesRequestBuilderGetRequestConfiguration();
        $configuration->queryParameters = new MessagesRequestBuilderGetQueryParameters();
        // Only request specific properties
        $configuration->queryParameters->select = ['from','isRead','receivedDateTime','subject'];

        $configuration->queryParameters->filter = "(from/emailAddress/address) eq '[email protected]'";

        // Sort by received time, newest first
        $configuration->queryParameters->orderby = ['receivedDateTime DESC'];
        // Get at most 25 results
        $configuration->queryParameters->top = 25;
        return GraphHelper::$userClient->me()
            ->mailFolders()
            ->byMailFolderId('inbox')
            ->messages()
            ->get($configuration)->wait();
    }

If I omit the line $configuration->queryParameters->filter = "(from/emailAddress/address) eq '[email protected]'";, I get the 25 latest messages from my inbox. When I apply filter, no matter what filter I put, I get the following:

Error getting user's inbox: 

MicrosoftGraphGeneratedModelsODataErrorsODataError in /home/alexios/research/automation/finances/automation-finances-import/vendor/microsoft/microsoft-graph/src/Generated/Models/ODataErrors/ODataError.php:36
Stack trace:
#0 /home/alexios/research/automation/finances/automation-finances-import/vendor/microsoft/kiota-serialization-json/src/JsonParseNode.php(117): MicrosoftGraphGeneratedModelsODataErrorsODataError::createFromDiscriminatorValue()
#1 /home/alexios/research/automation/finances/automation-finances-import/vendor/microsoft/kiota-http-guzzle/src/GuzzleRequestAdapter.php(678): MicrosoftKiotaSerializationJsonJsonParseNode->getObjectValue()
#2 /home/alexios/research/automation/finances/automation-finances-import/vendor/microsoft/kiota-http-guzzle/src/GuzzleRequestAdapter.php(160): MicrosoftKiotaHttpGuzzleRequestAdapter->throwFailedResponse()
#3 /home/alexios/research/automation/finances/automation-finances-import/vendor/php-http/promise/src/FulfilledPromise.php(39): MicrosoftKiotaHttpGuzzleRequestAdapter->MicrosoftKiotaHttp{closure}()
#4 /home/alexios/research/automation/finances/automation-finances-import/vendor/microsoft/kiota-http-guzzle/src/GuzzleRequestAdapter.php(145): HttpPromiseFulfilledPromise->then()
#5 /home/alexios/research/automation/finances/automation-finances-import/vendor/microsoft/microsoft-graph/src/Generated/Users/Item/MailFolders/Item/Messages/MessagesRequestBuilder.php(73): MicrosoftKiotaHttpGuzzleRequestAdapter->sendAsync()
#6 /home/alexios/research/automation/finances/automation-finances-import/src/Microsoft/GraphHelper.php(80): MicrosoftGraphGeneratedUsersItemMailFoldersItemMessagesMessagesRequestBuilder->get()
#7 /home/alexios/research/automation/finances/automation-finances-import/bin/import.php(25): AlexiosTsiaparasAutomationFinancesImportMicrosoftGraphHelper::getInbox()
#8 /home/alexios/research/automation/finances/automation-finances-import/bin/import.php(85): listInbox()
#9 {main}

So, no error description whatsoever.

I got the filtering from https://learn.microsoft.com/en-us/graph/use-the-api#query-parameters, and checked out the Graph Explorer https://developer.microsoft.com/en-us/graph/graph-explorer.

The get my mails from an address example has the filter I am interested in:

https://graph.microsoft.com/v1.0/me/messages?$filter=%28from%2FemailAddress%2Faddress%29+eq+%27MiriamG%40M365x214355.onmicrosoft.com%27

I tried url encoding the filter, and not, the error remains the same.

Update

I tried to bypass the SDK, except for the access token, so I did the following:

$accessToken = GraphHelper::getUserToken();
// echo "Token: $tokenn";

$params = [
    'select' => ['from','isRead','receivedDateTime','subject'],
    'orderby' => ['receivedDateTime DESC'],
    'top' => 3,
    'filter' => "(from/emailAddress/address) eq '[email protected]'"
];

$ch = curl_init();
$url = 'https://graph.microsoft.com/v1.0/me/messages?'.http_build_query($params);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer " . $accessToken));
$output = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err = curl_error($ch);
curl_close($ch);

echo "HTTP status: $httpcodenError:n";
print_r($err);
echo "nOutputn------n";
echo $output;

Everything works and I manage to get a response back with expected results!

Symfony access_token.token_handler triggers before access_control. What is the best way to skip it for public routes?

I use token_handler to validate token. But I don’t need it for PUBLIC_ACCESS routes. The thing is it triggers before access_control.

Can I check somehow for a PUBLIC_ACCESS first? Or is there a better way to make public routes avoid this token_handler? What is the best way? (Symfony 7)

# AccessTokenHandler.php

readonly class AccessTokenHandler implements AccessTokenHandlerInterface
{
    public function __construct(private ApiTokenRepository $repository)
    {
    }

    public function getUserBadgeFrom(string $accessToken): UserBadge
    {
        $accessToken = $this->repository->findOneByValue($accessToken);
        if (is_null($accessToken) || !$accessToken->isValid()) {
            throw new BadCredentialsException('Invalid credentials.');
        }

        return new UserBadge($accessToken->getUser()->getUserIdentifier());
    }
}
# security.yaml

firewalls:
    main:
        json_login:
            check_path: sign_in
            username_path: email
            password_path: password
        access_token:
            token_handler: AppSecurityAccessTokenHandler
access_control:
    - { path: ^/auth, roles: PUBLIC_ACCESS }
    - { path: ^/*, roles: ROLE_USER }

Attribute values in variable products on shop/categories WooCommerce pages

In an online store on WooCommerce, I use code that displays certain product attributes on archive/category pages.

add_action( 'woocommerce_before_shop_loop_item_title', 'new_template_loop_product_meta', 20 );
function new_template_loop_product_meta() {
    global $product;

    $attrs_by_cats = [
        20 => [ 'pa_size' ],
    ];

    $attr_list = [
        'Size' => 'pa_size',
    ];

    if ( ! is_object( $product ) ) {
        $product = wc_get_product( get_the_id() );
    }

    $cats = $product->get_category_ids();

    if ( ! is_array( $cats ) ) {
        return;
    }

    $attrs = [];

    foreach ( $cats as $cat ) {
        if ( isset( $attrs_by_cats[ $cat ] ) ) {
            $attrs[] = $attrs_by_cats[ $cat ];
        }
    }

    $allowed_attrs = array_unique( array_merge( [], ...$attrs ) );

    echo '<div class="custom-attributes">';

    foreach ( $attr_list as $attr_title => $attr_name ) {
        if ( in_array( $attr_name, $allowed_attrs, true ) ) {
            show_attribute( $product, $attr_title, $attr_name );
        }
    }

    echo '</div>';
}
/* Show attr */
function show_attribute( $product, $attr_title, $attr_name ) {
if ( 'sku' === $attr_name ) {
    $attr = (string) esc_html( $product->get_sku() );
} else {
    $attr = $product->get_attribute( $attr_name );

    if ( ! $attr ) {
        return;
    }
    $attr = explode( ', ', $attr ); // convert the coma separated string to an array

    $attr_arr = []; // Initialize

    // Loop through the term names
    foreach ( $attr as $term_name ) {
        // Embed each term in a span tag
        $attr_arr[] = sprintf('<span class="attr-term">%s</span>', $term_name);
    }
    // Convert back the array of formatted html term names to a string
    $attr = implode(' ', $attr_arr);
}

if ( '' === $attr ) {
    return;
}

printf( '<div class="custom-attributes-text">%s: %s</div>', $attr_title, $attr);
}

With simple products this code works without problems. The problem is only with the attribute in variable products.

When creating a product I added sizes S, M, L and automatically created variations. Then for each size S, M and L I manually set the stock availability to 30.

Then, the size L is all sold out and I have 0 in stock. Except that on the product list page all sizes are shown, while S and M should be shown.

How can I fix this code so that it works with variable products?

Thanks in advance for your help!

Download PDF in Laravel 9 using barryvdh/laravel-dompdf give us a pdf file corrupted

trying to download file using barryvdh/laravel-dompdf from html render view

        // Generate the PDF from the HTML content
    $pdf = PDF::loadHTML($contract_document)->setPaper('a4', 'landscape')
                        ->setOption('zoom', 1.2)
                        ->setOption('footer-center', '')
                        ->setOption('footer-font-size', 5);

   
    return $pdf->download($ad_id . '.pdf');

it download file corrupted if if I open in pdf fire fox it give me the below error :

Invalid or corrupted PDF file.

PDF.js v4.7.18 (build: 9735a840a)
Message: Invalid PDF structure. viewer.mjs:12184:13
Uncaught (in promise) 
Object { message: "Invalid PDF structure.", name: "InvalidPDFException", stack: "BaseExceptionClosure@resource://pdf.js/build/pdf.mjs:453:29n@resource://pdf.js/build/pdf.mjs:456:2n" }

can you please advice ?