- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1
Remove custom parser in favor of AST parser #13
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
          
     Closed
      
      
    
  
     Closed
                    Changes from 3 commits
      Commits
    
    
            Show all changes
          
          
            9 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      5227c4c
              
                Remove custom parser in favor of AST parser
              
              
                sejas 84a3a8d
              
                Add try catch instead of checking $result false value
              
              
                sejas 6fe2f55
              
                Add semi colon to comments regex
              
              
                sejas 79063a8
              
                Add support for old driver WP_SQLite_Translator
              
              
                sejas e7e8570
              
                Update comments
              
              
                sejas ca2f090
              
                Bypass SET comments instead of removing all the comments
              
              
                sejas b58afac
              
                Fix comment indentation
              
              
                sejas d897a9e
              
                Fix file encoding like: https://github.com/WordPress/sqlite-database-…
              
              
                sejas fdf1b63
              
                Echo the skipped comments instead of using a wp-cli warning to reduce…
              
              
                sejas File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
          Some comments aren't visible on the classic Files Changed page.
        
There are no files selected for viewing
  
    
      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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  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.
  
    
  
    
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 had to remove all the comments with a regex because the AST parser was identifying them as queries to execute, which caused it to fail. For example
Error: SQLite import could not execute statement: SET @saved_cs_client = @@character_set_client */;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.
@sejas Ahh, this is because the
/*!<number> ...*/comments are special MySQL comments that can execute queries conditionally based on the MySQL version. Therefore,/*!40101 SET character_set_client = @saved_cs_client */;means execute this on all versions >=4.1.1. So the part with the query being executed is correct.But somehow, the execution fails... so let's keep a quick fix. Regexes are tricky because they can match any random string in the dump, etc. What about catching the error instead, and if it starts with
SQLite import could not execute statement: SET @, then we would skip it? I would then check the root cause of the failure.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.
One thing I just noticed is that the statement doesn't include the leading
/*for some reason 🤔 Trying just$this->assertQuery( '/*!40101 SET character_set_client = @saved_cs_client */;' );— and this passes. Anyway, we can have a hotfix for now.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.
Yeah, I noticed that too. The leading
/*exists in the file, but not when using the AST parser.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 removed the regex and used a basic check: ca2f090#diff-aea1542aa0e46981e70c6bfb53a15a583242580d74dfb5df25dbfe71d098757bR159-R162
I'm checking that the query that failed starts with
SETand it contains*/.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.
Nice solution! This way it will target exactly these "wrongly parsed" comments.