GithubHelp home page GithubHelp logo

pantheon-systems / pantheon-mu-plugin Goto Github PK

View Code? Open in Web Editor NEW
8.0 9.0 4.0 136 KB

Pantheon's WordPress mu-plugin for all WordPress-based upstreams.

License: MIT License

CSS 1.21% JavaScript 0.14% PHP 98.65%
mu-plugin pantheon wordpress

pantheon-mu-plugin's People

Contributors

ataylorme avatar bensheldon avatar carl-alberto avatar danielbachhuber avatar gmcinnes avatar jazzsequence avatar joe-westcott avatar kporras07 avatar mboynes avatar mikevanwinkle avatar namespacebrian avatar nullvariable avatar pwtyler avatar rwagner00 avatar scottbasgaard avatar timothybjacobs avatar tripflex avatar westonruter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pantheon-mu-plugin's Issues

Return uncached taxonomy terms in Gutenberg to allow new terms to be added

Was referred to submit a potential issue from Pantheon's Slack.

Slack Notes

Issue already patched within the MU-Plugin at around https://github.com/pantheon-systems/WordPress/pull/337/files that does not appear to have been backported yet into https://github.com/pantheon-systems/pantheon-mu-plugin/blob/main/inc/pantheon-page-cache.php (at the latest/current hash) as of this note/issue?

So correct to file an issue, but in the wrong GitHub and the wrong issue! :) Need to backport the changes into the pantheon-systems/pantheon-mu-plugin/ repo. :)

Plugin Stack

  • Gutenberg Editor Enabled for Custom Post Type with Custom Taxonomy/Taxonomies
  • ACF Pro
  • Yoast SEO (and PRO, but errors for both with/without)
  • Pantheon (mu-plugin)

(I listed ACF Pro because I know it has some integrations with Yoast SEO, but the problem does not occur when ACF Pro is active. Its only with this specific combination of plugins.)

Background

We upgraded our "stack" in January with the following changes:

  1. Upgraded to WordPress 6.x, ACF Pro 6.x, and Yoast 19.1+ (moved to 20.1, but tested 19.1 and above in case it was Yoast 20.x).
  2. Upgraded from "Pantheon" 1.0.0 to the mu-plugin Composer-based version (including the recommended 'loader' file).
  • I did note a change in Aug '22 where the term caching was "deprecated" and to use the CDN. Unsure if related.

Once all updates were applied, we noticed an issue where the "Add New " button "appears" non-functional. Appears is in quotes because the terms will (randomly) save to the custom taxonomy (though not actually be seen on the page).

Note: After initial cache clear, it sometimes "works right", but then will not for other pages and/or after a refresh.

Testing

Occurs both on a "Pantheon" configured Lando environment and/or any given Pantheon environment, including LIVE.

  1. Enable listed plugins.
  2. Create the CPT and custom Taxonomy
  3. Navigate to create/edit a page in FireFox (for the tools / next-steps).
  4. Before making changes, open the inspector, navigate to the "Network" tab, and clear it.
  5. Try to add a new term.
  6. When it fails, note that api-fetch-min.js is pinged twice. Both times the "returned" content is listed as cached under the Transferred tab. (If not, give a refresh and/or edit a different page.)

"Fixing" the issue

Any of these solutions seems to "fix" the issue, though clearly none of them are valid solutions.

  1. Disable Yoast SEO.
  2. Remove the Pantheon mu-plugin and loader file(s) from the mu-plugins/ folder.
  3. Add the define('WP_CACHE', FALSE);
  4. Check the Disable Cache checkbox on the "Network" tab of FireFox tools.
  5. Using the Pantheon Adv. Page Cache plugin, set the TTL to 0.

Running wp cache flush via the CLI also sometimes fixes the issue for a single pageload.

Example (Screenshot)

I attempted to add the term "Another Test". You can see in the screenshot both that the "Transferred" items are cached and that the term "Another Test" is not present.

Please forgive creative term names. It kept working for a minute, then failing, due to code-changes. :D

image

Feel free to ping me via Pantheon Slack, if needed, to see two environments where this issue is occurring. ๐Ÿ‘

Rewrite PHPUnit tests to test with constants set/unset

This is a vanity test that doesn't actually test anything that is failing. It was added to test against #30 when the DISABLE_PANTHEON_UPDATE_NOTICES constant is set to true except that at the time the tests are run, it's set to false and the pantheon-updates.php file is loaded. Basically, all the pantheon-updates tests should be inside a separate test group that is only run when the constant is false and separated from other tests when the constant is true. There are likely other constants that perform similar functions and would require similar grouping.

[CMSP-644] add a Option field for REST API TTL

Copying over pantheon-systems/WordPress#198 to evaluate since that was initially proposed before the mu plugin was broken out from the upstream.

Fom @eabquinaโ€”

For a general use case where a customer wants to set a specific cache TTL for WP REST API endpoints, we add a specific field for the REST API TTL value

Alternatively, we can implement a custom plugin to set specific cache headers for these endpoints too, but that will be covered by another proposal or docs guide

The intention here is to avoid modifying wp-config.php to achieve this, and specifically for those who want to disable cache for

See pantheon-systems/WordPress@57ba357 for the specific diff that should be re-applied if we pursue this.

Pantheon prompts to upgrade WordPress when on beta/RC

I'm currently running WordPress 6.2-RC2 and I'm seeing the following notice in my dashboard:

image

When I click the link to go to my dashboard, there is no update available. This is, of course, because the current stable version of WordPress is 6.1.1 but I'm testing the next stable version.

It appears the logic in _pantheon_is_wordpress_core_latest() is incorrect here:

// Return true if our version is the latest
return version_compare( str_replace( '-src', '', $latest_wp_version ), str_replace( '-src', '', $wp_version ), '=' );

It should rather be something like the following:

 return version_compare( strtok( $wp_version, '-' ), strtok( $latest_wp_version, '-' ), '<=' ); 

Namely, 6.2-RC1 should be considered greater than or equal to the current stable version, 6.1.1.

[BUGS-7497] Version 1.3.0 breaks if `DISABLE_PANTHEON_UPDATE_NOTICES` is set

We have DISABLE_PANTHEON_UPDATE_NOTICES set to true on our sites so our users don't get confused. This morning all of our sites are showing the error:

[14-Feb-2024 15:03:09 UTC] PHP Fatal error: Uncaught Error: Call to undefined function _pantheon_get_current_wordpress_version() in /code/web/app/mu-plugins/pantheon-mu-plugin/pantheon.php:22

it looks like pantheon-updates.php isn't included if DISABLE_PANTHEON_UPDATE_NOTICES is set and that is where _pantheon_get_current_wordpress_version() is defined.

Simplify the wp-config

Instead of having complicated wp-config which forces a specific subdomain on non live env which complicates the initial config specially if a user will be using custom domains on other envs

if ( !empty( $_ENV['PANTHEON_ENVIRONMENT'] )) {
$site_name = $_ENV['PANTHEON_SITE_NAME'];
// Override $hostname value as needed.
switch ( $_ENV['PANTHEON_ENVIRONMENT'] ) {
case 'live':
$hostname = $_SERVER['HTTP_HOST'];
break;
case 'test':
$hostname = 'test-' . $site_name . '.pantheonsite.io';
break;
case 'dev':
$hostname = 'dev-' . $site_name . '.pantheonsite.io';
break;
case 'lando':
$hostname = $site_name . '.lndo.site';
break;
default:
$hostname = $_ENV['PANTHEON_ENVIRONMENT'] . '-' . $site_name . '.pantheonsite.io';
break;
}
} else {
// Override with a default hostname.
$hostname = '<?php echo $hostname ?>';
}
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?> );
define( 'DOMAIN_CURRENT_SITE', $hostname );
define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

if ( !empty( $_ENV['PANTHEON_ENVIRONMENT'] )) {
    $site_name = $_ENV['PANTHEON_SITE_NAME'];
    // Override $hostname value as needed.
    switch ( $_ENV['PANTHEON_ENVIRONMENT'] ) {
        case 'live':
            $hostname = $_SERVER['HTTP_HOST'];
            break;
        case 'test':
            $hostname = 'test-' . $site_name . '.pantheonsite.io';
            break;
        case 'dev':
            $hostname = 'dev-' . $site_name . '.pantheonsite.io';
            break;
        case 'lando':
            $hostname = $site_name . '.lndo.site';
            break;
        default:
            $hostname = $_ENV['PANTHEON_ENVIRONMENT'] . '-' . $site_name . '.pantheonsite.io';
            break;
    }
} else {
    // Override with a default hostname.
    $hostname = 'dev-example.pantheonsite.io';
}
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', $hostname );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Replace it with a simpler one that is proven that works on subfolder & subdomain setup that dynamically works on any subdomain

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST'] );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.