• Resolved Wil

    (@limecanvas)


    Hey Dion

    The plugin is generating the following PHP error
    Error: Non-static method Plugin_Revision_Control_Compat::options() should not be called statically, assuming $this from incompatible context

    Stack trace
    /plugins/revision-control/revision-control.php (252)
    /plugins/revision-control/revision-control.php (25)
    /plugins/revision-control/revision-control.php (10)

    Cheerz,
    Wil.

    https://wordpress.org/plugins/revision-control/

Viewing 7 replies - 1 through 7 (of 7 total)
  • The fix is easy, classes are called statically and the function definition is using old conventions when static methods didn’t exist (before PHP 5.2). In other words procedural functions inside a class but its an easy fix.

    Look at this diff and do the same. I might push upstream the fix someday.

    diff --git i/revision-control.php w/revision-control.php
    index d0d3958..ade99f9 100644
    --- i/revision-control.php
    +++ w/revision-control.php
    @@ -299,7 +299,7 @@ class Plugin_Revision_Control {
     }
    
     class Plugin_Revision_Control_Compat {
    - function postmeta($meta, $post) {
    + public static function postmeta($meta, $post) {
        if ( is_array($meta) )
          return $meta;
    
    @@ -318,7 +318,7 @@ class Plugin_Revision_Control_Compat {
        return $_meta;
      }
    
    - function options($options) {
    + public static function options($options) {
        $_options = $options;
        if ( ! is_array($options) ) { // Upgrade from 1.0 to 1.1
          $options = array( 'post' => $options, 'page' => $options );

    @renoirb
    yeah… I’m sure it is easy for you but I am not so familiar with diff so your display says nothing to me 🙁

    Would you please just put it simple like showing what should I replace with what?

    Thank you in advance.

    Hey Tom,

    Here’s a TL;DR version of how diff works.

    Lines starting by +++ and — are saying which files are involved and what symbol (add ‘+’, remove ‘-‘) each file has different from the other. In this case its a diff between two versions of the same file.

    Lines with @@ is to describe where in terms of line number, column. Gives hint which line to get to.

    Now the fix is to add ‘public static’. In front of the word ‘function’ for the two methods of that class.

    There are two ways to use classes. As a container of functions which we refer as calling “statically” which is the case here.

    Quixk way to assess? When its called Foo::postmeta(…) compared to

    $foo = new FooClass();
    echo $foo->bar(‘bazz’);

    @renoirb
    Thank you for short tutorial 🙂
    I think I was able to identify all 2 places where I had to add “public static” in front of proper functions. Lines were different but it helped globally. I do not have errors appearing on frontend and there is still one place failing. When I go to Settings -> Revision Control I get:

    Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Plugin_Revision_Control_UI::admin_page() should not be called statically in /home/.../public_html/wp-includes/plugin.php on line 496

    Maybe it is negligible but I ask just in case.

    Plugin Author Dion Hulse

    (@dd32)

    Meta Developer

    This was fixed in the development version that was eventually abandoned.

    I’ve just released 2.3.1 which includes a fix for the PHP Warnings and also fixes a nonce change in WordPress.

    Thanks Dion,
    No errors. No warnings.
    It looks like it is working now!

    Thread Starter Wil

    (@limecanvas)

    Yup confirm – no errors. Thanks Dion & Happy 2015!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘PHP Errors’ is closed to new replies.