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

Replace table prefix not working for me #17656

Closed
altrasoluzione opened this issue Jul 22, 2022 · 14 comments · Fixed by #17741
Closed

Replace table prefix not working for me #17656

altrasoluzione opened this issue Jul 22, 2022 · 14 comments · Fixed by #17741
Assignees
Labels
Bug A problem or regression with an existing feature has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete
Milestone

Comments

@altrasoluzione
Copy link

Describe the bug

If I try to replace table prefix(es) nothing happens.

To Reproduce

Steps to reproduce the behavior:

  1. Select one or more tables
  2. Select 'Prefix/Replace table prefix' in 'With selected' dropbox
  3. Fill from and to fields (example: aaa_, bbb_)
  4. Press Continue

Nothing happens.

Expected behavior

All the selected tables prefixes' aaa_ shoud be replaced by bbb_

Server configuration

  • Operating system: Windows 10 (xampp) or Linux (same behavior)
  • Web server: Apache
  • Database version: 10.4.24-MariaDB or 10.3.28-MariaDB
  • PHP version: 7.4.30 or 8.1.5
  • phpMyAdmin version: 5.2.0

Client configuration

  • Browser: Any (tested on Firefox, Chrome, Opera and Edge)
  • Operating system: Windows 10

Additional context

Used to work in all previous phpMyAdmin versions I've tested.

@Jimmi08
Copy link

Jimmi08 commented Aug 4, 2022

I have the same problem.

Neither SQL command is not working but no errors are displayed.

SET @database   = "database_name";
SET @old_prefix = "old_prefix_";
SET @new_prefix = "new_prefix_";
 
SELECT
    concat(
        "RENAME TABLE ",
        TABLE_NAME,
        " TO ",
        replace(TABLE_NAME, @old_prefix, @new_prefix),
        ';'
    ) AS "SQL"
FROM information_schema.TABLES WHERE TABLE_SCHEMA = @database;

Server configuration

Operating system: Windows 11 (xampp)
Web server: Apache
Database version: 10.4.24-MariaDB
PHP version: 8.1.6
phpMyAdmin version: 5.2.0

@codegain
Copy link
Contributor

codegain commented Sep 28, 2022

Same problem as described. The browser console outputs:

Failed to parse JSON: Unexpected token '<', "<form id=""... is not valid JSON

in console.js?v=5.2.0:186 upon selecting "replace table prefix"

phpMyAdmin version: 5.2.0

@williamdes williamdes added the Bug A problem or regression with an existing feature label Sep 28, 2022
@williamdes williamdes added this to the 5.2.1 milestone Sep 28, 2022
@codegain
Copy link
Contributor

codegain commented Sep 28, 2022

After looking at this for a while:

It seems that the fetched form with the id "ajax_fom" is never actually written to the DOM. This is because the "bulkActionModal" (in check_all_tables.twig) is embedded in the form "tablesForm" in table_header.twig:74

Since you can't have a form inside of another form, the browser simply doesn't render it in the DOM.

Moving

{% if check_all_tables %}
    {% include 'database/structure/check_all_tables.twig' with check_all_tables only %}
{% endif %}

after the </form> in table_header.twig did the trick for me and it seems to be working again. I haven't checked for any sideeffects though.

EDIT: It does not make the console error go away, but at least this function is working again. Maybe this should be further investigated.

@williamdes
Copy link
Member

Thank you @codegain for the debug !
Do you want to make a branch from QA_5_2 and submit a pull-request ?

EDIT: It does not make the console error go away, but at least this function is working again. Maybe this should be further investigated.

Using the latest 5.2 version in development (phpMyAdmin 5.2+snapshot) may fix the error depending on what it was

@williamdes williamdes added has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete and removed patch labels Sep 28, 2022
@williamdes williamdes linked a pull request Sep 28, 2022 that will close this issue
6 tasks
@williamdes
Copy link
Member

Wow I just found something that blew my brain !
cc @MauricioFauth
https://stackoverflow.com/a/14381330/5155484

If you innerHTML in a form with contents having a <form> in it the browser will strip the tag but keep the contents.
That's what happens at

this.querySelector('.modal-body').innerHTML = modalBody;

@williamdes williamdes self-assigned this Oct 13, 2022
williamdes added a commit that referenced this issue Oct 13, 2022
Pull-request: #17741

Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes
Copy link
Member

This is now fixed, I advise users to test the latest 5.2 version in development (phpMyAdmin 5.2+snapshot) and let us know if there is bugs

@altrasoluzione
Copy link
Author

altrasoluzione commented Oct 13, 2022

This is now fixed, I advise users to test the latest 5.2 version in development (phpMyAdmin 5.2+snapshot) and let us know if there is bugs

Hi, I've just tested the "Replace table prefix" function and it seems to be ok but export database doesn't work anymore.

clxswalther pushed a commit to clxswalther/phpmyadmin that referenced this issue Oct 17, 2022
Pull-request: phpmyadmin#17741

Signed-off-by: William Desportes <williamdes@wdes.fr>
Signed-off-by: Sebastian Walther <swalther@complex-it.de>
@williamdes
Copy link
Member

This is now fixed, I advise users to test the latest 5.2 version in development (phpMyAdmin 5.2+snapshot) and let us know if there is bugs

Hi, I've just tested the "Replace table prefix" function and it seems to be ok but export database doesn't work anymore.

Does export still not work now?

@altrasoluzione
Copy link
Author

This is now fixed, I advise users to test the latest 5.2 version in development (phpMyAdmin 5.2+snapshot) and let us know if there is bugs

Hi, I've just tested the "Replace table prefix" function and it seems to be ok but export database doesn't work anymore.

Does export still not work now?

Hi!
As far as I can see it seems to be ok now. Thanks!

@CelesteCote
Copy link

@williamdes I see this is closed but this is what is happening to me.. I've tried adding a prefix and replacing, I've even tried running an SQL query but nothing is resulting from any of these actions despite repeated attempts, refreshes, deleting my database and starting over (of course I have backups)

@williamdes
Copy link
Member

@williamdes I see this is closed but this is what is happening to me.. I've tried adding a prefix and replacing, I've even tried running an SQL query but nothing is resulting from any of these actions despite repeated attempts, refreshes, deleting my database and starting over (of course I have backups)

It's closed but not yet released, see #17830
Please try the latest 5.2 version in development (phpMyAdmin 5.2+snapshot) also available as a non official docker image

@CelesteCote
Copy link

@williamdes How soon will this fix be released? I'm not a developer and don't see an easy way to install the snapshot.. I'm just using phpMyAdmin online via MAMP, trying to import files to a Wordpress site for a client. I just need the option in the drop down to do what it says it does :(

@arnaudgautron
Copy link

@CelesteCote Had same problem on a Joomla 4 website between local and staging installations. Here's the fix that worked on my Mac.

  • Install latest version of MAMP
  • Download phpMyAdmin 5.2+snapshot version here : https://www.phpmyadmin.net/downloads/
  • unzip the downloaded development version of phpMyAdmin
  • go to MAMP/bin folder in you Applications folder
  • rename the phpMyAdmin5 folder (example: phpMyAdmin5-old)
  • create a new phpMyAdmin5 folder
  • copy all files from the unzipped downloaded folder into the created folder
  • go to the "old" folder and copy config.inc.php file to the new folder
  • relaunch MAMP
  • test renaming prefix functionnality in phpMyAdmin
    In my local installation, the skin of the new phpMyAdmin is slightly different from the previous one. I guess there is some conf file somewhere. I haven't looked at it for now.

@robertandrews
Copy link

Here's the fix that worked on my Mac.

Thanks for the instructions. They work.
I note that simply installing the newest version of MAMP did not come with the newest version of phpMyAdmin.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants