vinkla / wordplate

A boilerplate for WordPress, built with Composer and designed with sensible defaults.
2.11k stars 155 forks source link

404 page errors wordplate theme #176

Closed sandrodz closed 7 years ago

sandrodz commented 7 years ago

Notice: Trying to get property of non-object in /www/lithuanianbakery.dev/public/themes/wordplate/functions.php on line 68

Fatal error: Uncaught TypeError: trim() expects parameter 1 to be string, null given in /www/lithuanianbakery.dev/public/themes/wordplate/functions.php:68 Stack trace: #0 /www/lithuanianbakery.dev/public/themes/wordplate/functions.php(68): trim(NULL) #1 /www/lithuanianbakery.dev/public/wordpress/wp-includes/class-wp-hook.php(300): WordPlate\Application->{closure}(' Page not foun...') #2 /www/lithuanianbakery.dev/public/wordpress/wp-includes/plugin.php(203): WP_Hook->apply_filters(' Page not foun...', Array) #3 /www/lithuanianbakery.dev/public/wordpress/wp-includes/general-template.php(1218): apply_filters('wp_title', ' Page not foun...', '', '') #4 /www/lithuanianbakery.dev/public/themes/wordplate/library/pug-data.php(4): wp_title('', false) #5 /www/lithuanianbakery.dev/public/themes/wordplate/index.php(4): include('/www/lithuanian...') #6 /www/lithuanianbakery.dev/public/wordpress/wp-includes/template-loader.php(74): include('/www/lithuanian...') #7 /www/lithuanianbakery.dev/public/wordpress/wp-blog-header.php(19): re in /www/lithuanianbakery.dev/public/themes/wordplate/functions.php on line 68```
vinkla commented 7 years ago

Please add a better description to your issue with the code which fails (functions.php:68). Just pasting error messages on GitHub issues will make it hard for maintainers to help you.

sandrodz commented 7 years ago

oops. sorry.

screen shot 2017-05-05 at 11 10 06 am
vinkla commented 7 years ago

Its seem the $post object doesn't exist in the 404 page. Could you try to dd() the $post object in the 404.php file in your theme?

sandrodz commented 7 years ago

I cannot dd inside 404.php as fatal error happens in functions.php file before theme file gets executed.

but yes $post is null

screen shot 2017-05-05 at 12 42 16 pm
vinkla commented 7 years ago

Okay, we'll have to do some debugging on this. If you find a solution, please let us know!

puredazzle commented 7 years ago

@sandrodz are you using any more plugins or something that interfere with the wp_title? I am using the latest version of WordPlate and I don't get this error.

sandrodz commented 7 years ago

@puredazzle this is my composer.json I use cmb2 and polylang, later one does some magic to wp_title, but why does this happen only on 404?

{
    "name": "wordplate/wordplate",
    "description": "A modern WordPress stack. Don't repeat yourself.",
    "keywords": ["wordplate", "wordpress", "boilerplate", "plate"],
    "license": "MIT",
    "require": {
        "php": "^7.0",
        "wordplate/framework": "^5.1",
        "wordplate/plate": "^2.3",
        "johnpbloch/wordpress": "4.7.4",
        "wordplate/autoloader": "^0.1.2",
        "pug-php/pug": "^2.5",
        "wpackagist-plugin/cmb2": "^2.2",
        "wpackagist-plugin/polylang": "^2.1"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://wpackagist.org"
        }
    ],
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "extra": {
        "installer-paths": {
            "public/mu-plugins/{$name}": [
                "type:wordpress-muplugin",
                "wordplate/plate",
                "wpackagist-plugin/cmb2",
                "wpackagist-plugin/polylang"
            ],
            "public/plugins/{$name}": ["type:wordpress-plugin"],
            "public/themes/{$name}": ["type:wordpress-theme"]
        },
        "wordpress-install-dir": "public/wordpress"
    }
}
puredazzle commented 7 years ago

@sandrodz it seems that this is not being used any more by WordPress so we will remove the function all together, please see https://github.com/wordplate/wordplate/pull/177

vinkla commented 7 years ago

The wp_title is deprecated and we've removed it from WordPlate, please see #177.

sandrodz commented 7 years ago

Thank you, works great.