{"id":103782,"date":"2019-05-10T09:25:11","date_gmt":"2019-05-10T09:25:11","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/hagakure-yet-another-error-reporter\/"},"modified":"2025-03-28T12:53:14","modified_gmt":"2025-03-28T12:53:14","slug":"hagakure","status":"publish","type":"plugin","link":"https:\/\/pcd.wordpress.org\/plugins\/hagakure\/","author":13589055,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.3.2","stable_tag":"1.3.2","tested":"6.6.5","requires":"5.9","requires_php":"7.4","requires_plugins":null,"header_name":"Hagakure - Yet Another Error Reporter","header_author":"Tarosky","header_description":"A WordPress plugin to clarify meaningless errors like \"Allowed memory size of xxxxxxxx bytes exhausted\".","assets_banners_color":"6d6a67","last_updated":"2025-03-28 12:53:14","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"https:\/\/tarosky.co.jp","rating":5,"author_block_rating":0,"active_installs":30,"downloads":1983,"num_ratings":2,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"0.8.0":{"tag":"0.8.0","author":"Takahashi_Fumiki","date":"2019-05-10 09:25:02"},"1.0.3":{"tag":"1.0.3","author":"Takahashi_Fumiki","date":"2022-10-18 08:02:56"},"1.0.4":{"tag":"1.0.4","author":"Takahashi_Fumiki","date":"2022-10-18 08:10:32"},"1.1.0":{"tag":"1.1.0","author":"Takahashi_Fumiki","date":"2022-10-19 04:57:59"},"1.2.0":{"tag":"1.2.0","author":"Takahashi_Fumiki","date":"2022-11-29 11:17:01"},"1.3.0":{"tag":"1.3.0","author":"Tarosky","date":"2024-09-27 12:21:17"},"1.3.1":{"tag":"1.3.1","author":"Tarosky","date":"2024-09-27 12:32:19"},"1.3.2":{"tag":"1.3.2","author":"Tarosky","date":"2025-03-28 12:53:14"}},"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"2"},"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":2085221,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":2085221,"resolution":"256x256","location":"assets","locale":""}},"assets_banners":{"banner-1544x500.jpg":{"filename":"banner-1544x500.jpg","revision":2085221,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":2085221,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.8.0","1.0.3","1.0.4","1.1.0","1.2.0","1.3.0","1.3.1","1.3.2"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[906,662,13383],"plugin_category":[],"plugin_contributors":[171267,83237,142014],"plugin_business_model":[],"class_list":["post-103782","plugin","type-plugin","status-publish","hentry","plugin_tags-error","plugin_tags-php","plugin_tags-recovery","plugin_contributors-kuno1","plugin_contributors-takahashi_fumiki","plugin_contributors-tarosky","plugin_committers-takahashi_fumiki","plugin_committers-tarosky"],"banners":{"banner":"https:\/\/ps.w.org\/hagakure\/assets\/banner-772x250.jpg?rev=2085221","banner_2x":"https:\/\/ps.w.org\/hagakure\/assets\/banner-1544x500.jpg?rev=2085221","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/hagakure\/assets\/icon-128x128.png?rev=2085221","icon_2x":"https:\/\/ps.w.org\/hagakure\/assets\/icon-256x256.png?rev=2085221","generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Have you ever seen an error log like the one below?<\/p>\n\n<blockquote>\n  <p>PHP Fatal error: Allowed memory size of xxxxxx bytes exhausted (tried to allocate xxx bytes) in \/var\/www\/wordpress\/wp-includes\/wp-db.php on line 2007<\/p>\n<\/blockquote>\n\n<p>This means that <a href=\"https:\/\/www.php.net\/manual\/en\/ini.core.php#ini.memory-limit\">PHP memory limit<\/a> is exhausted while retrieving data from a database. In any case, this happens when your site has big data and makes insane loops inside.<\/p>\n\n<p>But we want to know that <strong>which plugin tried to retrieve data?<\/strong><\/p>\n\n<p>Hagakure adds extra information to error.log file when <code>wp-db.php<\/code> causes memory limit error:<\/p>\n\n<pre>[08-May-2019 10:28:37 UTC] wpdb Error Backtrace:\n#1      Kunoichi\\Hagakure\\DbLogger-&gt;filter_query()      \/app\/public\/wp-includes\/class-wp-hook.php       Line 286\n#2      WP_Hook-&gt;apply_filters()        \/app\/public\/wp-includes\/plugin.php      Line 208\n#3      apply_filters   \/app\/public\/wp-includes\/wp-db.php       Line 1871\n#4      wpdb-&gt;query()   \/app\/public\/wp-includes\/wp-db.php       Line 2579\n#5      wpdb-&gt;get_results()     \/app\/public\/wp-includes\/class-wp-query.php      Line 2979\n#6      WP_Query-&gt;get_posts()   \/app\/public\/wp-includes\/class-wp-query.php      Line 3387\n#7      WP_Query-&gt;query()       \/app\/public\/wp-includes\/post.php        Line 1961\n#8      get_posts       \/app\/public\/wp-content\/plugins\/hagakure\/hagakure.php    Line 34\n#9      {closure}       \/app\/public\/wp-includes\/class-wp-hook.php       Line 286\n#10     WP_Hook-&gt;apply_filters()        \/app\/public\/wp-includes\/class-wp-hook.php       Line 310\n#11     WP_Hook-&gt;do_action()    \/app\/public\/wp-includes\/plugin.php      Line 465\n#12     do_action       \/app\/public\/wp-includes\/template-loader.php     Line 13\n#13     require_once    \/app\/public\/wp-blog-header.php  Line 19\n#14     require \/app\/public\/index.php   Line 17\n#15     URI: \/?p=1<\/pre>\n\n<p>This log will always follow the memory limit Fatal Error by <code>wp-db.php<\/code>. Now you can find <code>#8<\/code> calls <code>get_posts<\/code> repeatedly.<\/p>\n\n<p>We recommend watching logs with notification services like <a href=\"https:\/\/docs.aws.amazon.com\/AmazonCloudWatch\/latest\/logs\/WhatIsCloudWatchLogs.html\">CloudWatch Logs<\/a>.\nThis error occurs in the productional environment, and you may not have a chance to see it occurs.\nWe use Hagakure with our <a href=\"https:\/\/hosting.kunoichiwp.com\/\">hosting service<\/a>, please look forward to seeing <a href=\"https:\/\/kunoichiwp.com\/blog\">our blog published<\/a> and describing the integration!<\/p>\n\n<p>This plugin also adds debug backtrace to error logs. To modify the error level to a detailed backtrace, define the constant in <code>wp-config.php<\/code> or somewhere else:<\/p>\n\n<pre>define( 'HAGAKURE_ERROR_LEVEL', E_NOTICE | E_USER_WARNING | E_WARNING | E_USER_ERROR );<\/pre>\n\n<p>Besides that, if <code>SAVEQUERIES<\/code> is set <code>true<\/code>, the slow query log will be logged with PHP debug backtrace. This helps you to debug.<\/p>\n\n<h3>Acknowledgements<\/h3>\n\n<p>The base text for dummy content is \"Three Ghost Story\" by Charles Dickens. The text file is modified the one of <a href=\"https:\/\/www.gutenberg.org\/ebooks\/1289\">Project Gutenberg<\/a>.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload <code>hagakure<\/code> folder to the <code>\/wp-content\/plugins<\/code> directory.<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress.<\/li>\n<li>That's it. This plugin will work as background.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id='how%20can%20i%20contribute%3F'><h3>How can I contribute?<\/h3><\/dt>\n<dd><p>We host this plugin on GitHub <a href=\"https:\/\/github.com\/tarosky\/hagakure\">tarosky\/hagakure<\/a>. Please feel free to send <a href=\"https:\/\/github.com\/tarosky\/hagakure\/pulls\">PRs<\/a> or to make <a href=\"https:\/\/github.com\/tarosky\/hagakure\/issues\">issues<\/a>.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.3.1<\/h4>\n\n<ul>\n<li>Bump required PHP and WP version.<\/li>\n<li>Fix memory limit error log logic.<\/li>\n<li>Move the ownership to TAROSKY Inc from Kunoichi Inc. Tarosky is a parent company of Kunoichi Inc.  Developers are the same \u263a\ufe0f<\/li>\n<\/ul>\n\n<h4>1.2.0<\/h4>\n\n<ul>\n<li>Slow query can be logged with the backtraces.<\/li>\n<\/ul>\n\n<h4>1.1.0<\/h4>\n\n<ul>\n<li>Add Request URI to backtrace.<\/li>\n<\/ul>\n\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Add warning and notice detail handler.<\/li>\n<\/ul>\n\n<h4>0.8.0<\/h4>\n\n<ul>\n<li>First Release.<\/li>\n<\/ul>","raw_excerpt":"A WordPress plugin to clarify meaningless errors like &quot;Allowed memory size of xxxxxxxx bytes exhausted&quot;.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/103782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=103782"}],"author":[{"embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/tarosky"}],"wp:attachment":[{"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=103782"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=103782"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=103782"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=103782"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=103782"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/pcd.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=103782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}