Internal Server Error – No limit on posts

Posted in: Newspaper
Post count: 20

Hi,

I noticed that if i provide an invalid parameter on p, for example https://www.agrinio-sports.gr/?p=invalid
i get internal server error. The reason is that the memory is being exhausted because it tries to load ALL the posts since day one and show them. No matter how i increase the memory, the issue persists. I even tried with 1GB limit just out of curiosity.
One of the files that is involved in the process is /plugins/td-composer/legacy/Newspaper/loop.php which loop through the files.
Is it possible to either limit the posts with paging, or just return a 404 in case the post provided in the parameter is not valid?

Thanks

Post count: 27744

Hello,

I checked with other parameters and this problem does not appear.
The parameter ‘p’ is for querying a post, as opposed to ‘page_id’ for querying a page -> https://wordpress.stackexchange.com/questions/265307/how-to-remove-p-from-wordpress-short-links

Thank you!

Post count: 20

Hello,

I am not sure i understood the suggestions on the link you provided. Can you be more specific about this solution and in which reply you are referring to as there are three different suggested solutions?
Also, is there a way to fix it without disabling the parameter? Such as paging the posts that are being queried?

Thanks

Post count: 35449

Hi andreaskas,
First you’ll need to make sure that you do not have other extra plugins that are interfering with the theme permalinks, so, please make a test using only tagDiv plugins and check to see if the problem persist. Also you can try changing the permalinks structure.
The last option will be to use a redirect, in case that the “/?p=invalid” parameter is set in your website permalink top be redirect to a specific page.
Thank you!

Post count: 20

Hi Calin,

The problem persists even with the rest of the plugins deactivated. Can you please elaborate on how to achieve the redirect part you mentioned in case the parameter refers to an invalid post. Such as redirecting the user to the 404 page.

Thanks

Post count: 35449

I see.
Then please try one of the redirect methods from this guide: https://blog.hubspot.com/website/10-best-redirect-wordpress-plugins
I hope this will help you!

Post count: 20

Hello,

I just remembered that in the past, i had fixed the issue by placing the following PHP block in the index.php of the theme the following code but it’s not working in Newspaper. Can you please elaborate on where to place it in order to make it work for your theme as well.


$post_id = filter_input(INPUT_GET, 'p');
if (!empty($post_id) && get_post_meta($post_id) === FALSE) {
get_template_part('404');
die();
}

Post count: 35449

Hi andreaskas,
Maybe that code need to be set in functions.php, you can try to set it on this file path -> wp-content/plugins/td-composer/legacy/Newspaper/functions.php
I hope this will help you!

Viewing 8 posts - 1 through 8 (of 8 total)
The forum ‘Newspaper’ is closed to new topics and replies.