News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Clone Topic

Started by nend, November 05, 2012, 02:06:59 PM

Previous topic - Next topic

nend

After examining the data and double checking it on your site it looks to be a permission issue. When I first created the modification I didn't incorporate this.

Tell me if the latest version works for you.

0.4.3
+ Added permissions to the query.

Dream of Omnimaga

#61
Do you mean my display issues only happens for admins?


ANyway I tried your new version and for some reasons when I accessed the topic list it said I had an error in my SQL syntax or something.

QuoteYou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 't.id_topic IN (404, 249, 374, 41, 414, 338, 147, 439, 498, 434, 507, 472, 505, 4' at line 19
File: /var/www/codewalr.us/Sources/MessageIndex.php
Line: 430

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 2.0.11, while your database is at version 2.0.9. The above error might possibly go away if you execute the latest version of upgrade.php.

Keep in mind I have to manually uninstall/install your mod each time in some parts of the MessageIndex.php file because I use so many mods that it rendered the package manager half-unuseable, so perhaps this time around I mistyped something when doing the change, but I checked with https://www.diffchecker.com/ to compare and couldn't find any error.

EDIT: The offending part is this bit of code:

'.($clone_topics ? 'OR t.id_topic IN ({array_int:clone_topics})' : '' ).(!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') .'

nend

I see, there should be two queries just like that one. It looks like I introduced a bug.

Change them to this and see if that resolves it.
'.($clone_topics ? 'OR t.id_topic IN ({array_int:clone_topics})'.(!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') : '' ) .'

Dream of Omnimaga

Nope, still the same error :(

QuoteYou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 't.id_topic IN (409, 565, 470, 477, 502, 466, 436, 508, 482, 435, 787, 818, 913, ' at line 19
File: /var/www/codewalr.us/Sources/MessageIndex.php
Line: 430

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 2.0.11, while your database is at version 2.0.9. The above error might possibly go away if you execute the latest version of upgrade.php.

Dream of Omnimaga

So have you gotten any luck finding what could be the problem above and what is causing the empty topics? I hope it's not my database that is broken >.<

nend

I am on vacation, however for the time being can you post a copy of your MessageIndex.php with the edits? I'll take a look it when I get back. For now just use the version that worked last.

Sorry for the delay.

Dream of Omnimaga

Hi,

I think I found why I was getting syntax errors. For some reasons, a bit of code went missing at some point when I first manually edited the file. So 4.3 no longer errors on me, and neither does the small edit you posted above.


However, the empty topic bug is still there. I'm posting my MessageIndex.php with the above edit anyway:

nend

Did you run the database code when you upgraded the modification?

Dream of Omnimaga

How would I do that? I know it showed db.php in the package manager and that it would run it, but maybe it failed to run or something?

nend

Quote from: DJ Omnimaga on June 08, 2016, 02:58:38 AM
How would I do that? I know it showed db.php in the package manager and that it would run it, but maybe it failed to run or something?
Upload db.php to the forum root folder and open it in the browser.

Or

In phpmyadmin
DELETE c FROM {db_prefix}topic_clones AS c
LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = c.id_topic)
WHERE t.id_board = c.id_board AND t.id_topic = c.id_topic

and
DELETE c FROM {db_prefix}topic_clones AS c
LEFT JOIN {db_prefix}messages AS m ON (m.id_topic = c.id_topic)
WHERE m.id_topic IS NULL


Just replace {db_prefix} with your database prefix.

Dream of Omnimaga

SOrry for the wait. I tried running db.php and I get the following error:

QuoteNo database selected
File: /var/www/codewalr.us/db.php
Line: 43
Back

I changed {db_prefix} to my database prefix (which is smf_) and that error happened.


So I went for the phpmyadmin stuff and it ran. First said 23 rows affected and second 0, but there are still scrambled topics and empty topics in the lists (although I have the impression that there are fewer than before?)


Dream of Omnimaga

Have you gotten any luck finding a solution by the way?

nend

Quote from: DJ Omnimaga on July 29, 2016, 02:57:51 PM
Have you gotten any luck finding a solution by the way?

I use this modification on two live forums and one test forum but I haven't been able to reproduce the issue. Once I am able to figure out what is causing it I'll be able to repair it.

I have a hunch that the repair query didn't work all the way.

Try going through the clone topic table in the database and see if the topic ids lead to actual topics.

Sort the table by id_topic
Then go through each topic id once skipping duplicates with different id_board values.
So in the url put this replacing id_topic with the id.
http://www.mysite.com/?topic=id_topic
If it you get the topic doesn't exist error then delete the entry.

Dream of Omnimaga

Is there any way to go through each topic and detect if they exist in an automatic fashion? I have 239 topic clones in the clone topic table and I don't feel like checking each of them one by one manually. It will take several months with my limited free time.

nend


-Rock Lee-

Quote from: nend on September 14, 2016, 05:40:00 PM
New release 0.4.5.
0.4.5 fixes some cases where duplicate listings are shown.

Changes
https://github.com/sicommnend/SMF-Clone-Topic/commit/c62c7deae0587f7a8341ffc7bde8358dfc564092

Here I leave the Latin translation into Spanish if something is missing then I add :D

Modifications.spanish_latin-utf8.php
$txt['clone_topic'] = 'Clonar tema';
$txt['clone_to'] = 'Clonar a';
$txt['clone_remove'] = 'Retirar';
$txt['clones_topic'] = 'Clones';
$txt['clones_remove'] = 'Retirar Clones';
$txt['modlog_ac_clone'] = 'Clonado &quot;{topic}&quot;';
$txt['permissionname_clone'] = 'Tema clonado';
$txt['permissionhelp_clone'] = 'Clonar un tema de un foro a otro, los sólo usuarios pueden seleccionar los foros de destino que se les permite acceder.';
$txt['permissionname_clone_own'] = 'Tema propio';
$txt['permissionname_clone_any'] = 'Cualquier tema';
$txt['permissionname_simple_clone_own'] = 'Clonar propio tema';
$txt['permissionname_simple_clone_any'] = 'Clonar tema de nadie';


and Modifications.spanish_latin.php
$txt['clone_topic'] = 'Clonar tema';
$txt['clone_to'] = 'Clonar a';
$txt['clone_remove'] = 'Retirar';
$txt['clones_topic'] = 'Clones';
$txt['clones_remove'] = 'Retirar Clones';
$txt['modlog_ac_clone'] = 'Clonado &quot;{topic}&quot;';
$txt['permissionname_clone'] = 'Tema clonado';
$txt['permissionhelp_clone'] = 'Clonar un tema de un foro a otro, los s&oacute;lo usuarios pueden seleccionar los foros de destino que se les permite acceder.';
$txt['permissionname_clone_own'] = 'Tema propio';
$txt['permissionname_clone_any'] = 'Cualquier tema';
$txt['permissionname_simple_clone_own'] = 'Clonar propio tema';
$txt['permissionname_simple_clone_any'] = 'Clonar tema de nadie';



Great job @nend


Regards!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Dream of Omnimaga

Hi, thanks for the update nend. On a side note, I tried the following earlier:

Quote from: nend on August 01, 2016, 12:44:02 AM
Quote from: DJ Omnimaga on July 29, 2016, 02:57:51 PM
Have you gotten any luck finding a solution by the way?

I use this modification on two live forums and one test forum but I haven't been able to reproduce the issue. Once I am able to figure out what is causing it I'll be able to repair it.

I have a hunch that the repair query didn't work all the way.

Try going through the clone topic table in the database and see if the topic ids lead to actual topics.

Sort the table by id_topic
Then go through each topic id once skipping duplicates with different id_board values.
So in the url put this replacing id_topic with the id.
http://www.mysite.com/?topic=id_topic
If it you get the topic doesn't exist error then delete the entry.

And I could not find any topics there that no longer exist. Could the scrambled and empty topic glitch be caused by permission issues (eg the mod trying to list topics based on the regular member group rather than admin)? Because when I browse my forum as guest, the empty topics show "(Awaiting Approval)" as topic title instead of an empty title. I currently have no topic on my forums that are awaiting approval, though. Also, the empty topics list is shorter as guest than as staff. I don't recall cloning topics from boards invisible to guests, though.

nend

It may be the first query to get the clones as it doesn't check if the topics are approved or not. Will have to add that in for future support.

If that is the case it is loading up the topic list and counting the unapproved topics and adding them to the list. Then the pre query comes up with wrong counts so it throws the numbers off.

If this is the case try this.

Find
'.($clone_topics ? 'OR t.id_topic IN ({array_int:clone_topics})'.(!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') : '' ) .'


Replace with
'.($clone_topics ? 'OR t.id_topic IN ({array_int:clone_topics})' : '' ) .'

This tells it to ignore if the cloned topic is approved or not and just load it.

Hope this solves it so I can code the fix.

Dream of Omnimaga

Hi, I think I finally might have found the issue. It seems that one past version of clone topic might have left over some code when uninstalling at some point in the past, because after uninstalling the current version I noticed that around that something similar to the first code above remained in my file and when re-installing the mod it installed the above code above it. I'm not sure if that was the cause of the issue, but the scrambled topics and empty ones are gone for now. I'll have to investigate about approved topics, though, in case those can still cause issues. Anyway thanks for the help so far and great mod, as always :)

skb

Is there a way to only copy some posts to a new or existing topic. Not clone the entire topic.

SMF 2.1.4 / TP 2.2.2

Advertisement: