MyBB Community Forums

Full Version: [SOLVED] Missing posts after upgrade from 1.6 to 1.8.35
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
That was a not good feedback I got from an user today. Confused

After the upgrade I looked around, created and edited some posts, but I didn't looked for this kind of issue.
You can see a couple of posts missing in this thread pointed by the user - I hope there are no much in this situation.

Does someone has any idea about what happened and how could I recover it from an backup?
I can imagine I will have to be able to access the database and select the missing posts and look for them in the backup to generate an insert script.
Start with this query to see the extent of the problem.
SELECT * FROM `mybb_posts` where message=""; 

The good thing is that it appears the rest of the data is there. i.e. the message is blank rather than the entire post just *poofed*.

MyBB throws an error when creating a post with no message, so any MyBB forum should end up with a null result on this query.

On my forum (migrated from the 1.6 era to 1.8.9 and onwards) with 500K posts, there is only one row with a blank message field. That post was immediately followed by one in which the member stated his tablet glitched or something. So it is possible to find a server/browser hiccup.

Hope your count is very low. Good luck.
HLFadmin, thanks for the tip.

(2023-08-15, 10:11 AM)Devilshakerz Wrote: [ -> ]This may be relevant: https://docs.mybb.com/1.8/faq/errors/#pa...ion-failed
Indeed.
Because of it I just took a look into the post (by Editing) and I saw the content is there.

By checking all of them I noticed it's related to img tag. For instance, the first (blank) post has a couple of images from imgur.com:

[ img link=https://i.imgur.com/UcM5364.png]https://i.imgur.com/UcM5364.png[/img]

The other posts that are showing the images (including the imgur.com) uses this syntax:
[ img]https://i.imgur.com/XUwxdW2.jpg[/img]
[ url=https://imgbb.com/] [ img]https://i.ibb.co/72MynJJ/h1.png[/img] [/url]

So, the issue you pointed makes sense - the problem seemed to be in a custom code. I knew there are some custom code I inherited when I assumed its maintenance and by checking them I found that one:
[Image: mycode-img.png] [Image: mycode-img-sandbox.png]
I already checked that custom class used and it was added to global.css.
I don't see nothing special on it to start to fail except for something that was changed in the current version that now cannot "parse" this code.

Also, as shown, in the Sandbox I'm able to test it with success. So, why it doesn't works on the posts remains strange.
Looks like there are some missing quotes in the Replacement HTML.

Try:
<a href="$1"><img src="$2" class="post_image" title="Click to view image" /></a>
(2023-08-15, 07:22 PM)Devilshakerz Wrote: [ -> ]Looks like there are some missing quotes in the Replacement HTML.

Try:
<a href="$1"><img src="$2" class="post_image" title="Click to view image" /></a>
Thanks Devilshakerz, this worked.
But, not without a "divine inspiration". Big Grin

After I update the content of "Replacement" text with the one you sent me - and save it - I refreshed that forum page and nothing happened.
Then, I entered in edit mode of my_code again and for my surprise the contente was still the old one. I changed the "Regular Expression" and after save it I checked it back and it was OK (kept the changes).

So, the way to get the proper replacement saved was to create a new one. Now the page is showing almost all images correctly.

There is an image that has an extra parameter
[img size=15x150 link=https://i.imgur.com/1zdae1p.png]https://i.imgur.com/1zdae1p.png[/img]

It seems the previous code was not working too, so I changed it to:
Replacement:
\[img size=(.*?)x(.*?) link=(.*?)\](.*?)\[/img\]
Regular Expression:
<a href="$3"><img src="$4" class="post_image" width="$1" height="$2" title="Click to view image" /></a>
HTML Result:
[img size=150x150 link=https://i.imgur.com/1zdae1p.png]https://i.imgur.com/1zdae1p.png[/img]

The only think I see different is the fact that we are using the latest parameters first. Do they need to be in order?

The previous was only:
\[img size=(.*?)x(.*?)\](.*?)\[/img\]
and its order of execution was 2.

Quote:Replacement:
\[img size=(.*?)x(.*?) link=(.*?)\](.*?)\[/img\]
Regular Expression:
<a href="$3"><img src="$4" class="post_image" width="$1" height="$2" title="Click to view image" /></a>
HTML Result:
[img size=150x150 link=https://i.imgur.com/1zdae1p.png]https://i.imgur.com/1zdae1p.png[/img]
I fixed this one by removing and creating it again.

Definably something is strange after the update - hard to know what or where.



There is only one image (here) in that forum page that is not getting formatted and it's a simple [img] tag - which should result in the image be downsized to 600px max (<a href="$1"><img src="$1" style="max-width:600px; max-height:600px;" title="Click to view image"></img></a>), but it's still big (which works fine when editing and using "Test MyCode" buttom).

By checking the page source I noticed that image has a class assigned to it named: "mycode_img".

I found that it may be result of a fail in evaluate the template in ./inc/class_parser.php:
...
eval("\$mycode_img = \"".$templates->get("mycode_img", 1, 0)."\";");
return $mycode_img;

The strange thing is that other images were processed correctly. Confused


Let's keep digging.
(2023-08-15, 10:43 PM)Micheus Wrote: [ -> ]The only think I see different is the fact that we are using the latest parameters first. Do they need to be in order?

The capturing groups can be referenced in any order.

Quote:There is only one image (here) in that forum page that is not getting formatted and it's a simple [img] tag - which should result in the image be downsized to 600px max (<a href="$1"><img src="$1" style="max-width:600px; max-height:600px;" title="Click to view image"></img></a>), but it's still big (which works fine when editing and using "Test MyCode" buttom).

By checking the page source I noticed that image has a class assigned to it named: "mycode_img".

I found that it may be result of a fail in evaluate the template in ./inc/class_parser.php:
...
eval("\$mycode_img = \"".$templates->get("mycode_img", 1, 0)."\";");
return $mycode_img;

The strange thing is that other images were processed correctly. Confused

In-built MyCodes have higher priority, so the default [img] with a class="mycode_img" is applied instead.

You can, however, use that class to add the styles to a stylesheet file of your theme (e.g. global.css) for the same effect:
.mycode_img {
  max-width: 600px;
  max-height: 600px;
}
(2023-08-16, 10:11 PM)Devilshakerz Wrote: [ -> ]You can, however, use that class to add the styles to a stylesheet file of your theme (e.g. global.css) for the same effect:
.mycode_img {
  max-width: 600px;
  max-height: 600px;
}
Thanks for the tip.
I did that to the img style in the same global.css. Although I don't understand from where that class="mycode_img" cames from. I checked the changed postbit* templates and I couldn't find it anywhere.

What I don't like in this way is the missing link to see in full size (in case it be downscaled) - which I could set via MyCode.
But, that is what I can have.


Thank you all for the assistance and patience.
/Micheus
The parser uses the MyCode Templates → mycode_img template as replacement HTML for each found tag.

You can modify that template in your forum's theme to similarly wrap the image HTML in <a href="{$url}"> ... </a> to create a link.