• Resolved marknjones

    (@marknjones)


    Hi.

    Since updating from 4.5.6 to 4.5.7 I see a new error on my site. I’ve created my own shortcode, which uses do_shortcode on one of *your* shortcodes, to give document links in a certain format:

    [download_data data='download_link' id='" . $atts['word'] . "']

    That worked (and still works) fine on 4.5.6, but on 4.5.7 whenever I try to save a page which contains my shortcode, I get a critical error. If I disable Download Monitor I can save the page no problem. The rest of the site continues to work correctly – it’s only pages which contain my shortcode which cause the error:

    Error Details
    =============
    An error of type E_ERROR was caused in line 179 of the file /www/wp-content/plugins/download-monitor/src/Admin/CustomColumns.php. Error message: Uncaught ArgumentCountError: Too few arguments to function DLM_Custom_Columns::prepend_id_to_title(), 1 passed in /wordpress/wp-includes/class-wp-hook.php on line 307 and exactly 2 expected in /www/wp-content/plugins/download-monitor/src/Admin/CustomColumns.php:179
    Stack trace:
    #0 /wordpress/wp-includes/class-wp-hook.php(307): DLM_Custom_Columns->prepend_id_to_title('To Donate')
    #1 /wordpress/wp-includes/plugin.php(189): WP_Hook->apply_filters('To Donate', Array)
    #2 /www/wp-content/themes/make/inc/sections/columns/frontend-template.php(13): apply_filters('the_title', 'To Donate')
    #3 /www/wp-content/themes/make/inc/builder/core/api.php(722): require('/www/wp-content...')
    #4 /www/wp-content/themes/make/inc/builder/core/save.php(388): ttfmake_get_template('sections/column...')
    #5 /www/wp-content/themes/make/inc/builder/core/save.php(345): TTFMAKE_Builder_Save->generate_post_content(Array)
    #6 /wordpress/wp-includes/class-wp-hook.php(309): TTFMAKE_Builder_Save->wp_insert_post_data(Array, Array)
    #7 /wordpress/wp-in

    … and the error text cuts off there.

    • This topic was modified 2 years, 8 months ago by marknjones.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Razvan Aldea

    (@raldea89)

    Hey @marknjones ,

    In version 4.5.7 we made some modifications to the way the title is displayed so we hooked a function to WordPress’ the_title hook. It seems you are trying to apply the same filter in your frontend-template.php file, but you are applying it wrong. As you can see here the hook needs 2 arguments, the string ( To donate in your case ) and the ID of the post, which you are missing. This will trigger error not only with our plugin but with every plugin/snippet that may attach to WordPress’ hook and that require not only the string but the ID too ( as in our case ).

    So, please apply the filter as intended/correctly and should be OK.

    Kind Regards!
    Razvan

    Actually, I had the same problem. I had the_title-filters before, and they worked fine. After the update to 4.5.7 I get a fatal error:

    PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function DLM_Custom_Columns::prepend_id_to_title(), 1 passed in /public_html/wp-includes/class-wp-hook.php on line 307 and exactly 2 expected in /public_html/content/plugins/download-monitor/src/Admin/CustomColumns.php:179

    If you look closely at the documentation that you @raldea89 linked to, you see that they write it like so:
    function suppress_if_blurb( $title, $id = null ) {

    As soon as I changed public function prepend_id_to_title( $title, $id ){ to public function prepend_id_to_title( $title, $id = null){ (in /public_html/content/plugins/download-monitor/src/Admin/CustomColumns.php) it started working.

    Plugin Author Razvan Aldea

    (@raldea89)

    Hey @annlickander ,

    Firstly, thank you very much for the input.

    What you say about the $id = null was an inconsistency that was introduced in WP 3.1 and fixed in WP 3.3 ( back in 2011 ), as the user that you mentioned said. So the correct use of the filter, outside of WordPress ( as WP since 3.3 uses 2 arguments everywhere ), still should be with 2 arguments, as it’s a WP Core filter.

    If the problem lies within a theme please contact the theme’s author or if you are using custom code please update the code so that it corresponds to the correct use of the the_title filter.

    Warmly,
    Razvan

    Well… You were right. There was a problem in the theme and not what I first thought. Because this theme was built a looong time ago, we still had $id = null in our function. And when adding that to your code, everything worked.

    But yeah. Found the real culpit, which, lo and behold, were a missing argument. Sorry and thank you for triggering the error hehe

    Plugin Author Razvan Aldea

    (@raldea89)

    Glad it all worked for the best and hey, it’s all well when it ends well, right? ??

    Have a wonderful day!

    Best wishes!
    Razvan

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Critical error on saving page with shortcode’ is closed to new replies.