WordPress.org

Ready to get started?Download WordPress

Forums

Simple Ads Manager
Update to wordpress (2 posts)

  1. fdeflint
    Member
    Posted 1 year ago #

    Hello. After update to 3.5 appears this message:

    Notice: Undefined offset: 1 in /usr/home/cinema2000.es/web/wp-content/plugins/simple-ads-manager/admin.class.php on line 129

    How can i resolve this?
    Thank you

    http://wordpress.org/extend/plugins/simple-ads-manager/

  2. NelsNose
    Member
    Posted 1 year ago #

    I'm trying to figure this out, too.

    I've changed that line from:
    $version['spec'] = $subver[1];
    to
    $version['spec'] = isset($subver[1]) ? $subver[1] : NULL;

    Still testing, not guaranteed to work.

    My process:
    Here is the function in admin.class.php that includes line 129:

    public function getWpVersion() {
          global $wp_version;
          $version = array();
    
          $ver = explode('.', $wp_version);
          $version['major'] = $ver[0];
          $vc = count($ver);
          if($vc == 2) {
            $subver = explode('-', $ver[1]);
            $version['minor'] = $subver[0];
            $version['spec'] = $subver[1];
            $version['str'] = $version['major'].'.'.$version['minor'].((!empty($version['spec'])) ? ' ('.$version['spec'].')' : '');
          }
          else {
            $version['minor'] = $ver[1];
            $version['build'] = $ver[2];
            $version['str'] = $wp_version;
          } 
    
          return $version;
        }

    What I notice is that $wp_version is "3.5" in the latest WP.
    $ver is an array of the version parts (as separated by '.'), e.g. array(3, 5).

    $vc therefor equals 2.

    $subver is trying to create an array of the "5" part of "3.5", splitting at "-" which doesn't exist, so we have $subver = array(5) and $subver[1] doesn't exist (illegal offset).

    I'm not sure where this is being called, but it's safe to assume that $version (the returned variable) needs to be an array, so we can't just assign $version the value of $wp_version.

    We can do a shorthand conditional statement instead, assigning $version['spec'] the value NULL if $subver[1] is not set.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.