Skip to content
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

Switch to mysqli #55

Merged
merged 13 commits into from
Nov 10, 2023
Merged

Switch to mysqli #55

merged 13 commits into from
Nov 10, 2023

Conversation

mattbucci
Copy link
Collaborator

For compatibility with WP 6.4 we must implement mysqli functions instead of mysql functions in our driver class

See:
#54

@mattbucci
Copy link
Collaborator Author

mattbucci commented Nov 10, 2023

Mysqli driver is now mostly working. I'm able to load the site, browse it and more. But I can't yet make changes to posts or create new posts. Editing via appearance also fails.

The error log contains this.

UPDATE `wp_posts` SET `guid` = '' WHERE `ID` IS NULL
---- converted to ----
UPDATE wp_posts SET guid = '' WHERE `ID` IS NULL
----> ERROR:  syntax error at or near "NULL"

Additionally i'm getting errors about sequences

@mattbucci
Copy link
Collaborator Author

I was able to switch themes fine, but it gave errors


Warning: pg_query(): Query failed: ERROR: currval of sequence "wp_options_seq" is not yet defined in this session in /mnt/shared/sites/monad/wp-content/plugins/pg4wp/driver_pgsql.php on line 1126

Warning: pg_query(): Query failed: ERROR: currval of sequence "wp_options_seq" is not yet defined in this session in /mnt/shared/sites/monad/wp-content/plugins/pg4wp/driver_pgsql.php on line 1126

Warning: pg_query(): Query failed: ERROR: currval of sequence "wp_options_seq" is not yet defined in this session in /mnt/shared/sites/monad/wp-content/plugins/pg4wp/driver_pgsql.php on line 1126

@mattbucci
Copy link
Collaborator Author

Here's another hint:

SELECT CURRVAL('wp_blogmeta_seq')
The latest INSERT query was :
'INSERT INTO wp_blogmeta (blog_id, meta_key, meta_value) VALUES ('1', 'db_version', '56657')'
[1699599422.2772] wpsqli_insert_id() was called with 'wp_blogmeta' and 'blog_id' and returned the error:

it looks like something is wrong with wpsqli_insert_id

@mattbucci
Copy link
Collaborator Author

I think inserts aren't working properly which is what is causing the majority of these issues

@mattbucci
Copy link
Collaborator Author

The issue was the connection was not shared between the insert and the sequence value call.

Changing all functions to pass by reference, updating the global connection more frequently and changing all functions to prefer passed $connection over global fixed the issue.

From what I can see everything is now working correctly but many parts of the driver such as prepared statements aren't implemented. I'm going to merge this, tag a new release and open issues for each function not implemented in the driver.

image

@mattbucci mattbucci merged commit bf2ef7f into v3 Nov 10, 2023
1 check passed
@mattbucci mattbucci changed the title WIP: Switch to mysqli Switch to mysqli Nov 10, 2023
@mattbucci mattbucci deleted the switch-to-mysqli branch November 11, 2023 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant