Fix page load warnings and dead GoDAM enqueue - #2359
Conversation
|
Unable to PHPCS or SVG scan one or more files due to error running PHPCS/SVG scanner:
The error may be temporary. If the error persists, please contact a human (commit-ID: 14d3c90). |
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Addresses reproducible runtime warnings from the audit in #2358 by adding missing guards/initialization, removing a dead GoDAM enqueue call, and correcting misleading comments/documentation.
Changes:
- Prevent undefined array key/variable warnings by guarding option access and initializing a counter.
- Remove a
wp_enqueue_style()call for a GoDAM handle that is not registered in the referenced GoDAM version. - Update translation domain loading and correct misleading multisite-related comments.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| templates/media/godam-integration.php | Removes dead style enqueue and updates comments about per-site GoDAM settings storage. |
| app/main/RTMediaUploadTerms.php | Fixes option access warning and updates loaded textdomain to the actively used domain. |
| app/importers/RTMediaMigration.php | Initializes $count to avoid undefined-variable warning when no legacy data exists. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Part of #2358
Bucket-one fixes from the audit in #2358 — the subset that was reproduced on a running install rather than inferred from reading code. 5 lines added, 3 removed, no behaviour change beyond silencing two warnings and dropping one dead call.
What changed
app/main/RTMediaUploadTerms.php:100— guardgeneral_upload_terms_error_messagewithisset(). The key is never seeded byinit_site_options(), so it only exists after an admin saves the Upload Terms settings. Every neighbouring line in the method already guards; this one did not. Fired aPHP Warning: Undefined array keyon every front-end page load of a default install.app/importers/RTMediaMigration.php:166— initialise$count = 0before the four accumulator branches.$countwas first assigned insideif ( ! empty( $_SESSION['migration_user_album'] ) ), so on an install with no legacy bp-media data nothing assigned it andreturn $count;warned. Fired on every admin page load viaadd_migration_notice()onadmin_init. Line 171 still uses=rather than+=, so behaviour is unchanged — this only removes the undefined-variable path.templates/media/godam-integration.php:27— dropwp_enqueue_style( 'godam-player-frontend-style' ). That handle exists nowhere in GoDAM 2.1.1; the other seven handles this function enqueues are all registered ininc/classes/shortcodes/class-godam-player.php:137-190.wp_enqueue_style()on an unregistered handle is a silent no-op, which is why it never surfaced.templates/media/godam-integration.php:11,30— correct two comments claiming the skin lookup is "multisite safe (usesget_site_option)". GoDAM reads and writesrtgodam-settingswithget_option()/update_option()(inc/classes/rest-api/class-settings.php:348is the writer, all 12 read sites match). Theget_option()call is correct and unchanged — only the misleading comments are fixed, so nobody "corrects" this into a multisite regression later.app/main/RTMediaUploadTerms.php:88—load_plugin_textdomain( 'rtmedia', … )→'buddypress-media'. 1,016 strings usebuddypress-media, 5 usertmedia; the call was loading a domain nothing reads.Verification
Run against WP 7.0.3 / PHP 8.3.30 / BuddyPress 14.5.2 / MariaDB 11.8 on DDEV v1.25.2.
/,/members/,/activity/,/wp-admin/,admin.php?page=rtmedia-settings,admin.php?page=rtmedia-migration-media-size-import— previously every front-end request incremented the first countergodam-integration.phpstill reports 4 pre-existing PHPCS errors (missing@package, 2x comment end-char, missing function doc) — untouched here, tracked in Fresh-install audit (4.7.11): PHP warnings on every page load, dead migration code, and asset build gaps #2358Commands a reviewer can run:
Durable how-to-test steps live in #2358.
Out of scope
Generated CSS is deliberately not included.
grunt buildonly runssass:minify, so the expandedadmin.css/rtmedia.csshad drifted from source (finding 3), and two SCSS files are never compiled at all (finding 4). Both need a diff of compiled-vs-committed output before landing, in case those CSS files were hand-edited while uncompiled. Separate PR.