[Plugin: Advanced Post List] Maximum execution time after update
-
Love this plugin but I’m encountering some difficulties after updating to 0.3.b2. When I try to access the settings, I’m receiving a “Maximum execution time” error. 0.2.0 worked fine and continues to work after downgrading.
Any ideas?
https://www.ads-software.com/extend/plugins/advanced-post-list/
-
thanks for the reply! i use the “custom post type UI” plugin. this is the only custom post type plugin i ever used on this site.
however i also use the custom post type UI on my test site where APL runs properly. it just doesn’t work on the real site. i tired deactivating all the other plugins but that doesn’t help.
so i have no idea what could be the problem.btw: APL is a great plugin (when it works), you guys do a really great job and a hope that this problem will get fixed too.
Thank you for the feedback. I believe it has something to do with CPT, and it may be awhile til I can provide a proper fix. So, for the time being, I would recommend using version 0.2.0. The only downside is that it doesn’t support CPT.
Sorry I can’t provide an ideal solution right now, but it is an issue that I’ll need time to investigate.
I’ve had a little bit of time to look into this issue a little further, and there’s one problem on my side. I’m having a difficult time trying to reproduce the issue. The sanitize_post function is triggered when there is ‘raw’ data found, and everything on my side keeps using proper data.
My guess right now is that what ever is being passed into that function doesn’t match up to WordPress’s configuration. This could be a post type, taxonomy, or page saved in the database, and this isn’t because of the APL Plugin necessarily, but I can create something to fall back on. Some other plugin’s also use post types in a different fashion, and if that’s the case, I could set it up to ignore it. Especially if it has no relation to the APL plugin’s purpose.
I’m unable to get my stuff to debug inside the function, and since you already have the event being triggered. Could you modify the function where the error is occurring? …and then post the results?
Old function
function sanitize_post($post, $context = 'display') { if ( is_object($post) ) { // Check if post already filtered for this context if ( isset($post->filter) && $context == $post->filter ) return $post; if ( !isset($post->ID) ) $post->ID = 0; foreach ( array_keys(get_object_vars($post)) as $field ) $post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context); $post->filter = $context; } else { // Check if post already filtered for this context if ( isset($post['filter']) && $context == $post['filter'] ) return $post; if ( !isset($post['ID']) ) $post['ID'] = 0; foreach ( array_keys($post) as $field ) $post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context); $post['filter'] = $context; } return $post; }
Modified function
function sanitize_post($post, $context = 'display') { if ( is_object($post) ) { // Check if post already filtered for this context if ( isset($post->filter) && $context == $post->filter ) return $post; if ( !isset($post->ID) ) $post->ID = 0; //Modify this foreach, add brackets and the echo line foreach ( array_keys(get_object_vars($post)) as $field ){ echo '$field = ' + $field + '\n$post->field = ' + $post->$field + '\n$post->ID = ' + $post->ID + '\n$context = ' + $context + '\n\n'; $post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context); } $post->filter = $context; } else { // Check if post already filtered for this context if ( isset($post['filter']) && $context == $post['filter'] ) return $post; if ( !isset($post['ID']) ) $post['ID'] = 0; foreach ( array_keys($post) as $field ) $post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context); $post['filter'] = $context; } return $post; }
Sorry for a late reply. A lot going on in the world today.
hi!
thank you for your work!
i tried the code as you suggested, pasted it into post.php replacing the old code with the modified one.Basically it leaves me with the same error message.
A few things did change though. The main menu disappeared from the site, weird long lines of numbers appeared at the header and at the widgets. On the backend the dashboard disappeared completely leaving only the left side menu functional.Clicking on settings/advanced post list the same extremely long line of numbers appears that distorts the screen and that also appears on the main page. A little time later this numbers disappear and i am faced with the old too familiar error message “Fatal error! Maximum execution time of 30 seconds exceeded in […]/wp-includes/post.php on line 1728”.
(i returned to the original version of the code)
so these are the results that i can post.
thank you so much for trying to help!
I should of thought twice about posting that since I have a better method that I forgot about, but I do have a good lead now, and thank you for taking the time to provide some feedback. It definitively helps.
I would prefer providing you with more information, but I need a little more time to review what I have now, and I need to catch some sleep. Ran out of time for the night. I at least wanted to give you with some kind of update, and I’ll be posting more information later.
Ok, I was able to debug inside the function to better understand what was going on. If I was to ask you if your site has quite a bit of posts/pages, and your response is yes. Then I’m fairly certain now that I have a fix for this.
Original
(Version 0.3.b5)
/wp-content/plugins/advanced-post-list/includes/APL-admin.php
Function at Line 218function APL_get_page_heirarchy($page_settings = array('post_type_name' => 'post'), $parent = 0, $depth = -1) { $rtnString = ''; $dashes = ''; if ($depth == -1) { $rtnString .= '<option id="slctChkCurrent-' . $page_settings['post_type_name'] . '" value="' . 0 . '"><b>Current Page</b></option>'; } $depth++; for ($i = 0; $i < $depth; $i++) { $dashes .= '-'; } $argPages = array('numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_type' => $page_settings['post_type_name']); $pages = get_posts($argPages); foreach ($pages as $page) { if ($page->post_parent == $parent) { $id = $page->ID; $rtnString .= '<option value="' . $page->ID . '">' . $dashes . $page->post_title . '</option>'; $rtnString .= APL_get_page_heirarchy($page_settings, $id, $depth); } } return $rtnString; }
Modified
function APL_get_page_heirarchy($page_settings = array('post_type_name' => 'post'), $parent = 0, $depth = -1) { $rtnString = ''; $dashes = ''; if ($depth == -1) { $rtnString .= '<option id="slctChkCurrent-' . $page_settings['post_type_name'] . '" value="' . 0 . '"><b>Current Page</b></option>'; } $depth++; for ($i = 0; $i < $depth; $i++) { $dashes .= '-'; } $argPages = array( 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_type' => $page_settings['post_type_name'], 'post_parent' => $parent ); $pages = get_posts($argPages); foreach ($pages as $page) { if ($page->post_parent === $parent) { $id = $page->ID; $rtnString .= '<option value="' . $page->ID . '">' . $dashes . $page->post_title . '</option>'; $rtnString .= APL_get_page_heirarchy($page_settings, $id, $depth); } } return $rtnString; }
This should speed things up 60-80 times faster than what it was. Depending on how deep your site’s page hierarchy is. For now, to keep it simple, all I did was add the post_parent filter (which I thought I did add, must have missed it) to prevent having to process unnecessary data, but I do plan on optimizing it further for the next update. Before I add 0.3.b6 though, I need to get some other issues fixed, but for now, this should fix it. Please let me know how it turns out though.
wow!!!
Thanks! It works! Just like on the test site. No more error message when I click on Settings/Advanced Post List, it loads the settings page nice and easy. Beautiful!
Yes, I have quite a few posts and pages… 16 pages and 547 posts to be exact with 10 categories and 355 tags. But APL loads pretty quick now with no more maximum execution time warning!
Thank you so much for your work and time and that you have such great support for this plugin! Thanks!
- The topic ‘[Plugin: Advanced Post List] Maximum execution time after update’ is closed to new replies.