{"id":347,"date":"2017-07-17T13:31:14","date_gmt":"2017-07-17T11:31:14","guid":{"rendered":"http:\/\/lab.fawno.com\/?p=347"},"modified":"2022-03-07T16:05:24","modified_gmt":"2022-03-07T15:05:24","slug":"","status":"publish","type":"post","link":"https:\/\/lab.fawno.com\/en\/2017\/07\/17\/wordpress-4-8-error-en-taxonomy-php\/","title":{"rendered":"","raw":""},"content":{"rendered":"","protected":false,"raw":""},"excerpt":{"rendered":"","protected":false,"raw":""},"author":1,"featured_media":1825,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_typography_data":[],"_editorskit_blocks_typography":"","_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","_es_post_content":"\n
Siguiendo la recomendaci\u00f3n universal que yo mismo extiendo, hace poco actualic\u00e9 mi WordPress...<\/p>\n\n\n\n
El caso es que hoy he descubierto que todas mis entradas comenzaban con un error de PHP:<\/p>\n\n\n\n
Warning: Illegal string offset 'filter' in wp-includes\/taxonomy.php on line 1372<\/p><\/blockquote>\n\n\n\n
Si bien es cierto que utilizo c\u00f3digo propio el caso concreto apunta a un fichero original de la instalaci\u00f3n, en concreto el error corresponde a la funci\u00f3n sanitize_term<\/a> cuyo c\u00f3digo se puede comprobar en la referencia para desarrolladores<\/a>.<\/p>\n\n\n\n
En concreto el error est\u00e1 en la sentencia del else<\/em>:<\/p>\n\n\n\n
if ( $do_object )\n $term->filter = $context;\nelse\n $term['filter'] = $context;<\/pre>\n\n\n\nEn alg\u00fan caso se llama a la funci\u00f3n
sanitize_term($term)<\/code> asignando a
$term<\/code> un contenido que no es ni un objeto ni un array. Como quiera que lo \u00fanico que se comprueba es si
$term<\/code> es un objeto, la asignaci\u00f3n como array sobre una variable que no es un array da error.<\/p>\n\n\n\n
Por lo que la soluci\u00f3n l\u00f3gica es comprobar si es un array antes de tratar a $term como un array:<\/p>\n\n\n\n
if ( $do_object )\n $term->filter = $context;\nelseif ( is_array( $term ) )\n $term['filter'] = $context;<\/pre>\n","_es_post_name":"wordpress-4-8-error-en-taxonomy-php","_es_post_excerpt":"","_es_post_title":"WordPress 4.8: error en taxonomy.php","_en_post_content":"","_en_post_name":"","_en_post_excerpt":"","_en_post_title":"","edit_language":"en","footnotes":""},"categories":[5,49],"tags":[6,48],"class_list":["post-347","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-wordpress","tag-php","tag-wordpress"],"ninja_gutenberg_blocks_featured_media_urls":{"thumbnail":["https:\/\/lab.fawno.com\/wp-content\/uploads\/2022\/01\/20220125_212251-150x150.jpg",150,150,true],"ninja_gutenberg_blocks_landscape_large":["https:\/\/lab.fawno.com\/wp-content\/uploads\/2022\/01\/20220125_212251-1200x800.jpg",1200,800,true],"ninja_gutenberg_blocks_portrait_large":["https:\/\/lab.fawno.com\/wp-content\/uploads\/2022\/01\/20220125_212251-1200x1800.jpg",1200,1800,true],"ninja_gutenberg_blocks_square_large":["https:\/\/lab.fawno.com\/wp-content\/uploads\/2022\/01\/20220125_212251-scaled.jpg",900,1200,false],"ninja_gutenberg_blocks_landscape":["https:\/\/lab.fawno.com\/wp-content\/uploads\/2022\/01\/20220125_212251-scaled.jpg",300,400,false],"ninja_gutenberg_blocks_portrait":["https:\/\/lab.fawno.com\/wp-content\/uploads\/2022\/01\/20220125_212251-scaled.jpg",600,800,false],"ninja_gutenberg_blocks_square":["https:\/\/lab.fawno.com\/wp-content\/uploads\/2022\/01\/20220125_212251-scaled.jpg",450,600,false],"full":["https:\/\/lab.fawno.com\/wp-content\/uploads\/2022\/01\/20220125_212251-scaled.jpg",1920,2560,false]},"_links":{"self":[{"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/posts\/347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/comments?post=347"}],"version-history":[{"count":16,"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/posts\/347\/revisions"}],"predecessor-version":[{"id":1875,"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/posts\/347\/revisions\/1875"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/media\/1825"}],"wp:attachment":[{"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/media?parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/categories?post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab.fawno.com\/en\/wp-json\/wp\/v2\/tags?post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}