Merge "(bug 40857) fix non-array sidebar links handling in CologneBlue"
[lhc/web/wiklou.git] / maintenance / fixExtLinksProtocolRelative.php
index e10b194..2403ec6 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
+ * @file
  * @ingroup Maintenance
  */
 
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
+require_once( __DIR__ . '/Maintenance.php' );
 
+/**
+ * Maintenance script that fixes any entriy for protocol-relative URLs
+ * in the externallinks table.
+ *
+ * @ingroup Maintenance
+ */
 class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance {
        public function __construct() {
                parent::__construct();
@@ -37,7 +44,7 @@ class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance {
        protected function updateSkippedMessage() {
                return 'protocol-relative URLs in externallinks table already fixed.';
        }
-       
+
        protected function doDBUpdates() {
                $db = wfGetDB( DB_MASTER );
                if ( !$db->tableExists( 'externallinks' ) ) {
@@ -53,7 +60,7 @@ class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance {
                foreach ( $res as $row ) {
                        $count++;
                        if ( $count % 100 == 0 ) {
-                               $this->output( $count );
+                               $this->output( $count . "\n" );
                                wfWaitForSlaves();
                        }
                        $db->insert( 'externallinks',
@@ -70,7 +77,7 @@ class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance {
                                        )
                                ), __METHOD__, array( 'IGNORE' )
                        );
-                       $db->delete( 'externallinks', array( 'el_index' => $row->el_index ), __METHOD__ );
+                       $db->delete( 'externallinks', array( 'el_index' => $row->el_index, 'el_from' => $row->el_from, 'el_to' => $row->el_to ), __METHOD__ );
                }
                $this->output( "Done, $count rows updated.\n" );
                return true;