Mar 142015
 

Some time ago, on Aquoid forum, an user complaint about this problem: when he tried to see the preview of a post he get this warning displayed on his page: Warning: Illegal offset type in isset or empty in …………………/wp-includes/post.php on line 1151.

Illegal Offset WarningAs I didn’t saw this error on any of sites whit Suffusion which I monitoring and no other user complaint about this we deduced that was something wrong with his hosting – by reinstalling the database, the problem was solved. At that time I wasn’t able to find what exactly was the root of the problem and, of course, I wasn’t able to provide a definite solution.

But, few days ago, Alex Zevallos, a friend which developing a very nice site for his wife at https://bellabodyinc.com/, complain to me about the same error and give me the possibility to check what’s happens.

First of all, in Alex case was just this warning, the preview working just fine, despite this message. So, the post was displayed in preview, but it just had this message at the bottom. Probably this is the reason for not being more reports about the problem, even if others saw the message, said “so, what? I see what I need, let’s forget about the warning.” Being in preview mode, the warning not appear for visitors so, the site will not have any problem with this.

Digging for the root of problem I found this. The problem come indeed from Suffusion, in some conditions the message appear instead of post navigation. There usually are the titles of previous/next published posts as are settled at Suffusion Options -> Other Graphical Elements -> Breadcrumbs and Page Navigation -> Previous – Next Posts. For some reason the function which test if the posts belongs the same category or not, don’t return the expected value, but an empty value or an array which cannot be used for retrieving the categories. Because of this error, the page don’t show the navigation, but the error message instead.

But why this happening? Digging more I’ve found that the database is using InnoDB engine, not MyISAM as all other WP sites which I saw are using. I checked then another site hosted on GoDaddy, which have mixed engines, some tables are using InnoDB, some MyISAM. The same warning message.

So, the warning is triggered in very rare cases when is using InnoDB as MySQL engine. I see this only on these sites hosted on GoDaddy. A representative of GoDaddy said: “GoDaddy uses InnoDB because it is more secure than MyISAM. InnoDB does not allow remote access, MyISAM does.”

Now, knowing from where the problem come, let’s see the solution. As I said, the message is displayed instead of post navigation. The post navigation is controlled by prev-next.php file located under suffusion/custom/ folder. Being in custom folder the file is pluggable and can be copied and changed in a child theme. The content of this file is very short:

As you can see, the code test if you have settled to show the posts from the same category or from any category then display a table with those links. On tables based on InnoDB engine the result of the queries can be slightly different than on MyISAM tables. So, probably the query which retrieve the categories return an unexpected result in this case, hence that warning.

But first of all we don’t need those 2 links in preview mode, we use the preview mode for adjusting the actual post, for what can use the post navigation in preview? So, the solution is very simple. I changed the file to show the posts navigation only if the post is not in preview mode:

In conclusion, if your host use InnoDB engine for MySQL database, can download the modified file from here Download patched prev-next.php, make a subfolder named custom in your child theme folder, then upload my file there.