rdbms: optimize DatabaseDomain::newFromId() to remember the string form
[lhc/web/wiklou.git] / includes / libs / rdbms / database / domain / DatabaseDomain.php
index 5dd4b49..5698cf8 100644 (file)
@@ -53,9 +53,7 @@ class DatabaseDomain {
                }
                $this->schema = $schema;
                if ( !is_string( $prefix ) ) {
-                       throw new InvalidArgumentException( 'Prefix must be a string.' );
-               } elseif ( $prefix !== '' && substr( $prefix, -1, 1 ) !== '_' ) {
-                       throw new InvalidArgumentException( 'A non-empty prefix must end with "_".' );
+                       throw new InvalidArgumentException( "Prefix must be a string." );
                }
                $this->prefix = $prefix;
        }
@@ -92,7 +90,10 @@ class DatabaseDomain {
                        $schema = null;
                }
 
-               return new self( $database, $schema, $prefix );
+               $instance = new self( $database, $schema, $prefix );
+               $instance->equivalentString = (string)$domain;
+
+               return $instance;
        }
 
        /**