[wp-trac] [WordPress Trac] #43498: PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted

WordPress Trac noreply at wordpress.org
Thu Mar 8 21:44:12 UTC 2018


#43498: PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted
-------------------------------+------------------------------
 Reporter:  arena              |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  General            |     Version:  trunk
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by arena):

 So i upgraded to 7.2.3 and the fatal error disappeared

 '''''I know the following occurs on a plugin and is not related to WP but
 may be it can help.'''''

 But i have another error :


 [php7:error] [pid 2052:tid 976] [client 127.0.0.1:50008] PHP Fatal error:
 Uncaught Error: [] operator not supported for strings in
 (mypluginfile:line)
 Stack trace:
 # 0 \wordpress\wp-includes\class-wp-hook.php(286) :
 MP_AdminPage::print_styles('')
 # 1 \wordpress\wp-includes\class-wp-hook.php(310) :
 WP_Hook->apply_filters(NULL, Array)
 # 2 \wordpress\wp-includes\plugin.php(465) : WP_Hook->do_action(Array)
 # 3 \wordpress\wp-admin\admin-header.php(113) :
 do_action('admin_print_sty...')
 # 4 \wordpress\wp-admin\admin.php(230) :
 require_once('D:\webserver\Do...')
 # 5 {main}  thrown in (mypluginfile) on line (line), referer:
 http://127.0.0.1/wordpress/wp-admin/


 My analysis is this :

 from PHP 5 to PHP 7, PHP becomes 'stricter' on variable types. A string
 remains a string, an array remains an array ...

 The issue is that do_action() uses apply_filters(), which initialize by
 default an argument ($args) => var_dump => string(0) ""

 do_action() should not pass '''any''' argument if not required.

 In a plugin, in a parent class, i am using this line :

 {{{#!php
 add_action('admin_print_styles',         array('MP_AdminPage',
 'print_styles'));    /* xref.mailpress.org/nav.html?mp-
 includes/class/MP_adminpage_.class.php.source.html#l16 */
 }}}

 i define the print_styles() function  as

 {{{#!php
 public static function print_styles($styles = array())
 /* xref.mailpress.org/nav.html?mp-
 includes/class/MP_adminpage_.class.php.source.html#l76 */
 }}}

 and (for code consistancy) the same print_styles() function in the sub
 class as

 {{{#!php
 public static function print_styles($styles = array())  {
 /*  xref.mailpress.org/nav.html?mp-admin/mails.php.source.html#l60 */
 /* some code here */
 parent::print_styles($styles);
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/43498#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list