update/common/scripts/5.4/fixremovedezurlobjectlinks.php
public function processData()
    {
        while ( $this->processedCount < $this->xmlTextContentObjectAttributeCount() )
        {
            $limit = array( 'offset' => $this->offset,
                            'length' => $this->fetchLimit );

            $xmlAttributeChunk = eZContentObjectAttribute::fetchListByClassID( $this->xmlClassAttributeIds(), false, $limit, true, false );

            foreach ( $xmlAttributeChunk as $xmlAttr )
            {
                $result = true;
                // If the current entry has been logged, we don't increment the running number
                // so that the entries can be displayed together on output.
                $currentEntryLogged = false;

                $currentId = $xmlAttr->attribute( 'id' );
                $objectId = $xmlAttr->attribute( 'contentobject_id' );
                $version = $xmlAttr->attribute( 'version' );
                $languageCode = $xmlAttr->attribute( 'language_code' );

                $label = "Attribute [id:{$currentId}] - [Object-id:{$objectId}] - [Version:{$version}] - [Language:{$languageCode}]";

                $xmlText = eZXMLTextType::rawXMLText( $xmlAttr );
                if ( empty( $xmlText ) )
                {
                    if ( $this->verboseLevel > 0 )
                    {
                        $this->outputString( "Empty XML-data", $label, $currentEntryLogged );
                        $currentEntryLogged = true;
                    }
                    $result = false;
                    continue;
                }

                $dom = new DOMDocument( '1.0', 'utf-8' );
                $success = $dom->loadXML( $xmlText );
                if ( !$success )
                {
                    if ( $this->verboseLevel > 0 )
                    {
                        $this->outputString( "XML not loaded correctly for attribute", $label, $currentEntryLogged );
                        $currentEntryLogged = true;
                    }
                    $result = false;
                    continue;
                }

                $linkNodes = $dom->getElementsByTagName( 'link' );
                $urlIdArray = array();

                foreach ( $linkNodes as $link )
                {
                    // We are looking for external 'http://'-style links, not the internal
                    // object or node links.
                    if ( $link->hasAttribute( 'url_id' ) )
                    {
                        $urlIdArray[] = $link->getAttribute( 'url_id' );
                    }
                }
                $urlIdArray = array_unique( $urlIdArray );

                if ( count( $urlIdArray ) > 0 )
                {
                    if ( $this->verboseLevel > 0 )
                    {
                        $this->outputString( "Found http-link elements in xml-block", $label, $currentEntryLogged );
                        $currentEntryLogged = true;
                    }

                    if ( $this->doFix)
                    {
                        $db = eZDB::instance();
                        $db->begin();
                        eZSimplifiedXMLInput::updateUrlObjectLinks( $xmlAttr, $urlIdArray );
                        $db->commit();
                    }
                }

                $this->script->iterate( $this->cli, $result );
                $label = null;
            }

            $this->processedCount += count( $xmlAttributeChunk );
            $this->offset += $this->fetchLimit;
            unset( $xmlAttributeChunk );
        }
    }
public function processData()
    {
        while ( $this->processedCount < $this->xmlTextContentObjectAttributeCount() )
        {
            $limit = array( 'offset' => $this->offset,
                            'length' => $this->fetchLimit );

            $xmlAttributeChunk = eZContentObjectAttribute::fetchListByClassID( $this->xmlClassAttributeIds(), false, $limit, true, false );

            foreach ( $xmlAttributeChunk as $xmlAttr )
            {
                $result = true;
                // If the current entry has been logged, we don't increment the running number
                // so that the entries can be displayed together on output.
                $currentEntryLogged = false;

                $currentId = $xmlAttr->attribute( 'id' );
                $objectId = $xmlAttr->attribute( 'contentobject_id' );
                $version = $xmlAttr->attribute( 'version' );
                $languageCode = $xmlAttr->attribute( 'language_code' );

                $label = "Attribute [id:{$currentId}] - [Object-id:{$objectId}] - [Version:{$version}] - [Language:{$languageCode}]";

                $xmlText = eZXMLTextType::rawXMLText( $xmlAttr );
                if ( empty( $xmlText ) )
                {
                    if ( $this->verboseLevel > 0 )
                    {
                        $this->outputString( "Empty XML-data", $label, $currentEntryLogged );
                        $currentEntryLogged = true;
                    }
                    $result = false;
                    continue;
                }

                $dom = new DOMDocument( '1.0', 'utf-8' );
                $success = $dom->loadXML( $xmlText );
                if ( !$success )
                {
                    if ( $this->verboseLevel > 0 )
                    {
                        $this->outputString( "XML not loaded correctly for attribute", $label, $currentEntryLogged );
                        $currentEntryLogged = true;
                    }
                    $result = false;
                    continue;
                }

                $linkNodes = $dom->getElementsByTagName( 'link' );
                $urlIdArray = array();

                foreach ( $linkNodes as $link )
                {
                    // We are looking for external 'http://'-style links, not the internal
                    // object or node links.
                    if ( $link->hasAttribute( 'url_id' ) )
                    {
                        $urlIdArray[] = $link->getAttribute( 'url_id' );
                    }
                }
                $urlIdArray = array_unique( $urlIdArray );

                if ( count( $urlIdArray ) > 0 )
                {
                    if ( $this->verboseLevel > 0 )
                    {
                        $this->outputString( "Found http-link elements in xml-block", $label, $currentEntryLogged );
                        $currentEntryLogged = true;
                    }

                    if ( $this->doFix)
                    {
                        $db = eZDB::instance();
                        $db->begin();
                        eZSimplifiedXMLInput::updateUrlObjectLinks( $xmlAttr, $urlIdArray );
                        $db->commit();
                    }
                }

                $this->script->iterate( $this->cli, $result );
                $label = null;
            }

            $this->processedCount += count( $xmlAttributeChunk );
            $this->offset += $this->fetchLimit;
            unset( $xmlAttributeChunk );
        }
    }
public function processData ( ) { while ( $ this -> processedCount < $ this -> xmlTextContentObjectAttributeCount ( ) ) { $ limit = array ( 'offset' => $ this -> offset , 'length' => $ this -> fetchLimit ) ; $ xmlAttributeChunk = eZContentObjectAttribute :: fetchListByClassID ( $ this -> xmlClassAttributeIds ( ) , false , $ limit , true , false ) ; foreach ( $ xmlAttributeChunk as $ xmlAttr ) { $ result = true ; // If the current entry has been logged, we don't increment the running number // so that the entries can be displayed together on output. $ currentEntryLogged = false ; $ currentId = $ xmlAttr -> attribute ( 'id' ) ; $ objectId = $ xmlAttr -> attribute ( 'contentobject_id' ) ; $ version = $ xmlAttr -> attribute ( 'version' ) ; $ languageCode = $ xmlAttr -> attribute ( 'language_code' ) ; $ label = "Attribute [id:{$currentId}] - [Object-id:{$objectId}] - [Version:{$version}] - [Language:{$languageCode}]" ; $ xmlText = eZXMLTextType :: rawXMLText ( $ xmlAttr ) ; if ( empty ( $ xmlText ) ) { if ( $ this -> verboseLevel > 0 ) { $ this -> outputString ( "Empty XML-data" , $ label , $ currentEntryLogged ) ; $ currentEntryLogged = true ; } $ result = false ; continue ; } $ dom = new DOMDocument ( '1.0' , 'utf-8' ) ; $ success = $ dom -> loadXML ( $ xmlText ) ; if ( ! $ success ) { if ( $ this -> verboseLevel > 0 ) { $ this -> outputString ( "XML not loaded correctly for attribute" , $ label , $ currentEntryLogged ) ; $ currentEntryLogged = true ; } $ result = false ; continue ; } $ linkNodes = $ dom -> getElementsByTagName ( 'link' ) ; $ urlIdArray = array ( ) ; foreach ( $ linkNodes as $ link ) { // We are looking for external 'http://'-style links, not the internal // object or node links. if ( $ link -> hasAttribute ( 'url_id' ) ) { $ urlIdArray [ ] = $ link -> getAttribute ( 'url_id' ) ; } } $ urlIdArray = array_unique ( $ urlIdArray ) ; if ( count ( $ urlIdArray ) > 0 ) { if ( $ this -> verboseLevel > 0 ) { $ this -> outputString ( "Found http-link elements in xml-block" , $ label , $ currentEntryLogged ) ; $ currentEntryLogged = true ; } if ( $ this -> doFix ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; eZSimplifiedXMLInput :: updateUrlObjectLinks ( $ xmlAttr , $ urlIdArray ) ; $ db -> commit ( ) ; } } $ this -> script -> iterate ( $ this -> cli , $ result ) ; $ label = null ; } $ this -> processedCount += count ( $ xmlAttributeChunk ) ; $ this -> offset += $ this -> fetchLimit ; unset ( $ xmlAttributeChunk ) ; } }
Search through valid ezxmltext occurrences, and fix missing url object links if
specified.

@return void
Search through valid ezxmltext occurrences and fix missing url object links if specified .