r81534 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81533‎ | r81534 | r81535 >
Date:20:05, 4 February 2011
Author:mah
Status:ok
Tags:
Comment:
change from double quote to single quote to avoid double-encoding by htmlspecialchars()
Modified paths:
  • /trunk/phase3/includes/installer/PostgresUpdater.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/PostgresUpdater.php
@@ -404,17 +404,17 @@
405405 protected function renameTable( $old, $new ) {
406406 if ( $this->db->tableExists( $old ) ) {
407407 $this->output( "Renaming table $old to $new\n" );
408 - $this->db->query( "ALTER TABLE \"$old\" RENAME TO $new" );
 408+ $this->db->query( "ALTER TABLE '$old' RENAME TO $new" );
409409 }
410410 }
411411
412412 protected function addPgField( $table, $field, $type ) {
413413 $fi = $this->db->fieldInfo( $table, $field );
414414 if ( !is_null( $fi ) ) {
415 - $this->output( "... column \"$table.$field\" already exists\n" );
 415+ $this->output( "... column '$table.$field' already exists\n" );
416416 return;
417417 } else {
418 - $this->output( "Adding column \"$table.$field\"\n" );
 418+ $this->output( "Adding column '$table.$field'\n" );
419419 $this->db->query( "ALTER TABLE $table ADD $field $type" );
420420 }
421421 }
@@ -427,9 +427,9 @@
428428 }
429429
430430 if ( $fi->type() === $newtype )
431 - $this->output( "... column \"$table.$field\" is already of type \"$newtype\"\n" );
 431+ $this->output( "... column '$table.$field' is already of type '$newtype'\n" );
432432 else {
433 - $this->output( "Changing column type of \"$table.$field\" from \"{$fi->type()}\" to \"$newtype\"\n" );
 433+ $this->output( "Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
434434 $sql = "ALTER TABLE $table ALTER $field TYPE $newtype";
435435 if ( strlen( $default ) ) {
436436 $res = array();
@@ -454,37 +454,37 @@
455455 if ( $fi->isNullable() ) {
456456 # # It's NULL - does it need to be NOT NULL?
457457 if ( 'NOT NULL' === $null ) {
458 - $this->output( "Changing \"$table.$field\" to not allow NULLs\n" );
 458+ $this->output( "Changing '$table.$field' to not allow NULLs\n" );
459459 $this->db->query( "ALTER TABLE $table ALTER $field SET NOT NULL" );
460460 } else {
461 - $this->output( "... column \"$table.$field\" is already set as NULL\n" );
 461+ $this->output( "... column '$table.$field' is already set as NULL\n" );
462462 }
463463 } else {
464464 # # It's NOT NULL - does it need to be NULL?
465465 if ( 'NULL' === $null ) {
466 - $this->output( "Changing \"$table.$field\" to allow NULLs\n" );
 466+ $this->output( "Changing '$table.$field' to allow NULLs\n" );
467467 $this->db->query( "ALTER TABLE $table ALTER $field DROP NOT NULL" );
468468 }
469469 else {
470 - $this->output( "... column \"$table.$field\" is already set as NOT NULL\n" );
 470+ $this->output( "... column '$table.$field' is already set as NOT NULL\n" );
471471 }
472472 }
473473 }
474474
475475 public function addPgIndex( $table, $index, $type ) {
476476 if ( $this->db->indexExists( $table, $index ) ) {
477 - $this->output( "... index \"$index\" on table \"$table\" already exists\n" );
 477+ $this->output( "... index '$index' on table '$table' already exists\n" );
478478 } else {
479 - $this->output( "Creating index \"$index\" on table \"$table\" $type\n" );
 479+ $this->output( "Creating index '$index' on table '$table' $type\n" );
480480 $this->db->query( "CREATE INDEX $index ON $table $type" );
481481 }
482482 }
483483
484484 public function addPgExtIndex( $table, $index, $type ) {
485485 if ( $this->db->indexExists( $table, $index ) ) {
486 - $this->output( "... index \"$index\" on table \"$table\" already exists\n" );
 486+ $this->output( "... index '$index' on table '$table' already exists\n" );
487487 } else {
488 - $this->output( "Creating index \"$index\" on table \"$table\"\n" );
 488+ $this->output( "Creating index '$index' on table '$table'\n" );
489489 if ( preg_match( '/^\(/', $type ) ) {
490490 $this->db->query( "CREATE INDEX $index ON $table $type" );
491491 } else {
@@ -496,13 +496,13 @@
497497 protected function changeFkeyDeferrable( $table, $field, $clause ) {
498498 $fi = $this->db->fieldInfo( $table, $field );
499499 if ( is_null( $fi ) ) {
500 - $this->output( "WARNING! Column \"$table.$field\" does not exist but it should! Please report this.\n" );
 500+ $this->output( "WARNING! Column '$table.$field' does not exist but it should! Please report this.\n" );
501501 return;
502502 }
503503 if ( $fi->is_deferred() && $fi->is_deferrable() ) {
504504 return;
505505 }
506 - $this->output( "Altering column \"$table.$field\" to be DEFERRABLE INITIALLY DEFERRED\n" );
 506+ $this->output( "Altering column '$table.$field' to be DEFERRABLE INITIALLY DEFERRED\n" );
507507 $conname = $fi->conname();
508508 $command = "ALTER TABLE $table DROP CONSTRAINT $conname";
509509 $this->db->query( $command );
@@ -516,7 +516,7 @@
517517 protected function checkPgUser() {
518518 global $wgDBmwschema, $wgDBuser;
519519
520 - $config = $this->db->selectField(
 520+ $config = $this->db->selectField(
521521 'pg_catalog.pg_user', "array_to_string(useconfig,'*')",
522522 array( 'usename' => $wgDBuser ), __METHOD__ );
523523
@@ -533,7 +533,7 @@
534534 }
535535
536536 if ( strpos( $search_path, $wgDBmwschema ) === false ) {
537 - $this->output( "Adding in schema \"$wgDBmwschema\" to search_path for user \"$wgDBuser\"\n" );
 537+ $this->output( "Adding in schema '$wgDBmwschema' to search_path for user '$wgDBuser'\n" );
538538 $search_path = "$wgDBmwschema, $search_path";
539539 }
540540 $search_path = str_replace( ', ,', ',', $search_path );
@@ -542,7 +542,7 @@
543543 $this->db->query( "SET search_path = $search_path" );
544544 } else {
545545 $path = $conf['search_path'];
546 - $this->output( "... search_path for user \"$wgDBuser\" looks correct ($path)\n" );
 546+ $this->output( "... search_path for user '$wgDBuser' looks correct ($path)\n" );
547547 }
548548
549549 $goodconf = array(
@@ -553,46 +553,46 @@
554554
555555 foreach ( $goodconf as $key => $value ) {
556556 if ( !array_key_exists( $key, $conf ) or $conf[$key] !== $value ) {
557 - $this->output( "Setting $key to '$value' for user \"$wgDBuser\"\n" );
 557+ $this->output( "Setting $key to '$value' for user '$wgDBuser'\n" );
558558 $this->db->query( "ALTER USER $wgDBuser SET $key = '$value'" );
559559 $this->db->query( "SET $key = '$value'" );
560560 } else {
561 - $this->output( "... default value of \"$key\" is correctly set to \"$value\" for user \"$wgDBuser\"\n" );
 561+ $this->output( "... default value of '$key' is correctly set to '$value' for user '$wgDBuser'\n" );
562562 }
563563 }
564564 }
565565
566566 protected function convertArchive2() {
567567 if ( $this->db->tableExists( "archive2" ) ) {
568 - $this->output( "Converting \"archive2\" back to normal archive table\n" );
 568+ $this->output( "Converting 'archive2' back to normal archive table\n" );
569569 if ( $this->db->ruleExists( 'archive', 'archive_insert' ) ) {
570 - $this->output( "Dropping rule \"archive_insert\"\n" );
 570+ $this->output( "Dropping rule 'archive_insert'\n" );
571571 $this->db->query( 'DROP RULE archive_insert ON archive' );
572572 }
573573 if ( $this->db->ruleExists( 'archive', 'archive_delete' ) ) {
574 - $this->output( "Dropping rule \"archive_delete\"\n" );
 574+ $this->output( "Dropping rule 'archive_delete'\n" );
575575 $this->db->query( 'DROP RULE archive_delete ON archive' );
576576 }
577577 $this->applyPatch( 'patch-remove-archive2.sql' );
578578 } else {
579 - $this->output( "... obsolete table \"archive2\" does not exist\n" );
 579+ $this->output( "... obsolete table 'archive2' does not exist\n" );
580580 }
581581 }
582582
583583 protected function checkOiDeleted() {
584584 if ( $this->db->fieldInfo( 'oldimage', 'oi_deleted' )->type() !== 'smallint' ) {
585 - $this->output( "Changing \"oldimage.oi_deleted\" to type \"smallint\"\n" );
 585+ $this->output( "Changing 'oldimage.oi_deleted' to type 'smallint'\n" );
586586 $this->db->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" );
587587 $this->db->query( "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" );
588588 $this->db->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" );
589589 } else {
590 - $this->output( "... column \"oldimage.oi_deleted\" is already of type \"smallint\"\n" );
 590+ $this->output( "... column 'oldimage.oi_deleted' is already of type 'smallint'\n" );
591591 }
592592 }
593593
594594 protected function checkOiNameConstraint() {
595595 if ( $this->db->hasConstraint( "oldimage_oi_name_fkey_cascaded" ) ) {
596 - $this->output( "... table \"oldimage\" has correct cascading delete/update foreign key to image\n" );
 596+ $this->output( "... table 'oldimage' has correct cascading delete/update foreign key to image\n" );
597597 } else {
598598 if ( $this->db->hasConstraint( "oldimage_oi_name_fkey" ) ) {
599599 $this->db->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
@@ -600,7 +600,7 @@
601601 if ( $this->db->hasConstraint( "oldimage_oi_name_fkey_cascade" ) ) {
602602 $this->db->query( "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey_cascade" );
603603 }
604 - $this->output( "Making foreign key on table \"oldimage\" (to image) a cascade delete/update\n" );
 604+ $this->output( "Making foreign key on table 'oldimage' (to image) a cascade delete/update\n" );
605605 $this->db->query( "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascaded " .
606606 "FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE ON UPDATE CASCADE" );
607607 }
@@ -608,46 +608,46 @@
609609
610610 protected function checkPageDeletedTrigger() {
611611 if ( !$this->db->triggerExists( 'page', 'page_deleted' ) ) {
612 - $this->output( "Adding function and trigger \"page_deleted\" to table \"page\"\n" );
 612+ $this->output( "Adding function and trigger 'page_deleted' to table 'page'\n" );
613613 $this->applyPatch( 'patch-page_deleted.sql' );
614614 } else {
615 - $this->output( "... table \"page\" has \"page_deleted\" trigger\n" );
 615+ $this->output( "... table 'page' has 'page_deleted' trigger\n" );
616616 }
617617 }
618618
619619 protected function checkRcCurIdNullable(){
620620 $fi = $this->db->fieldInfo( 'recentchanges', 'rc_cur_id' );
621621 if ( !$fi->isNullable() ) {
622 - $this->output( "Removing NOT NULL constraint from \"recentchanges.rc_cur_id\"\n" );
 622+ $this->output( "Removing NOT NULL constraint from 'recentchanges.rc_cur_id'\n" );
623623 $this->applyPatch( 'patch-rc_cur_id-not-null.sql' );
624624 } else {
625 - $this->output( "... column \"recentchanges.rc_cur_id\" has a NOT NULL constraint\n" );
 625+ $this->output( "... column 'recentchanges.rc_cur_id' has a NOT NULL constraint\n" );
626626 }
627627 }
628628
629629 protected function checkPagelinkUniqueIndex() {
630630 $pu = $this->describeIndex( 'pagelink_unique' );
631631 if ( !is_null( $pu ) && ( $pu[0] != 'pl_from' || $pu[1] != 'pl_namespace' || $pu[2] != 'pl_title' ) ) {
632 - $this->output( "Dropping obsolete version of index \"pagelink_unique index\"\n" );
 632+ $this->output( "Dropping obsolete version of index 'pagelink_unique index'\n" );
633633 $this->db->query( 'DROP INDEX pagelink_unique' );
634634 $pu = null;
635635 } else {
636 - $this->output( "... obsolete version of index \"pagelink_unique index\" does not exist\n" );
 636+ $this->output( "... obsolete version of index 'pagelink_unique index' does not exist\n" );
637637 }
638638
639639 if ( is_null( $pu ) ) {
640 - $this->output( "Creating index \"pagelink_unique index\"\n" );
 640+ $this->output( "Creating index 'pagelink_unique index'\n" );
641641 $this->db->query( 'CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)' );
642642 } else {
643 - $this->output( "... index \"pagelink_unique_index\" already exists\n" );
 643+ $this->output( "... index 'pagelink_unique_index' already exists\n" );
644644 }
645645 }
646646
647647 protected function checkRevUserFkey() {
648648 if ( $this->fkeyDeltype( 'revision_rev_user_fkey' ) == 'r' ) {
649 - $this->output( "... constraint \"revision_rev_user_fkey\" is ON DELETE RESTRICT\n" );
 649+ $this->output( "... constraint 'revision_rev_user_fkey' is ON DELETE RESTRICT\n" );
650650 } else {
651 - $this->output( "Changing constraint \"revision_rev_user_fkey\" to ON DELETE RESTRICT\n" );
 651+ $this->output( "Changing constraint 'revision_rev_user_fkey' to ON DELETE RESTRICT\n" );
652652 $this->applyPatch( 'patch-revision_rev_user_fkey.sql' );
653653 }
654654 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r82679Followup r81534, use addQuotes() insteaddemon16:42, 23 February 2011

Status & tagging log