Opened 18 years ago
Closed 16 years ago
#1296 closed Bug (worksforme)
MediaWiki+FCKeditor : shared images not working
Reported by: | cvh | Owned by: | |
---|---|---|---|
Priority: | Must have (possibly next milestone) | Milestone: | |
Component: | Project : MediaWiki+FCKeditor | Version: | FCKeditor 2.5.1 |
Keywords: | shared tables interwiki | Cc: | admin@… |
Description ¶
I use 3 wiki for multilingual purposes: 1 french, 1 dutch and 1 global that is configured shared upload of images
The code for the images of the existing images is transformed when i preview or clik on the wikitext button
Steps to reproduce: open a page in the wiki: the image are correctly shown click on edit: i still see the images click on the wikitext button to see the "source" code:
the link for the first image was :
[[Image:|Image:But_harm_afwezig.png]]
and it becomes: [[Image:|Image:But_harm_afwezig.png]]
Moreover when i try to place a new image, the dialog box does'nt let me access tio the shared folder of images but still in the local images
parameters in LocalSettings.php: $wgUploadNavigationUrl="http://localhost/mediawiki/index.php/Special:Upload"; ##to use pool's wiki file in language wiki
$wgUseSharedUploads = true; $wgSharedUploadPath = 'http://localhost/mediawiki/images'; $wgSharedUploadDirectory= 'C:
WWWroot\mediawiki
images
'; $wgHashedSharedUploadDirectory = true;

Change History (6)
comment:1 Changed 18 years ago by
comment:2 Changed 18 years ago by
On MW website, it contradicts your setting:
$wgHashedSharedUploadDirectory:
Set this setting to false especially if you have a set of files that need to be accessible by all wikis, and you do not want to use the hash (path/a/aa/) directory layout.
It's true though that the Ajax call in FCK is only looking at the DB for the file, not the shared directory.
comment:3 Changed 17 years ago by
To avoid the problem described,I tried to stop sharing the images and to create 2 totally independant wiki's. I made 2 folders: wikif & wikin, 2 databases: wikif & wikin. in the folders images of /wikin and /wikif I made a copy of the shared folder images (every images copied twice). Then I executed the script to create the image pages updating the tables page, revision and text. I managed to do it but I still had a problem: wiki could not find the text of the image pages. May be an error in my script or may be I forgot to take in account another table I place the script in attachment for your curiosity, any feedback is welcome.
to understand this script: the database has been copied in db wikif and contains
- without prefixe: the pool tables (containing image pages)
- with prefixe fr_ the tables of the french wiki
/* insert image pages from the pool to the fr_ table */ insert into wikif.fr_page ( `page_namespace`, `page_title`, `page_restrictions`, `page_counter`, `page_is_redirect`, `page_is_new`, `page_random`, `page_touched`, `page_latest`, `page_len` ) select `page_namespace`, `page_title`, `page_restrictions`, `page_counter`, `page_is_redirect`, `page_is_new`, `page_random`, `page_touched`, `page_latest`, `page_len` from wikif.page where page_namespace=6; select * from wikif.revision where rev_page in (select page_id from wikif.page where page_namespace=6); /** creation of the table to keep link between pool's page_id's and the pages i,serted in fr_page **/ create temporary table wikif.tempage (page_id int, text_id int, new_page_id int); insert into wikif.tempage (page_id, text_id , new_page_id ) select rev_page, rev_text_id ,0 from wikif.revision where rev_page in (select page_id from wikif.page where page_namespace=6); update wikif.tempage as t, fr_page as fp, page as ep set t.new_page_id= fp.page_id where fp.page_title=ep.page_title and t.page_id=ep.page_id; select * from wikif.tempage; CREATE TEMPORARY TABLE wikif.temp_revision_table LIKE wikif.revision; insert into wikif.temp_revision_table select revision.* from wikif.revision join wikif.page on revision.rev_page=page.page_id where page_namespace=6; update wikif.temp_revision_table , wikif.tempage set rev_page= new_page_id where temp_revision_table.rev_page=tempage.page_id; select * from wikif.temp_revision_table; /********creation of new id's for fr_text******************/ create temporary table wikif.temp_text (compteur int AUTO_INCREMENT PRIMARY KEY, old_id int , new_old_id int); insert into wikif.temp_text (old_id, new_old_id) SELECT text.old_id,0 FROM wikif.text JOIN wikif.revision AS r ON text.old_id = r.rev_text_id JOIN wikif.page ON r.rev_page = page.page_id WHERE page_namespace =6 order by old_id asc; create temporary table wikif.tempmax (maxi int); insert into wikif.tempmax (maxi) select max(old_id) from fr_text; select * from wikif.tempmax ; /** on va creer les nouveaux id de text **/ update wikif.temp_text, wikif.tempmax set new_old_id = maxi +compteur; select * from wikif.temp_text; /** we adapt the id from table text into temporary REVISION temp_revision_table **/ update wikif.temp_revision_table , wikif.temp_text set rev_text_id= new_old_id where rev_text_id= old_id; select * from wikif.temp_revision_table; /** we add the texts with the new Id's and put it in a temporary table tempo; **/ CREATE temporary TABLE wikif.tempo_text ( `old_id` int(8) unsigned NOT NULL , `old_text` mediumblob NOT NULL, `old_flags` tinyblob NOT NULL, PRIMARY KEY (`old_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci ; insert into wikif.tempo_text select tt.new_old_id, t.old_text, t.old_flags from wikif.text as t join temp_text as tt on tt.old_id=t.old_id; select * from wikif.tempo_text; /** le stade final on va effectivement remplir la tables fr_text ******/ insert into wikif.fr_text (old_id, old_text, old_flags) select old_id, old_text, old_flags from wikif.tempo_text; /** final stage we add the revisions fr_revision without the id ******/ insert into wikif.fr_revision (rev_page, rev_text_id, rev_comment, rev_user, rev_user_text, rev_timestamp, rev_minor_edit,rev_deleted) select rev_page, rev_text_id,rev_comment, rev_user, rev_user_text, rev_timestamp, rev_minor_edit,rev_deleted from wikif.temp_revision_table; /* copy images in table fr_image **/ delete from fr_image where img_name in (select distinct img_name from image); insert into fr_image select * from image; select * from fr_image; /************************************************* delete tables without prefixe (pool's table) ******************************************************/ drop table archive ; drop table categorylinks; drop table externallinks ; drop table filearchive; drop table hitcounter; drop table image; drop table imagelinks; drop table interwiki; drop table ipblocks; drop table job; drop table langlinks; drop table logging; drop table math; drop table objectcache; drop table oldimage; drop table page; drop table pagelinks; drop table page_restrictions; drop table querycache; drop table querycachetwo; drop table querycache_info; drop table recentchanges; drop table redirect; drop table revision; drop table searchindex; drop table site_stats; drop table templatelinks; drop table text; drop table trackbacks; drop table transcache; drop table user; drop table user_groups; drop table user_newtalk; drop table watchlist
comment:4 Changed 16 years ago by
Cc: | admin@… added |
---|---|
Priority: | Normal → High |
Resolution: | → worksforme |
Status: | new → closed |
Version: | → FCKeditor 2.5.1 |
Found the solution:
Assume, you only want to search your pool wiki for images, you have to set the praefix for the right table. Look for
"$res = $db->select( 'page', 'page_title',"
in FCKeditoSajax.body.php (line 74) and rename it to:
"$res = $db->select( 'YOUR_POOL_PRAEFIX_page', 'page_title',"
So it is done, FCKeditor find the right images. It is only a little bit hardcoded by me :-)
regards RaceRay
comment:5 Changed 16 years ago by
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
comment:6 Changed 16 years ago by
Keywords: | shared tables interwiki added |
---|---|
Resolution: | → worksforme |
Status: | reopened → closed |
I found a way to let the FCK editor files untouched:
When you use shared wikis, you have to replace some code in the database.php and modify the function tableName() in localSettings.php:
function tableName( $name ) {
global $wgSharedDB; global $wgSharedTables; global $wgSharedPrefix; # Skip quoted literals] if ( $name{0} != '`' ) {
$found = 0; if ( $this->mTablePrefix !== && strpos( '.', $name ) === false ) {
$name = "{$this->mTablePrefix}$name";
}
if ( isset( $wgSharedDB ) ) {
foreach ($wgSharedTables as $fromshared) {
if ($name == $fromshared) {
$name = "
$wgSharedDB
.$name
"; #you may add $wgSharedPrefix here $found = 1;}
}
}
if ($found == 0) {
# Standard quoting $name = "
$name
";}
} return $name;
}
In LocalSettings.php:
$wgSharedDB = 'wiki'; set to your shared db name $wgSharedTables = array( 'user', 'user_groups', 'interwiki', 'ipblocks'); some examples of useful shared tables
$wgSharedPrefix = ; change it to the correct prefix. In my case it would be "pool_"

Please check ticket 1293 for first issue.