• It’s probably never been a good idea, but PHP is getting stricter about not allowing class variables to be declared dynamically. Most of your code has an easy fix, but you have one place that will need some more thought. I’ve included code to disable the warning, but presumably you should work harder than I did to clean up the code.

    I started out making them all public to be safe, but there were some that were obvious (theoretically) that shouldn’t be public, so again, you can do a better job than I did.

    Modified:
    customer//dev/wp-content/plugins/badgeos-badgestack-add-on/badgeos-badgestack.php
    customer//dev/wp-content/plugins/badgeos-community-add-on/badgeos-community.php
    customer//dev/wp-content/plugins/badgeos/badgeos.php
    customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/autoload.php
    customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/connection-type.php
    customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/side-post.php
    customer//dev/wp-content/plugins/badgeos/includes/p2p/scb/AdminPage.php
    Log:
    PHP deprecation warnings (undeclared class variables dynamically created)

    Modified: customer//dev/wp-content/plugins/badgeos/badgeos.php
    ===================================================================
    --- customer//dev/wp-content/plugins/badgeos/badgeos.php 2024-06-09 10:29:56 UTC (rev 30066)
    +++ customer//dev/wp-content/plugins/badgeos/badgeos.php 2024-06-09 10:32:20 UTC (rev 30067)
    @@ -68,6 +68,8 @@
    */
    public $mysql_deduct_points;

    + public $basename, $directory_path, $directory_url, $start_time, $award_ids, $achievement_types, $award_points_activity_triggers, $deduct_points_activity_triggers, $badgeos_ranks_req_activity_triggers, $activity_triggers;
    +
    /**
    * Define class constants and hooks for displaying Comments.
    *

    Modified: customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/autoload.php
    ===================================================================
    --- customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/autoload.php 2024-06-09 10:29:56 UTC (rev 30066)
    +++ customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/autoload.php 2024-06-09 10:32:20 UTC (rev 30067)
    @@ -1,7 +1,7 @@
    <?php

    class P2P_Autoload {
    -
    + public $prefix, $basedir;
    protected function __construct( $prefix, $basedir ) {
    $this->prefix = $prefix;
    $this->basedir = $basedir;

    Modified: customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/connection-type.php
    ===================================================================
    --- customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/connection-type.php 2024-06-09 10:29:56 UTC (rev 30066)
    +++ customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/connection-type.php 2024-06-09 10:32:20 UTC (rev 30067)
    @@ -1,5 +1,5 @@
    <?php
    -
    +#[AllowDynamicProperties]
    class P2P_Connection_Type {

    public $side;
    @@ -9,7 +9,8 @@
    public $labels;

    protected $title;
    -
    + public $fields, $strategy;
    +
    public function __construct( $args, $sides ) {
    $this->side = $sides;

    @@ -26,7 +27,8 @@

    $this->fields = $this->expand_fields( _p2p_pluck( $args, 'fields' ) );

    - foreach ( $args as $key => $value ) {
    + foreach ( $args as $key => $value ) {
    + // creating class variables dynamically is deprecated as of PHP 8.2
    $this->$key = $value;
    }
    }

    Modified: customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/side-post.php
    ===================================================================
    --- customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/side-post.php 2024-06-09 10:29:56 UTC (rev 30066)
    +++ customer//dev/wp-content/plugins/badgeos/includes/p2p/p2p-core/side-post.php 2024-06-09 10:32:20 UTC (rev 30067)
    @@ -3,7 +3,8 @@
    class P2P_Side_Post extends P2P_Side {

    protected $item_type = 'P2P_Item_Post';
    -
    + protected $query_vars;
    +
    function __construct( $query_vars ) {
    $this->query_vars = $query_vars;
    }

    Modified: customer//dev/wp-content/plugins/badgeos/includes/p2p/scb/AdminPage.php
    ===================================================================
    --- customer//dev/wp-content/plugins/badgeos/includes/p2p/scb/AdminPage.php 2024-06-09 10:29:56 UTC (rev 30066)
    +++ customer//dev/wp-content/plugins/badgeos/includes/p2p/scb/AdminPage.php 2024-06-09 10:32:20 UTC (rev 30067)
    @@ -20,6 +20,7 @@
    * $admin_action_priority int The priority that the admin_menu action should be executed at (default: 10)
    */
    protected $args;
    + protected $nonce;

    // URL to the current plugin directory.
    // Useful for adding css and js files

    Modified: customer//dev/wp-content/plugins/badgeos-badgestack-add-on/badgeos-badgestack.php
    ===================================================================
    --- customer//dev/wp-content/plugins/badgeos-badgestack-add-on/badgeos-badgestack.php 2024-06-09 10:29:56 UTC (rev 30066)
    +++ customer//dev/wp-content/plugins/badgeos-badgestack-add-on/badgeos-badgestack.php 2024-06-09 10:32:20 UTC (rev 30067)
    @@ -26,7 +26,7 @@
    */

    final class BadgeOS_BadgeStack {
    -
    + public $basename, $directory_path, $directory_url;
    function __construct() {
    // Define plugin constants
    $this->basename = plugin_basename( __FILE__ );

    Modified: customer//dev/wp-content/plugins/badgeos-community-add-on/badgeos-community.php
    ===================================================================
    --- customer//dev/wp-content/plugins/badgeos-community-add-on/badgeos-community.php 2024-06-09 10:29:56 UTC (rev 30066)
    +++ customer//dev/wp-content/plugins/badgeos-community-add-on/badgeos-community.php 2024-06-09 10:32:20 UTC (rev 30067)
    @@ -30,7 +30,7 @@
    register_activation_hook( __FILE__, array( 'BadgeOS_Community', 'activate' ) );

    class BadgeOS_Community {
    -
    + public $basename, $directory_path, $directory_url, $community_triggers;
    function __construct() {

    // Define plugin constants
    @@ -216,4 +216,4 @@
    }

    }
    -$GLOBALS['badgeos_community'] = new BadgeOS_Community();
    \ No newline at end of file
    +$GLOBALS['badgeos_community'] = new BadgeOS_Community();

  • You must be logged in to reply to this topic.