Skip to content

PHP Notices raised by cssconcat #5

Open
@westonruter

Description

@westonruter

When running unit tests for Customize Widgets Plus inside of Quickstart, I'm noticing PHP Notices being raised:

Only variable references should be returned by reference

/srv/www/wp-content/mu-plugins/http-concat/cssconcat.php:174
/srv/www/wp/wp-includes/class.wp-dependencies.php:219
/srv/www/wp/wp-includes/script-loader.php:653
/srv/www/wp/wp-includes/plugin.php:579
/srv/www/wp/wp-includes/class.wp-styles.php:39
/srv/www/wp-content/mu-plugins/http-concat/cssconcat.php:31
/srv/www/wp-content/mu-plugins/http-concat/cssconcat.php:191
/srv/www/wp/wp-includes/plugin.php:503
/srv/www/wp-tests/tests/phpunit/tests/customize/widgets.php:53
/srv/www/wp-tests/tests/phpunit/tests/customize/widgets.php:175

The code in question is:

class WPcom_CSS_Concat extends WP_Styles {
    // ...
    function &__get( $key ) {
        return $this->old_styles->$key;
    }
    // ...
}

I tried changing this method to:

    function &__get( $key ) {
        $value = $this->old_styles->$key;
        return $value;
    }

But then of course a different error is raised when wp_styles()->registered[ $key ] is attempted to be set:

Indirect modification of overloaded property WPcom_CSS_Concat::$registered has no effect

/srv/www/wp/wp-includes/class.wp-dependencies.php:221
/srv/www/wp/wp-includes/functions.wp-styles.php:116
/srv/www/wp-content/plugins/jetpack/_inc/genericons.php:11
/srv/www/wp/wp-includes/plugin.php:503
/srv/www/wp-tests/tests/phpunit/tests/customize/widgets.php:53
/srv/www/wp-tests/tests/phpunit/tests/customize/widgets.php:175

I think perhaps the approach for extending WP_Styles needs to be changed. Instead of storing the original instance of WP_Styles inside of the WPcom_CSS_Concat instance, I think it should be fully re-using all of its properties directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions