New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use deprecated object creation internally #92

Closed
NielsdeBlaauw opened this Issue Oct 30, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@NielsdeBlaauw
Copy link
Contributor

NielsdeBlaauw commented Oct 30, 2017

Problem

Intern triggered Clarkson Core nog een notice dat er geen WordPress Object geïnitieerd mocht worden via een post_id. Is nu verholpen.

These lines:

https://github.com/level-level/Clarkson-Core/blob/0.2.0/lib/clarkson-core-objects.php#L61
https://github.com/level-level/Clarkson-Core/blob/0.2.0/lib/clarkson-core-objects.php#L64

And more use a deprecated way of instantiating objects.

How to test

In your functions.php of a Clarkson Theme.

echo 'new Clarkson( 32 )';
$post1 = new Clarkson_Object( 32 );

echo 'Clarkson::get( 32 )';
$post2 = Clarkson_Object::get( 32 );

$cco = \Clarkson_Core_Objects::get_instance();
echo 'cc->get_objects( [ 32,10 ] ) with IDs which triggers notices';
$cco->get_objects( [ 32, 10] );

echo 'get_object with ID triggers notice';
$cco->get_object( 32 );


echo 'get_objects with WP_post = no notice';
$wp_post_32 = get_post( 32 );
$cco->get_object( $wp_post_32 );

@jmslbam jmslbam added this to the 0.3.0 milestone Apr 18, 2018

jmslbam added a commit that referenced this issue Apr 19, 2018

@rianrietveld

This comment has been minimized.

Copy link
Member

rianrietveld commented Jun 27, 2018

Tested:
If the object is called with a post id the notice

PHP Deprecated:  Deprecated __construct called with an ID. Use '::get(post)' instead. in /srv/www/clarkson/public_html/wp-content/mu-plugins/clarkson-core/wordpress-objects/Clarkson_Object.php on line 45

f the object is called with a post object there was no warning.

$cco = \Clarkson_Core_Objects::get_instance();
$wp_post_7 = get_post( 7 );
$cco->get_object( $wp_post_7 );

print_r( $cco->get_object( $wp_post_7 ) ); displayed the proper post object.

Seems ok with me.

@rianrietveld

This comment has been minimized.

Copy link
Member

rianrietveld commented Jun 27, 2018

I manually merged #116 into #118
Code props to @jmslbam

@jmslbam

This comment has been minimized.

Copy link
Contributor

jmslbam commented Jul 12, 2018

@jmslbam jmslbam closed this Jul 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment