-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search feature #1
Conversation
5fb3bd7
to
be98c28
Compare
README.md
Outdated
- Find all occurrences of "http://example.com/" followed by any number of digits on tables: | ||
|
||
`php admin/tool/advancedreplace/cli/find.php --regex-match=http://example.com/\\d+` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you "" bash quote the params would this make the \\ just \ and read easier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix this
cli/find.php
Outdated
if (!empty($matches[0])) { | ||
// Show the result foreach match. | ||
foreach ($matches[0] as $match) { | ||
echo "$table, $column, $id, \"$match\"\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please use either the php or the moodle apis for writing csv so this is escaped properly for content when it contains commas and quotes
* @param int $limit The maximum number of results to return. | ||
* @return array | ||
*/ | ||
public static function search(string $search, bool $regex = false, string $tables = '', int $limit = 0): array { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when we scale up I'm pretty sure this will start breaking as everything is in memory
So probably fine to merge right now, but we'll need to refactor this later. We will probably want to do things in two phases, the first phase returns a list of tables we will search, and then we'll want to do a search table by tables and that second layer will return a record set we can stream through
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also thinking ahead, we talked about this script just outputting to stdout, but it might be better if it outputs to a file and then we can output a set of progress bars to stdout. Knowing how long things will take and where we are up to with ETA's is going to be fairly important. Again not critical now but I'll make issues for this
80e605d
to
2b2ef2d
Compare
2b2ef2d
to
a98f8bd
Compare
CLI script
WIP: Still working on regex-match