Conversation
Attempt to update for multiple tables
Make search work with multiple tables on the same page
Processor: add some more input checking - table_search js: fix node dropdown
Closed
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies “Shentity” related tweaks to the module’s Google Sheets integration and the table search behavior, including additional input handling and a cleanup/removal of an unused plugin.
Changes:
- Add input validation/sanitization to Google Sheets processing, including safer handling of unexpected data.
- Extend Google Sheets fetching/API to optionally accept a full Google Docs URL for Shentity use cases.
- Update table search JS to support multiple
.table-searchinstances with unique search inputs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Plugin/GoogleSheetsTopLinks.php | Removes the GoogleSheetsTopLinks plugin implementation. |
| src/Plugin/GoogleSheetsProcess.php | Adds validation and sanitization when processing fetched sheet data. |
| src/Plugin/GoogleSheetsFetch.php | Adds optional $shentity mode and sanitization for feed construction. |
| src/Plugin/GoogleSheetsApi.php | Passes through new $shentity parameter to the fetcher. |
| js/table_search.js | Refactors to handle multiple searchable tables with unique input IDs. |
Comments suppressed due to low confidence (1)
src/Plugin/GoogleSheetsFetch.php:56
- When
$shentityis TRUE and$keyfails the prefix check,$feedbecomes NULL but is still passed tonew CvsToArray($feed, ','). This will triggerfopen(NULL, 'r')warnings and can lead to downstream warnings when processing$data. Add an early return / fallback ($this->fetchData = []) when$feedis empty or invalid.
public function __construct($key, $gid, $shift = 0, $shentity = FALSE) {
if ($shentity) {
// Check the url starts with 'https://docs.google.com'.
$feed = !empty($key) && strpos($key, 'https://docs.google.com') === 0 ? $key : NULL;
}
else {
$key = !empty($key) ? Xss::filter($key) : NULL;
$gid = $gid >= 0 ? $gid : NULL;
// See https://gist.github.com/pamelafox/770584
$feed = "https://docs.google.com/spreadsheets/d/$key/pub?gid=$gid&single=true&output=csv";
}
// Arrays we'll use later.
$newArray = [];
// Do it.
$this->cvsSheet = new CvsToArray($feed, ',');
$data = $this->cvsSheet->getBuiltArray();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
@protitude I've opened a new pull request, #15, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: protitude <695625+protitude@users.noreply.github.com>
Co-authored-by: protitude <695625+protitude@users.noreply.github.com>
Add type validation for $sheet_letters to prevent TypeError in PHP 8+
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe context / purpose for this PR
Shentity Tweaks
Issue link
#1172
Any other related PRs?
Link to MultiDev instance
http://md-1172-ucbsub-oit.pantheonsite.io