if ( !function_exists( 'xml_parser_create_ns' ) ) {
// this should already be checked by this point
- throw new MWException( 'XMP support requires XML Parser' );
+ throw new RuntimeException( 'XMP support requires XML Parser' );
}
$this->items = XMPInfo::getItems();
* @param string $content XMP data
* @param bool $allOfIt If this is all the data (true) or if its split up (false). Default true
* @param bool $reset Does xml parser need to be reset. Default false
- * @throws MWException
+ * @throws RuntimeException
* @return bool Success.
*/
public function parse( $content, $allOfIt = true, $reset = false ) {
break;
default:
//this should be impossible to get to
- throw new MWException( "Invalid BOM" );
+ throw new RuntimeException( "Invalid BOM" );
}
} else {
// standard specifically says, if no bom assume utf-8
*
* @param XMLParser $parser XMLParser reference to the xml parser
* @param string $data Character data
- * @throws MWException On invalid data
+ * @throws RuntimeException On invalid data
*/
function char( $parser, $data ) {
}
if ( !isset( $this->mode[0] ) ) {
- throw new MWException( 'Unexpected character data before first rdf:Description element' );
+ throw new RuntimeException( 'Unexpected character data before first rdf:Description element' );
}
if ( $this->mode[0] === self::MODE_IGNORE ) {
if ( $this->mode[0] !== self::MODE_SIMPLE
&& $this->mode[0] !== self::MODE_QDESC
) {
- throw new MWException( 'character data where not expected. (mode ' . $this->mode[0] . ')' );
+ throw new RuntimeException( 'character data where not expected. (mode ' . $this->mode[0] . ')' );
}
// to check, how does this handle w.s.
* This method is called when we hit the "</exif:ISOSpeedRatings>" tag.
*
* @param string $elm Namespace . space . tag name.
- * @throws MWException
+ * @throws RuntimeException
*/
private function endElementNested( $elm ) {
&& !( $elm === self::NS_RDF . ' Description'
&& $this->mode[0] === self::MODE_STRUCT )
) {
- throw new MWException( "nesting mismatch. got a </$elm> but expected a </" .
+ throw new RuntimeException( "nesting mismatch. got a </$elm> but expected a </" .
$this->curItem[0] . '>' );
}
* hit the "</rdf:li>")
*
* @param string $elm Namespace . ' ' . element name
- * @throws MWException
+ * @throws RuntimeException
*/
private function endElementModeLi( $elm ) {
$this->results['xmp-' . $info['map_group']][$finalName]['_type'] = 'lang';
}
} else {
- throw new MWException( __METHOD__ . " expected </rdf:seq> or </rdf:bag> but instead got $elm." );
+ throw new RuntimeException( __METHOD__ . " expected </rdf:seq> or </rdf:bag> but instead got $elm." );
}
}
*
* @param XMLParser $parser
* @param string $elm Namespace . ' ' . element name
- * @throws MWException
+ * @throws RuntimeException
*/
function endElement( $parser, $elm ) {
if ( $elm === ( self::NS_RDF . ' RDF' )
if ( count( $this->mode[0] ) === 0 ) {
// This should never ever happen and means
// there is a pretty major bug in this class.
- throw new MWException( 'Encountered end element with no mode' );
+ throw new RuntimeException( 'Encountered end element with no mode' );
}
if ( count( $this->curItem ) == 0 && $this->mode[0] !== self::MODE_INITIAL ) {
// just to be paranoid. Should always have a curItem, except for initially
// (aka during MODE_INITAL).
- throw new MWException( "Hit end element </$elm> but no curItem" );
+ throw new RuntimeException( "Hit end element </$elm> but no curItem" );
}
switch ( $this->mode[0] ) {
if ( $elm === self::NS_RDF . ' Description' ) {
array_shift( $this->mode );
} else {
- throw new MWException( 'Element ended unexpectedly while in MODE_INITIAL' );
+ throw new RuntimeException( 'Element ended unexpectedly while in MODE_INITIAL' );
}
break;
case self::MODE_LI:
* this should always be <rdf:Bag>
*
* @param string $elm Namespace . ' ' . tag
- * @throws MWException If we have an element that's not <rdf:Bag>
+ * @throws RuntimeException If we have an element that's not <rdf:Bag>
*/
private function startElementModeBag( $elm ) {
if ( $elm === self::NS_RDF . ' Bag' ) {
array_unshift( $this->mode, self::MODE_LI );
} else {
- throw new MWException( "Expected <rdf:Bag> but got $elm." );
+ throw new RuntimeException( "Expected <rdf:Bag> but got $elm." );
}
}
* this should always be <rdf:Seq>
*
* @param string $elm Namespace . ' ' . tag
- * @throws MWException If we have an element that's not <rdf:Seq>
+ * @throws RuntimeException If we have an element that's not <rdf:Seq>
*/
private function startElementModeSeq( $elm ) {
if ( $elm === self::NS_RDF . ' Seq' ) {
. ' it is a Seq, since some buggy software is known to screw this up.' );
array_unshift( $this->mode, self::MODE_LI );
} else {
- throw new MWException( "Expected <rdf:Seq> but got $elm." );
+ throw new RuntimeException( "Expected <rdf:Seq> but got $elm." );
}
}
* we don't care about.
*
* @param string $elm Namespace . ' ' . tag
- * @throws MWException If we have an element that's not <rdf:Alt>
+ * @throws RuntimeException If we have an element that's not <rdf:Alt>
*/
private function startElementModeLang( $elm ) {
if ( $elm === self::NS_RDF . ' Alt' ) {
array_unshift( $this->mode, self::MODE_LI_LANG );
} else {
- throw new MWException( "Expected <rdf:Seq> but got $elm." );
+ throw new RuntimeException( "Expected <rdf:Seq> but got $elm." );
}
}
*
* @param string $elm Namespace and tag names separated by space.
* @param array $attribs Attributes of the element.
- * @throws MWException
+ * @throws RuntimeException
*/
private function startElementModeSimple( $elm, $attribs ) {
if ( $elm === self::NS_RDF . ' Description' ) {
}
} elseif ( $elm === self::NS_RDF . ' value' ) {
// This should not be here.
- throw new MWException( __METHOD__ . ' Encountered <rdf:value> where it was unexpected.' );
+ throw new RuntimeException( __METHOD__ . ' Encountered <rdf:value> where it was unexpected.' );
} else {
// something else we don't recognize, like a qualifier maybe.
wfDebugLog( 'XMP', __METHOD__ .
* @param string $ns Namespace
* @param string $tag Tag name (without namespace prefix)
* @param array $attribs Array of attributes
- * @throws MWException
+ * @throws RuntimeException
*/
private function startElementModeInitial( $ns, $tag, $attribs ) {
if ( $ns !== self::NS_RDF ) {
if ( $this->charContent !== false ) {
// Something weird.
// Should not happen in valid XMP.
- throw new MWException( 'tag nested in non-whitespace characters.' );
+ throw new RuntimeException( 'tag nested in non-whitespace characters.' );
}
} else {
// This element is not on our list of allowed elements so ignore.
* @param string $ns Namespace
* @param string $tag Tag name (no ns)
* @param array $attribs Array of attribs w/ values.
- * @throws MWException
+ * @throws RuntimeException
*/
private function startElementModeStruct( $ns, $tag, $attribs ) {
if ( $ns !== self::NS_RDF ) {
) {
// This assumes that we don't have inter-namespace nesting
// which we don't in all the properties we're interested in.
- throw new MWException( " <$tag> appeared nested in <" . $this->ancestorStruct
+ throw new RuntimeException( " <$tag> appeared nested in <" . $this->ancestorStruct
. "> where it is not allowed." );
}
array_unshift( $this->mode, $this->items[$ns][$tag]['mode'] );
if ( $this->charContent !== false ) {
// Something weird.
// Should not happen in valid XMP.
- throw new MWException( "tag <$tag> nested in non-whitespace characters (" .
+ throw new RuntimeException( "tag <$tag> nested in non-whitespace characters (" .
$this->charContent . ")." );
}
} else {
*
* @param string $elm Namespace . ' ' . tagname
* @param array $attribs Attributes. (needed for BAGSTRUCTS)
- * @throws MWException If gets a tag other than <rdf:li>
+ * @throws RuntimeException If gets a tag other than <rdf:li>
*/
private function startElementModeLi( $elm, $attribs ) {
if ( ( $elm ) !== self::NS_RDF . ' li' ) {
- throw new MWException( "<rdf:li> expected but got $elm." );
+ throw new RuntimeException( "<rdf:li> expected but got $elm." );
}
if ( !isset( $this->mode[1] ) ) {
// This should never ever ever happen. Checking for it
// to be paranoid.
- throw new MWException( 'In mode Li, but no 2xPrevious mode!' );
+ throw new RuntimeException( 'In mode Li, but no 2xPrevious mode!' );
}
if ( $this->mode[1] === self::MODE_BAGSTRUCT ) {
if ( !isset( $this->curItem[1] ) ) {
// be paranoid.
- throw new MWException( 'Can not find parent of BAGSTRUCT.' );
+ throw new RuntimeException( 'Can not find parent of BAGSTRUCT.' );
}
list( $curNS, $curTag ) = explode( ' ', $this->curItem[1] );
$this->ancestorStruct = isset( $this->items[$curNS][$curTag]['map_name'] )
*
* @param string $elm Namespace . ' ' . tag
* @param array $attribs Array of elements (most importantly xml:lang)
- * @throws MWException If gets a tag other than <rdf:li> or if no xml:lang
+ * @throws RuntimeException If gets a tag other than <rdf:li> or if no xml:lang
*/
private function startElementModeLiLang( $elm, $attribs ) {
if ( $elm !== self::NS_RDF . ' li' ) {
- throw new MWException( __METHOD__ . " <rdf:li> expected but got $elm." );
+ throw new RuntimeException( __METHOD__ . " <rdf:li> expected but got $elm." );
}
if ( !isset( $attribs[self::NS_XML . ' lang'] )
|| !preg_match( '/^[-A-Za-z0-9]{2,}$/D', $attribs[self::NS_XML . ' lang'] )
) {
- throw new MWException( __METHOD__
+ throw new RuntimeException( __METHOD__
. " <rdf:li> did not contain, or has invalid xml:lang attribute in lang alternative" );
}
* @param XMLParser $parser
* @param string $elm Namespace "<space>" element
* @param array $attribs Attribute name => value
- * @throws MWException
+ * @throws RuntimeException
*/
function startElement( $parser, $elm, $attribs ) {
if ( count( $this->mode ) === 0 ) {
// This should not happen.
- throw new MWException( 'Error extracting XMP, '
+ throw new RuntimeException( 'Error extracting XMP, '
. "encountered <$elm> with no mode" );
}
$this->startElementModeQDesc( $elm );
break;
default:
- throw new MWException( 'StartElement in unknown mode: ' . $this->mode[0] );
+ throw new RuntimeException( 'StartElement in unknown mode: ' . $this->mode[0] );
}
}
* @codingStandardsIgnoreEnd
*
* @param array $attribs Array attribute=>value
- * @throws MWException
+ * @throws RuntimeException
*/
private function doAttribs( $attribs ) {
// first check for rdf:parseType attribute, as that can change
}
} elseif ( isset( $this->items[$ns][$tag] ) ) {
if ( $this->mode[0] === self::MODE_SIMPLE ) {
- throw new MWException( __METHOD__
+ throw new RuntimeException( __METHOD__
. " $ns:$tag found as attribute where not allowed" );
}
$this->saveValue( $ns, $tag, $val );